
2024.03 arXiv, Gholami
LLM의 main performance bottlenck은 (기존 computing에서) memory bandwidth이 되어가고 있다.
(특히 LLM serving에서)
LLM을 train하기 위해 필요한 연산량은 750x/2yrs로 증가하고 있다.
operation(연산)을 완료하는데 걸리는 시간은 두 가지에 의존.
compute: arithmetic을 얼마나 빨리 수행할 수 있는지
memory bandwidth: hardware의 arithmetic units에 data를 얼마나 빨리 feed할 수 있는지.
hardware가 computing(arithmetic)을 아무리 빠르게 하더라도, DRAM bandwidth 때문에 제한된다.
data는 Cache에 이미 있거나,
DRAM에서 fetch해야 하거나
80%의 데이터가 cache에 즉시 사용 가능한 상태로 있고
단 20%만 DRAM에서 가져와야 한다고 해도,
만약 이 20%의 cache-miss 데이터를 가져오는 데 5 cycles 이상 걸린다면,
전체 operation 완료 시간은 전적으로 DRAM에 의해 제한된다.
문제
different levels of "memory data transfer"
compute는 bottlececk이 아니다. memory가 bottleneck.
single chip memory capacity << LLM size
LLM size는 410x/2yrs로 증가 (2018-2022)
이는 single chip의 memory capacity를 초과.
가능한 반문: single chip의 memory capacity와 bandwidth 문제를 해결하기 위해,
distributed-memory parallelism을 사용해서 multiple accelerator들로 training/serving을 scaling out하면 되지 않냐?
model이 single chip에 fit하더라도,
intra-chip memory transfer가 bottleneck.
(from/to registers, L2 cache, global memory, etc.)
Transformer의 두 가지 architecture를 실험.
encoder architecture(e.g. BERT), decoder architecture(e.g. GPT)
Arithmetic Intensity의 필요성
performance bottleneck을 measure하기 위한 popular method는
encoder-only, decoder-only model을 compute하기 위한 total number of FLOPs
하지만, 이것만 놓고 보는 것은 잘못된 해석으로 이끌 수 있다.
operation의 arithmetic intensity를 봐야 한다.

Arithmetic Intensity: memory로부터 load되는 per byte(즉, data) 당 수행되는 num of FLOPs를 의미.
(MOPs: Memory Operation)
Tansformer workloads의 bottleneck을 분석하기 위해,
Transformer inference를 intel Gold 6242 CPU에서 profiling.
결과

decoder-only (GPT-2)의 latency가 encoder-only(BERT 계열)보다 훨씬 큼
(각 sequence length에 대해서. BERT-Base와 GPT-2는 거의 동일한 model config를 갖고 있음에도)
이는 GPT의 auto-regressive inference에 내재된
higher memory operations와 lower arithmetic intensity of matrix-vector operations 때문.
deocder model
auto-regressive inference: 이전에 생성된 token들을 기반으로, 한 번에 하나의 token 생성.
따라서, sequential하게, 각 step에서 matrix-vector multiplication 수행
(weight matrix와 지금까지 생성된 token들의 hidden states(embeddings) 간의 multiplication)
각 token마다 이전에 생성된 token들을 retrieve하기 위해 frequent한 memory access가 필요.
fewer computations relative to the amount of memory being accessed (= lower arithmetic intensity)
bottleneck = memory bandwidth
encoder model
모든 token들을 parallel로 처리.
한 번에 matrix-matrix multiplication 수행.
larger data chunks and more computations per memory access (=high arithmetic intensity)
arithmetic intensity가 높은 model은 낮은 model보다 더 빠르게, (동일한, 혹은 더 많은 FLOPs에서도) 실행 가능하다.
이는 decoder models (at low batch sizes)에서 major bottleneck은 compute가 아닌 memory wall임을 명확히 보여준다.
challenge(for training NN models)와 promising approache들
challenge 1: need for brute-force hyperparameter tuning.
promising approach: reducing memory footprint &
increasing the data locality of optimizatino algorithms,
at the expense of performing computation

promising approach: low-precision training에 robust한 optimization 알고리즘.
Model compression
Approach 1: Quantization(reducing precision)
Approach 2: Pruning(removing redundant parameters)
현재 여기 까지 가능.
challenge: 이 이상으로 하는거.
Approach 3: Design small LLMs
peak compute를 희생해서, compute/bandwidth trade-off를 달성할 수도 있음.
CPU 구조는 최적화된 cache hierarchy 이미 사용.
이것이 CPU가 GPU보다 bandwidth-bound 문제에 더 좋은 성능을 보이는 이유.
CPU의 challenge: peak compute capability (즉, FLOPS)가 GPU나 TPU와 같은 AI accelerator들보다 매우 낮음.
AI accelerator들이 주로 maximum peak compute를 달성하도록 설계되었기 때문.
가능한 대안