The Efficient Transformer

OTAKAR.AI

The Efficient Transformer

Reference sheet
Updated Sept 2026
Sources: DeepSeek-V2/V3 technical reports, EAGLE/Medusa papers, vLLM & serving benchmarks

Everything that makes the same weights run faster, cheaper, and at higher concurrency — from a single KV vector to a full serving cluster. Figures below are drawn from published model cards and inference-serving benchmarks; treat multipliers as directional, not guarantees on your own stack.

1The one number that explains almost everythingThe bottleneck


A transformer spends its inference budget in two very different ways. Prefill reads your prompt in one parallel pass — compute-bound, GPU-flops-limited. Decode generates one token at a time, each step re-reading the entire model's weights plus every cached key/value pair from every prior token — memory-bandwidth-bound. Almost every technique below attacks one side of that split.

time per decode step ≈ (bytes moved from HBM) / (memory bandwidth) — not FLOPs, bandwidth
SymptomBound bySections that fix it
Slow time-to-first-tokenPrefill compute / queueing§6 batching, §6 disaggregation
Slow tokens/sec per userDecode memory bandwidth§2 KV design, §4 quantization, §5 speculative decoding
Can't raise batch size / GPU OOMKV cache + weight capacity§2–§3 KV design, §4 quantization
Model itself is too big to loadTotal parameter footprint§3 MoE sparsity, §4 quantization

2The KV cache taxAttention memory


Every generated token stores a key and value vector, per layer, per head, for the rest of the sequence. That cache — not the model weights — is usually what caps your batch size and context length.

KV cache / token = 2 (K&V) × n_layers × n_heads × d_head × bytes_per_param
e.g. a 128-head, 128-dim, 61-layer model at FP16 → 2 × 61 × 128 × 128 × 2B = ~4.0 MB / token
at 128K context, single sequence → ~512 GB — far past any single GPU

Three families of fix exist, in increasing order of architectural intrusiveness: share KV heads across queries (MQA, GQA), compress KV into a low-rank latent (MLA), or reduce cache precision (§4). Nearly every 2025–2026 frontier open-weight model ships one of the first two.

Attention variants — KV heads
VariantKV headsQuality vs MHA
MHA baselinen_headsreference
GQA (8 groups)8~matches MHA
MQA1measurable drop
MLA (latent)1 latent vec.meets or beats MHA
KV cache reduction vs. MHA
VariantReduction
GQA, 8 groups (128→8 heads)~72%
MLA — DeepSeek-V2 (small MoE)~86%
MLA — DeepSeek-V2 (large MoE)~96%
MLA — DeepSeek-V3 config~93–98%

MLA in one line: instead of caching full-size K and V per head, DeepSeek-V2/V3 down-project them into one shared latent vector c_kv (dim 512) and reconstruct K/V on the fly at decode time via learned up-projection matrices, absorbed into the attention weights so no extra decode FLOPs are paid.

Concurrency payoff: at 128K context on an H200 (141 GB), reported figures show ~8–9 concurrent sessions under MLA versus ~1–2 under MHA / GQA on the same card — because the cache, not the weights, was the ceiling.

3Sparse mixture-of-expertsCompute per token


MoE decouples total capacity from compute per token: a router sends each token to a small subset of expert FFN blocks (plus, in most 2025–2026 designs, one or two "shared" experts every token visits). You pay memory for all the experts, but compute for only the active ones.

ModelTotal paramsActive paramsSparsityRouting
Mixtral 8x7B46.7B12.9B27.6%2 of 8 experts
DeepSeek-V2236B21B8.9%6 of 160 + shared
DeepSeek-V3671B37B5.5%8 of 256 + shared
Llama 4 Maverick400B17B4.3%1 of 128 + shared
Kimi K2.5~1T32B3.2%fine-grained routed

Total params ≈ VRAM to hold the model; active params ≈ FLOPs and, roughly, decode latency per token. A 671B/37B model needs 671B-worth of memory but computes like a ~37B dense model per forward pass — the "MoE VRAM trap" for anyone sizing hardware off active params alone.

4QuantizationPrecision per parameter


Lower precision shrinks both the weight footprint and — because decode is bandwidth-bound — the bytes that must move per step, which is usually the bigger win.

FormatBytes / paramSize vs FP16Typical quality cost
FP16 / BF162.01.0×reference
FP81.00.5×near-lossless on most models
INT81.00.5×small, implementation-dependent
INT4 weight-only0.50.25×noticeable on some tasks; strong with calibration
KV cache — INT80.5× of §2 figureusually small
KV cache — INT40.25× of §2 figureattention-quality risk rises

Quantization compounds with §2 and §3: an INT4, MoE, MLA model can occupy well under a tenth of the memory of its dense FP16 MHA equivalent for a comparable active-parameter count.

5Speculative decodingSequential steps


Idea: a small draft mechanism proposes several tokens ahead; the full model verifies them all in one forward pass. Every accepted token is one expensive sequential decode step you didn't have to pay for — output distribution is unchanged, since the target model still makes the final call on every token.
expected tokens / verification step ≈ (1 − α^(k+1)) / (1 − α) — α = acceptance rate, k = draft length
α = 0.85, k = 4 → ~3.3 tokens/step  ·  α = 0.60, k = 4 → ~2.0 tokens/step
MethodTypical acceptance αReported speedupMechanism
Medusa60–80%2.2–3.6×parallel heads on target model, no separate draft model
EAGLE-275–80%2.7–3.5× (70B)autoregressive draft on target's hidden states
EAGLE-380–88%3–6.5×draft head fused across all target layers
DeepSeek MTP (built-in)>80%~1.8×native multi-token-prediction head

Below α ≈ 0.5, verification overhead can make speculative decoding slower than plain autoregressive decode — and MoE targets are harder to accelerate this way, since only the routed experts' weights need reading per step regardless of draft length.

6Serving-layer efficiencyCluster utilization


TechniqueWhat it changesBest when
Continuous batchingNew requests join at token boundaries, not batch boundariesalmost always on — one of the highest-leverage serving wins available
PagedAttentionKV cache allocated in fixed blocks instead of contiguous, over-provisioned buffersmany concurrent, variable-length requests
Prefix / chunked prefill cachingReuse KV state for repeated system prompts, RAG context, agent scaffoldingshared prefixes across requests
Prefill/decode disaggregationSeparate GPU pools for the compute-bound and bandwidth-bound phaseslarge, heterogeneous traffic that justifies the KV-transfer cost
Tensor / pipeline / expert parallelismSplit weights, layers, or experts across GPUsmodel doesn't fit on one GPU, or MoE experts need spreading

7Stacking the gainsIllustrative, not additive


These techniques multiply, not add, and they apply to different resources — memory, bandwidth, sequential steps — so no single number represents "total speedup." As an illustration of scale, relative memory-per-token for a frontier-scale model, applying techniques cumulatively:

Dense · FP16 · MHA
100%
+ MLA attention
~7%
+ MoE (active-param basis)
~3.5%
+ FP8 weights/cache
~1.8%

Bars are directional composition of the reduction ratios in §2–§4 (MLA ~93%, MoE active/total ~50% further on top of an already-sparse base, FP8 ~50%) — not a benchmark from one model. Speculative decoding (§5) and serving-layer gains (§6) stack on top of this as reductions in sequential steps and idle GPU time, not memory, so treat them as a separate multiplier on throughput.

1

Fit first. If the model and its KV cache don't fit in memory at your target concurrency, nothing downstream matters — reach for MoE sparsity, quantization, or MLA/GQA before anything else.

2

Measure the split. Separate TTFT, TPOT, throughput, and p95 latency — you cannot tell if you're compute- or bandwidth-bound without them.

3

Fix the actual bottleneck. Attention-kernel work (FlashAttention) matters when attention is the bottleneck, not by default — profile before optimizing.

4

Attack the KV cache next. It usually determines production concurrency more than any other single lever, and GQA/MLA/quantization compose.

5

Add speculative decoding once α is known. Measure real acceptance rate on your traffic before adopting a headline multiplier from a paper.

6

Optimize the cluster last. Disaggregation and exotic scheduling pay off only at a scale that justifies their operational complexity.