Product wants to offer a 1M-token context window on a model you self-host. What breaks in serving, and how do you make it work?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Three things break at once: the KV cache for one request outgrows a GPU, prefill takes long enough to be a product problem of its own, and a single such request can starve everyone else on the box. Size it before agreeing to it.
Full worked answer with diagram
Three things break at once: the KV cache for one request outgrows a GPU, prefill takes long enough to be a product problem of its own, and a single such request can starve everyone else on the box. Size it before agreeing to it.
Memory. With the 70B GQA shape used earlier (~320 KB per token at FP16), 1M tokens is ~330 GB of KV for one sequence, several GPUs' worth of HBM. FP8 KV halves that. Architectures with MLA, sliding-window layers or linear-attention hybrid layers cut it far further, which is why long-context models are built that way. Either way, a 1M request needs its own capacity class.
Prefill. Attention FLOPs grow quadratically, so at 1M tokens attention dominates the linear-layer work, and on one GPU prefill would take tens of minutes even if memory allowed it. The fix is context parallelism: shard the sequence across GPUs, each holding a slice of Q, K and V, and pass KV blocks around a ring (ring attention) or gather them, overlapping communication with compute. Prefill time drops roughly with GPU count, and the KV cache ends up sharded across devices.
Decode. Every step reads the whole KV cache, and that read does not amortise across the batch the way weights do, so per-token latency rises with context. Keep the KV sharded: each GPU computes partial attention over its slice, and a small combine merges the partial softmaxes.
Scheduling. Route long requests to a dedicated pool so a multi-minute prefill never shares a queue with chat. Admission control must reserve KV for the whole request up front, otherwise it gets preempted halfway and recomputed, the most expensive preemption there is.
Economics and quality. Prefix caching is what makes it affordable: users ask many questions of the same corpus, so the 1M prefill is paid once and reused, ideally from an offload tier. Price long context separately, as some providers do above a threshold. And run long-context evals first, because many models degrade well before their advertised limit.
Worth sketching. It shows the long request taking its own path from admission to reuse, which is the core of the design.
flowchart TD
R["1M-token request"] --> A["Admission: reserve the whole KV<br/>before accepting"]
A --> L["Dedicated long-context pool"]
L --> CP["Context-parallel prefill,<br/>sequence sharded across GPUs"]
CP -->|"KV blocks passed around a ring"| KV["KV cache sharded,<br/>FP8 to halve it"]
KV --> D["Decode: partial attention per GPU,<br/>then a combine"]
KV --> PC["Prefix cache or offload tier<br/>for the next question"]
What a good answer covers
- Three things break at once
- With the 70B GQA shape used earlier (~320 KB per token at FP16), 1M tokens is ~330 GB of KV for one…
- Architectures with MLA, sliding-window layers or linear-attention hybrid layers cut it far further,…
- Either way, a 1M request needs its own capacity class
- Attention FLOPs grow quadratically, so at 1M tokens attention dominates the linear-layer work, and on…
Key terms: Memory · Prefill · context parallelism · Decode · Scheduling · Economics and quality
In the glossary: Prefill · GQA · HBM · FP8 / INT8 · MLA · Decode
Interviewer follow-ups to expect
Why does context parallelism help prefill far more than it helps decode?
Prefill. Attention FLOPs grow quadratically, so at 1M tokens attention dominates the linear-layer work, and on one GPU prefill would take tens of minutes even if memory allowed it. The fix is context parallelism: shard the sequence across GPUs, each holding a slice of Q, K and V, and pass KV blocks around a ring (ring attention) or gather them, overlapping communication with compute. Prefill time drops roughly with GPU count, and the KV cache ends up sharded across devices.
A customer sends a different 900K-token document with every request: how does that change your pricing and capacity plan?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep