The Long-Context Cost Cliff: A Decision Tree for Your Inference Architecture
If you're self-hosting long-context inference without architectural optimization, you are almost certainly losing money on every request. New analysis with production numbers makes the case unambiguous: on a 70B model on an H100, extending context from 4K to 128K collapses concurrent users from 59 to 1 and inflates hardware cost to $19.84/M output tokens — exceeding what Claude and OpenAI charge retail.
The root cause is widely misunderstood. Decode is memory-bandwidth bound, not compute bound. FlashAttention — the optimization everyone defaults to — helps prefill but doesn't move the needle on decode, where your cost actually lives. The KV cache at 128K on a 70B model consumes ~21GB per user, eating all available HBM.
Four Levers, One Decision Tree
The solution space maps to four orthogonal and composable techniques:
- DeepSeek MLA — 93.3% KV cache reduction. Drops per-user cache from ~21GB to ~1.4GB, restoring concurrency to 27 users and cost to $0.73/M tokens. This is the most production-viable option today, but requires models trained with MLA (DeepSeek-V2) due to a decoupled RoPE strategy. This is a model architecture change, not a serving optimization.
- KIVI asymmetric quantization — K=2-bit per-channel, V=2-bit per-token. Delivers 2.6× memory reduction as a serving-layer change with minimal quality loss. Lowest friction to deploy.
- Hybrid Mamba-Attention (Jamba-style 1:7 ratio) — Fits 50B MoE at 256K on a single H100 (~39.3GB vs. 98GB for pure transformer). But vLLM's PagedAttention assumes KV cache is the only per-request state; Mamba layers introduce a second memory pool requiring custom dual-pool schedulers and 2-4 months of serving stack work.
- Distributed Ring Attention — Perfect recall at 1M+ tokens. Meta proved it: 1M tokens on Llama 3 405B in 77 seconds across 128 H100s at 93% efficiency for prefill. But decode has a 2,500× compute-to-transfer mismatch. This is a revenue-enablement play for prefill-heavy jobs, not a cost play for chat.
There is no single architecture that solves long-context inference. The winning approach is workload-aware architecture selection.
Critical Failure Modes
Mamba's quantization error compounding through the recurrent chain is a deployment showstopper: INT8 rounding error at token 1 grows exponentially through 100K tokens, forcing FP32 state storage. Linear Attention achieves only ~2 FLOPs/byte against H100's 591 roofline — 0.3% hardware utilization — and feature collision destroys exact retrieval. StreamingLLM works for conversational flows that don't need full recall but is fundamentally lossy.
The Bottom Line for Your Stack
Profile your production workloads to determine actual context length distribution. If >50% of requests are under 32K, your optimization priority is throughput at short context, not long-context heroics. If you have significant 128K+ traffic, MLA + KIVI + PagedAttention is the production-ready stack today. Compare your total self-hosting cost against API providers who already have MLA-class optimizations baked in — the buy-vs-build answer may surprise you.
What to do
Profile production inference workloads to determine actual context length distribution and prefill-vs-decode ratio this sprint
Benchmark KIVI asymmetric quantization (K=2bit, V=2bit) on your serving stack this sprint as lowest-friction KV cache reduction
Audit total self-hosting cost at >32K context vs. API providers with MLA-class optimization by end of quarter
Track diffusion-based LLMs (Inception Mercury 2) as potential paradigm disruption to autoregressive decode bottleneck