F
Member
TTFT at 32k context is set by prefill chunking and KV math, not by the model card
We kept missing a 2 s TTFT SLO on 32k-token requests while the same model answered 2k-token requests in 300 ms. The model was not the variable. Here is the arithmetic that made it obvious, and the measurement order we now use before touching anything.
Step 1: budget the prefill, don't guess it. Dense 8B active params, 32,768 tokens: prefill FLOPs ≈ 2 × 8e9 × 32768 ≈ 5.2e14. On one H100 at bf16, real prefill efficiency lands at 35–45% of the 989 TFLOPS peak, so call it 400 TFLOPS sustained: 1.3 s of pure prefill. Add the quadratic attention term (it is small at 32k for GQA but not zero) and tokenization of a 120k-character prompt (30–80 ms at 4–5 MB/s). Queueing is the rest: if four 32k requests arrive together and you run them serially, the fourth one's TTFT is 4×1.3 s plus decode interleaving.
Step 2: KV cache decides your concurrency, not weights. 32 layers, 8 KV heads, head_dim 128, fp16: 2 × 32 × 8 × 128 × 2 B = 131 KB per token, so 32k tokens = 4.3 GB per request. Four concurrent requests = 17 GB of KV alone. On an 80 GB card this is fine; on a 24 GB card you get four concurrent 32k sessions and nothing else, and any "just raise batch size" advice is wrong until you shrink KV (fp8 KV halves it to 65 KB/token, which buys exactly 2× at a measurable quality cost you should A/B on your own eval set, not assume).
Step 3: chunked prefill trades TTFT for ITL. Full prefill of 32k gives the best TTFT but blocks the decode loop for over a second, so p99 inter-token latency jumps to ~900 ms and streaming users think the app hung. Chunk at 512 or 1024 tokens and the numbers move the other way: measured on the same box, chunk=512 gave TTFT 1.35 s vs 1.15 s for monolithic prefill (about 17% worse) while p99 ITL fell from 900 ms to 60 ms. Chunk=1024 sits near 1.2 s / 110 ms. If your SLO is TTFT-only, you are optimizing the wrong side of this trade.
Step 4: measure it properly, because most TTFT numbers in the wild are wrong.
- Report p50 and p99 over at least 50 runs after 3 warmups, with clocks pinned (nvidia-smi -lgc), otherwise boost behavior alone moves you 10%.
- Generate prompts by token count from the actual tokenizer, not by character count. A 4.0 chars/token assumption on Chinese or code can be off by 30%, which is 10k tokens at 32k scale.
- Time with CUDA events or nsys around the prefill kernel plus the first sampled token, not around the whole completion. Streaming off means you are measuring full generation.
- Separate queue time from compute time by logging admission timestamp and prefill-start timestamp. We found 40% of our "TTFT" was queue, which no kernel work would have fixed.
Step 5: two things worth trying before rewriting the stack. Prefix caching helps only if the hit is real: a 30% hit rate at 32k skips roughly 0.4 s, but a shared system prompt of 800 tokens on a 32k request is a 2.4% saving and will not show up in your p99 at all. Prefill/decode disaggregation is the other lever: moving a 4.3 GB KV block over 200 Gb/s RDMA is 0.17 s at wire speed and 0.3 s at a realistic 60% of line rate, so it only pays when the prompt is long enough that the transfer is a small fraction of prefill — in our case above 16k tokens, and not below.
Counterexamples worth avoiding: benchmarking TTFT on a single request while production has concurrency 8; quoting mean TTFT with a 3× p99 tail; assuming prefill throughput scales linearly with batch (chunked prefill caps it); and tuning chunk size on synthetic uniform-length traffic when real traffic is 90% short and 10% long — that mix needs a shortest-prefill-first queue, otherwise the long requests own the p99.
What are people seeing for 32k TTFT on a single H100 with chunked prefill enabled — is 1.2–1.4 s in line with your numbers, or is someone getting meaningfully below 1 s on open-weight models?
We kept missing a 2 s TTFT SLO on 32k-token requests while the same model answered 2k-token requests in 300 ms. The model was not the variable. Here is the arithmetic that made it obvious, and the measurement order we now use before touching anything.
Step 1: budget the prefill, don't guess it. Dense 8B active params, 32,768 tokens: prefill FLOPs ≈ 2 × 8e9 × 32768 ≈ 5.2e14. On one H100 at bf16, real prefill efficiency lands at 35–45% of the 989 TFLOPS peak, so call it 400 TFLOPS sustained: 1.3 s of pure prefill. Add the quadratic attention term (it is small at 32k for GQA but not zero) and tokenization of a 120k-character prompt (30–80 ms at 4–5 MB/s). Queueing is the rest: if four 32k requests arrive together and you run them serially, the fourth one's TTFT is 4×1.3 s plus decode interleaving.
Step 2: KV cache decides your concurrency, not weights. 32 layers, 8 KV heads, head_dim 128, fp16: 2 × 32 × 8 × 128 × 2 B = 131 KB per token, so 32k tokens = 4.3 GB per request. Four concurrent requests = 17 GB of KV alone. On an 80 GB card this is fine; on a 24 GB card you get four concurrent 32k sessions and nothing else, and any "just raise batch size" advice is wrong until you shrink KV (fp8 KV halves it to 65 KB/token, which buys exactly 2× at a measurable quality cost you should A/B on your own eval set, not assume).
Step 3: chunked prefill trades TTFT for ITL. Full prefill of 32k gives the best TTFT but blocks the decode loop for over a second, so p99 inter-token latency jumps to ~900 ms and streaming users think the app hung. Chunk at 512 or 1024 tokens and the numbers move the other way: measured on the same box, chunk=512 gave TTFT 1.35 s vs 1.15 s for monolithic prefill (about 17% worse) while p99 ITL fell from 900 ms to 60 ms. Chunk=1024 sits near 1.2 s / 110 ms. If your SLO is TTFT-only, you are optimizing the wrong side of this trade.
Step 4: measure it properly, because most TTFT numbers in the wild are wrong.
- Report p50 and p99 over at least 50 runs after 3 warmups, with clocks pinned (nvidia-smi -lgc), otherwise boost behavior alone moves you 10%.
- Generate prompts by token count from the actual tokenizer, not by character count. A 4.0 chars/token assumption on Chinese or code can be off by 30%, which is 10k tokens at 32k scale.
- Time with CUDA events or nsys around the prefill kernel plus the first sampled token, not around the whole completion. Streaming off means you are measuring full generation.
- Separate queue time from compute time by logging admission timestamp and prefill-start timestamp. We found 40% of our "TTFT" was queue, which no kernel work would have fixed.
Step 5: two things worth trying before rewriting the stack. Prefix caching helps only if the hit is real: a 30% hit rate at 32k skips roughly 0.4 s, but a shared system prompt of 800 tokens on a 32k request is a 2.4% saving and will not show up in your p99 at all. Prefill/decode disaggregation is the other lever: moving a 4.3 GB KV block over 200 Gb/s RDMA is 0.17 s at wire speed and 0.3 s at a realistic 60% of line rate, so it only pays when the prompt is long enough that the transfer is a small fraction of prefill — in our case above 16k tokens, and not below.
Counterexamples worth avoiding: benchmarking TTFT on a single request while production has concurrency 8; quoting mean TTFT with a 3× p99 tail; assuming prefill throughput scales linearly with batch (chunked prefill caps it); and tuning chunk size on synthetic uniform-length traffic when real traffic is 90% short and 10% long — that mix needs a shortest-prefill-first queue, otherwise the long requests own the p99.
What are people seeing for 32k TTFT on a single H100 with chunked prefill enabled — is 1.2–1.4 s in line with your numbers, or is someone getting meaningfully below 1 s on open-weight models?