정의
LLM 추론에서 latency(지연 시간)와 cost(비용)는 t_compute(계산 시간) 와 t_memory(메모리 시간) 두 요소로 결정되며, 전체 시간은 둘 중 더 큰 값에 의해 bound된다. 최적의 batch size는 t_compute와 t_memory가 같아지는 지점에서 결정되며, 이는 sparsity(활성 파라미터 비율)와 하드웨어의 FLOPs/메모리 대역폭 비율(약 300)에 의해 산출된다.
핵심 속성
- t_compute: (batch size × active parameters) ÷ FLOPs. attention 연산은 편의상 생략하나 실제로 중요.
- t_memory: (total parameters를 로딩하는 시간) + (KV cache를 읽는 시간). 모델 전체 weight와 모든 유저의 KV cache를 HBM에서 읽어야 함.
- roofline 분석: latency 그래프는 batch size가 작을 때 memory-bound, 클 때 compute-bound이며, 최적점(critical point)에서 두 시간이 같아진다.
- 토큰당 cost: latency를 batch size로 나눈 곡선으로, batch가 작을 때 급격히 비싸고 최적 batch 이후 완만해짐.
- sparsity 공식: batch ≈ (FLOPs / memory bandwidth) × (1 / sparsity). FLOPs/bandwidth ≈ 300 (FP4 기준), sparsity가 1/8이면 batch ≈ 2400.
- drain time: HBM 전체를 읽는 시간 ≈ 20ms (GB300 기준 288GB ÷ 20TB/s). 이 시간이 한 inference 사이클의 기준.
- 200K context 임계점: context length가 200K를 넘으면 KV cache 부담이 급증하여 memory-bound로 전환, 가격 티어가 달라짐.
관계
- 20260605-deepseek-v4-sparse-attention — DeepSeek V4는 sparse attention과 MLA로 KV cache 크기를 극단적으로 줄여 roofline 곡선을 낮춤
- 20260605-moe-mixture-of-experts — MoE는 sparsity를 통해 t_compute를 줄이고 batch capacity를 높임
- 20260605-kv-cache-pagedattention — PagedAttention은 KV cache를 page 단위로 관리하여 메모리 효율을 높이고 t_memory를 낮춤
- 20260605-vllm-sglang-inference-engine — vLLM/SGLang은 chunked prefill, continuous batching으로 GPU utilization 극대화
인용
“t_compute와 t_memory, 이 두 개의 조합으로 현대의 LLM inference의 모든 가격이 결정이 된다.” “latency lower bound는 weight를 한 번 로딩하는 시간이며, 이는 HBM 용량과 대역폭에 의해 결정된다.”
출처
- 📎 클리핑: 20260613-ep96-ko-transcript