정의
LLM 추론 서빙에서의 latency와 per-token cost는 연산 시간(t_compute)과 메모리 접근 시간(t_memory) 중 더 큰 값에 의해 결정되며, 이 두 요소는 배치 크기(batch size), 모델의 sparsity(활성 파라미터 비율), 컨텍스트 길이의 함수로 최적화된다.
핵심 속성
- t_compute:
batch * N_active / FLOPs— 활성 파라미터 수와 배치에 선형적. - t_memory:
(N_total * bytes_per_param + batch * avg_context_length * bytes_per_kv) / memory_bandwidth— 전체 파라미터 로딩과 KV cache 로딩의 합. - Roofline Analysis: t_compute와 t_memory의 max가 실제 latency를 결정하며, 배치가 작을수록 memory-bound, 배치가 클수록 compute-bound로 전환.
- 최적 배치 공식:
B_opt = (FLOPs / memory_bandwidth) * sparsity— FLOPs/bandwidth 비율(약 300)과 sparsity의 곱. (예: sparsity 1/8 → B=2400) - Drain Time: HBM 전체 용량을 대역폭으로 나눈 시간(~20ms)으로, 이 시간을 한 inference step의 기준으로 삼음.
- Chunked Prefill: 긴 컨텍스트 prefill을 작게 쪼개 decode 토큰과 섞어 배치를 채움.
관계
- 20260606-inference-bottleneck-memory-bandwidth — t_memory가 지배적인 시나리오를 구체화
- 20260606-moe-sparse-attention-serving-economics — MoE와 sparse attention이 sparsity를 높여 최적 배치를 증가시키는 원리
인용
“t_compute와 t_memory, 이 두 개의 조합으로 현대의 LLM inference의 모든 가격이 결정이 된다.” “Batch가 작을 때는 메모리에 bound되고, 배치가 커지면 compute에 bound된다.” “FLOPs / 메모리 대역폭의 크기는 하드웨어가 발전해도 약 300의 배율을 유지한다.”