A team is benchmarking GPT-5.5 at 200,000 input tokens and 500 output tokens. End to end latency is dominated not by the 500 output tokens but by the prompt itself, with TTFT in the multi-second range and decode steps that get measurably slower than at a 2k-token context. Identify the two distinct cost drivers and explain why one shows up in TTFT and the other in per token decode time.
At 200k input the bill is paid by prefill compute (which sets TTFT) and by the resulting KV cache size (which slows every decode step). Output tokens are a rounding error on this profile.
Imagine you walk into a library and hand the librarian a 200-page document and ask for a one-paragraph summary. Before the librarian can write a single word, they have to read all 200 pages. That reading time is what you wait for at the very beginning, even though no answer has appeared yet. Now while they write the paragraph, every sentence has to be checked against what they remember from the 200 pages, which is a huge stack of notes. So each sentence comes out a bit slower than if the document had been 2 pages. The summary itself is short and cheap; what is expensive is the original reading and the constant flipping through notes.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
At 200k input the bill and the latency are paid by the prompt, not by the answer. Two structural effects produce two distinct cost components: prefill compute drives time-to-first-token, and the resulting KV cache makes every decode step slower for the rest of the request. The 500 output tokens, despite being billed at a higher per-token rate, contribute single-digit percent of wall-clock and bill on this profile.
This deep dive separates the two phases, quantifies each on a realistic frontier-model setup, and ranks the optimization stack from highest leverage (prompt caching) to weakest (output-side tricks).
Prefill compute: where TTFT actually goes
Prefill processes the entire prompt in one parallel forward pass. The compute decomposes into two terms per layer. The MLP and Q/K/V projections are linear-in-n matmuls: each token's vector is projected against the layer's weight matrix, scaling with n * d_model^2. The attention computation produces an n by n attention matrix per head, costing roughly n^2 * d_h FLOPs per layer.
For a 70B model with d_model 8192 and 80 layers at n = 200000: the MLP term is roughly 1.3 * 10^16 FLOPs across all layers; the attention term is roughly 1.0 * 10^16 FLOPs. At length 200k these are comparable. Past 200k the attention term dominates because it grows quadratically.
On H200 with ~1.5 PFLOP/s of FP8 compute throughput, this prefill is several seconds even with FlashAttention keeping the memory traffic tractable. The entire prefill duration lands in TTFT: from the user's perspective, the API call returns the first token only after the full prompt has been ingested.
FlashAttention is the reason this is tractable at all. The naive attention path materializes an n by n attention matrix in HBM, which is 40 GB at n = 200000 (FP16), more than fits per layer. FlashAttention tiles the computation so the intermediate matrix lives only in shared memory and the HBM traffic stays roughly linear in n. The FLOPs are still n^2 but they are done with efficient memory access patterns. Without FlashAttention, 200k prefill would be infeasible on current hardware.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| Latency component | Dominant driver at 200k | What surfaces it | Top mitigation |
|---|---|---|---|
| TTFT (prefill) | Per-token MLP + attention compute over 200k positions | Multi-second wait before first token | Prompt caching of stable prefix |
| TPOT (decode) | Per-step weight + KV bytes loaded from HBM | Each decode step ~45% slower than at 2k | FP8 KV cache, GQA/MLA, TP |
| Output token cost | Small share of bill at 200k:500 ratio | Routine decode latency for 500 tokens | Speculative decoding (weak lever here) |
| Dollar bill | Input tokens (volume) + KV-amplified decode time | Input share dominates total spend | Prompt caching (cuts input cost by ~90%) |
Real products, models, and research that use this idea.
- Anthropic Claude Opus 4.7 at 200k context shows TTFT in the 5-15 second range and per-token decode about 40-60 percent slower than at 4k; the same prompt with cache hit returns the first token in under a second.
- GPT-5.5 long-context benchmarks at 200k routinely report 80-95 percent of cost going to prefill input tokens, even though output is billed at higher per-token rate, simply because there are 400x more input tokens.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does FlashAttention change the prefill cost at 200k?
FlashAttention does not reduce the n^2 FLOPs of attention but tiles the computation so the n^2 intermediate matrix never materializes in HBM. HBM bandwidth becomes linear in n instead of n^2, making prefill compute-bound rather than memory-bound at long context, which is what actually makes 200k tractable on production hardware.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Thinking the output token count drives long-context latency. At 200k input and 500 output, the prompt processing and the KV-amplified decode dominate; the 500 output tokens contribute single-digit percent of wall-clock and bill.
60 second bullets to scan on the way to the call.
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.