kv-cache llm-inference token-budget gqa prefill-decode mha energy-cost simple-law
Abstract
Generative AI is billed per token, yet tokens are not equally expensive. Each token enters the KV-cache and raises the cost of those that follow, so energy grows non-linearly along a sequence whose tokens look identical. No analytical model states what a token costs, and the most accurate SOTA model is a fit, not a law: it absorbs architecture into fitted coefficients, requiring per-LLM fitting. We derive closed-form expressions of the computational and memory-access complexity of LLM inference in terms of architectural hyperparameters, covering MHA and GQA, and compare a family of analytical models of increasing granularity. From these, we obtain the SIMPLE Inference Model to Predict LLMs Energy (SIMPLE), a four-parameter law that separates prefill from decode, and decode into KV-cache cost and next-token computation. Over traces of 13 dense LLMs from six families on NVIDIA H100 GPUs, it attains R2 = 0.969 and 11.97% MAPE, 3.1-3.5x below the SOTA, without per-LLM calibration. The SIMPLE law explains as well as predicts: prefill energy grows quadratically with the hidden dimension, so larger LLMs suffer most from long inputs; and more aggressive GQA KV grouping reduces the per-token energy by up to 3x relative to standard MHA. Increasing the reasoning token budget pushes output length beyond the analytically derived energy minimum, driving super-linear energy growth; although accuracy grows with the budget, energy grows faster, so Intelligence per Joule peaks at an intermediate budget and falls by up to 3.14x across a 4.0x reasoning-budget range. Agentic serving raises energy per request by 13.0x relative to non-agentic ones, driven by the growth of both the prefill and the KV-cache terms with input length; while prefix caching removes most of the prefill cost (-93%), the KV-cache term is unaffected, so even a cached agentic request costs 4.8x more.
한국어 요약
한 줄 요약
SIMPLE은 LLM 추론 에너지 소비를 아키텍처 하이퍼파라미터로 예측하는 4개 파라미터 모델로, 기존 최고 모델 대비 3.1–3.5배 낮은 MAPE를 달성했다.
핵심 기여도
- SIMPLE 모델은 prefill과 decode를 분리하고, decode를 KV-cache와 next-token 계산으로 분해하여 4개 파라미터로 LLM 추론 에너지를 예측.
- 13개의 다양한 LLM(예: OPT, LLaMA, Gemma 등)에서 R²=0.969, MAPE=11.97%를 달성하며, 기존 최고 모델(SweetSpot) 대비 3.1–3.5배 낮은 오차.
- GQA가 MHA 대비 토큰당 에너지를 최대 3배 감소시키는 것을 분석.
- 에이전트형 요청은 비에이전트형 대비 13.0배 더 많은 에너지를 소모하며, prefix caching은 prefill 비용을 -93% 감소시키지만 KV-cache 비용은 영향 없음.
핵심 아이디어
LLM 추론 에너지는 토큰당 비용이 일정하지 않으며, KV-cache에 저장된 토큰 수에 따라 비선형적으로 증가한다. 기존 모델은 아키텍처 정보를 피팅 계수에 암묵적으로 포함하여 일반화가 어려웠다. SIMPLE은 MHA와 GQA를 포함한 아키텍처 하이퍼파라미터(예: hidden dimension, attention 구조)를 기반으로 수식적으로 에너지를 예측한다. prefill 단계는 hidden dimension의 제곱에 비례하여 에너지가 증가하며, GQA의 KV 그룹화는 토큰당 에너지를 3배까지 줄인다. 이는 기존 모델이 아키텍처를 명시적으로 고려하지 못한 한계를 해결한다.
기술적 접근법
- **모델**: SIMPLE은 prefill과 decode 단계를 분리하고, decode는 KV-cache와 next-token 계산으로 분해.
- **하이퍼파라미터**: hidden dimension, attention head 수, GQA 그룹 수 등.
- **데이터**: 13개의 dense LLM (OPT, LLaMA, Gemma, Falcon, Qwen2, Granite 등)의 추적 데이터.
- **성능 지표**: R²=0.969, MAPE=11.97%, 기존 최고 모델 대비 3.1–3.5배 낮은 오차.
- **알고리즘**: attention 메커니즘(예: MHA, GQA)을 수식적으로 모델링하여 에너지 복잡도를 도출.
주요 결과
- **데이터셋**: 13개의 LLM에서 R²=0.969, MAPE=11.97%.
- **비교**: 기존 최고 모델(SweetSpot) 대비 3.1–3.5배 낮은 오차.
- **GQA 효과**: MHA 대비 토큰당 에너지를 최대 3배 감소.
- **에이전트 요청**: 비에이전트 대비 13.0배 더 많은 에너지 소비.
- **prefix caching**: prefill 비용 -93% 감소, KV-cache 비용은 영향 없음.
의의 및 한계
SIMPLE은 LLM 아키텍처 하이퍼파라미터를 기반으로 에너지를 예측하는 첫 번째 분석적 모델로, 에너지 최적화와 아키텍처 설계에 중요한 기초를 제공한다. 특히, GQA의 에너지 절감 효과와 에이전트형 요청의 에너지 증가를 정량적으로 설명하며, 추론 토큰 예산이 Intelligence per Joule에 미치는 영향을 분석한다. 그러나 현재는 single-GPU, dense LLM에만 적용되며, MoE, batch size, multi-GPU 배포는 포함되지 않아 한계가 있다.
실용적 활용
SIMPLE은 LLM 아키텍처 설계, 추론 에너지 최적화, 클라우드 서비스의 가격 책정, 에이전트형 AI의 에너지 관리 등에 활용 가능하다. 특히, GQA 선택이나 토큰 예산 설정 시 에너지 효율을 예측하여 비용 절감에 기여할 수 있다.