Zenaique

Name the dominant cost driver of GPT-5.5 latency at a 200k-token input

Short answer·Medium·4.0 · 0·~3 min·Asked atAccentureMoveworksOpenAI
Attempt it

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.

Free · 2 AI evals / day
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

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.

The KV cache: a 200k input leaves 64 GB behind
Decode with a large KV: every step is slower
Where the bill actually goes and the optimization ranking
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
Latency componentDominant driver at 200kWhat surfaces itTop mitigation
TTFT (prefill)Per-token MLP + attention compute over 200k positionsMulti-second wait before first tokenPrompt caching of stable prefix
TPOT (decode)Per-step weight + KV bytes loaded from HBMEach decode step ~45% slower than at 2kFP8 KV cache, GQA/MLA, TP
Output token costSmall share of bill at 200k:500 ratioRoutine decode latency for 500 tokensSpeculative decoding (weak lever here)
Dollar billInput tokens (volume) + KV-amplified decode timeInput share dominates total spendPrompt 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.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does FlashAttention change the prefill cost at 200k?
A

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.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

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.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Prefill compute scales super-linearly with prompt length, driven by attention

  • Prefill cost surfaces as TTFT

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy