Summary

No hosted endpoint serves Gemma 4 31B fast enough for us, so we serve it ourselves on NVIDIA B200 GPUs with NVFP4 weights and an FP8 KV cache. In production, a reply takes about 300 ms at the median, and in our load tests one GPU holds 130 concurrent sessions with a median under 600 ms. We reached 130 sessions per GPU in steps: more cache for the full-attention layers, one prefill per turn instead of two, full CUDA graphs, a second cache tier in CPU memory, longer speculative drafts extended by prompt lookup, and larger cache pages.

In a cascaded stack, keeping time to first audio (TTFA) under 1 second requires keeping each component under a tight budget. We want our LLM to return a first sentence within 350 ms median and a full response in 600 ms median.

After we chose Gemma 4 on its capabilities, we needed to serve it within that time budget. Since no provider has an option that meets our requirements, we decided to try and do it ourselves. After a month of experiments, we managed to reach our target while maintaining a high GPU utilization by leveraging what we know about our usage patterns and optimizing around it. In production, a full reply now takes about 300 ms at the median, half our budget.

p50p90hovered session

Production Gemma requests between 17:00 and 19:00, November 13 to 18, one point per request. Lines are the rolling median and p90 over 15 minutes. Background prefills are not shown.

Workload

A game session is a sequence of agent and player turns. Most agent turns include one or several calls to our main LLM. The prompt holds the system prompt, contextual instructions and session history, so it can grow quite long. In production, the median request has about 22,000 input tokens. Most of it repeats from one turn to the next. You can see it in the graph above: select Cache hit rate as a metric, and observe how most calls within a session are above 95% hit rate, with occasional drops to 50-80%. These drops indicate changes in the instruction context, typically when navigating from one scene to the other. Now select Input tokens: within a session, the prompt grows roughly linearly, by about 750 tokens per minute of play. Most requests fall between 15,000 and 31,000 tokens, and the longest reach about 51,000. About 8,000 of those are the episode’s shared prefix, identical for every child playing it.

Replies are short: about 65 output tokens at the median, typically between 20 and 160, and rarely more than 300. We disable reasoning to keep them that way.

This shape has three consequences.

  • The fixed cost per call matters more than tokens per second: prefill of the uncached suffix usually takes under 10 ms, decoding a 65-token reply about 100 ms. Everything else is an almost constant overhead.
  • Under load, cache is the bottleneck: cache eviction is costly, since recomputing a 20k-token prefix takes over a second. Sometimes it’s hidden behind audio playback, but most of the time it means a sharp increase in our p95 TTFA.
  • Capacity is limited by latency, not throughput: as we add sessions, the GPU still has throughput to spare, but calls that arrive together slow each other down, and the median crosses our target first.
Lab notesRule of thumb: latency of one call

A linear fit over 30,000 production replies from November 13 to 18 gives (R² 0.62):

latency≈188ms+1.50ms×output tokens+0.031ms×uncached input tokens\textrm{latency} ≈ 188 \textrm{ms} + 1.50 \textrm{ms} × \textrm{output tokens} + 0.031 \textrm{ms} × \textrm{uncached input tokens}

The fixed part covers the network, tokenization and launching the prefill. On SGLang in September, the same fit gave 228 ms, 2.85 ms and 0.052 ms: the changes below almost halved the cost of each output token.

The network matters as much as the GPU here. About a fifth of a median reply, roughly 60 ms, is spent between our agent and the inference engine: the network both ways and the HTTP handling on each side. Until mid-November, it was about 110 ms, a third of the reply. Two changes saved about 50 ms per request: HTTP/2 over long-lived keep-alive connections, and no TCP slow start after idle (net.ipv4.tcp_slow_start_after_idle=0). Between two turns of a game, a connection sits idle long enough for the kernel to shrink its sending window back to the start, so each reply paid extra round trips just to send a prompt of tens of kilobytes.

Where a median production reply's time goes A median production reply, about 300 ms 60 Network and HTTP, both ways 95 Engine: prefill and other steps 140 Engine: decoding about 65 tokens between agent and engine, about 60 ms in vLLM's engine, about 235 ms ms, medians over 7,505 production replies, November 18–19, 2026
Where a median production reply's time goes, November 18 and 19. Each part is a median, so they add up only roughly.

Traffic is strongly diurnal: outside holidays, children play in the morning, in the evening, on Wednesdays and weekends. And, since we only sell in France for now, almost all of our users are in the same timezone. Over a week, the average load is 30% of the busiest hour, and close to zero between 22:00 and 7:00. The steepest rise is about 40% of the weekly peak within an hour, on free-day mornings. A replica takes 2 to 5 minutes to start, so we add GPUs before the ones we have fill up.

Concurrent sessions by hour of day, as a share of the busiest hour 0% 25% 50% 75% 100% 0:00 3:00 6:00 9:00 12:00 15:00 18:00 21:00 24:00 hour of day, Paris time Mon, Tue, Thu, Fri Wed, Sat, Sun
Concurrent sessions by hour of day, as a share of the busiest hour of the week, over one month of production sessions.

Benchmark

Most of the measurements below come from our load-testing bench, which replays recorded sessions with the exact same timing as in production. Our replay corpus is 120 recorded sessions from ten episodes (this matters because different episodes have different cache prefixes). Each simulated player sends the recorded request at the recorded pace, including prefill requests our prod agent sends while audio is playing, so our measured load uses the same cache pattern as in production. When a simulated session ends, we start another one to maintain the same volume of sessions per unit of time. Each request has a 30 s timeout (instead of 2 s in production), so that we can measure exact latency when a replica is overloaded.

20 of 100 simulated players over two minutes, and requests in flight Agent speaking Child speaking Call Prefill new session P1 P1, call: 767 ms P1, prefill: 260 ms P1, call: 1,028 ms P1, call: 1,285 ms P1, prefill: 260 ms P2 P2, call: 679 ms P2, prefill: 410 ms P2, call: 295 ms P2, prefill: 580 ms P2, call: 573 ms P2, prefill: 250 ms P3 P3, prefill: 510 ms P3, call: 777 ms P3, prefill: 230 ms P4 P4, call: 563 ms P4, call: 1,664 ms P4, prefill: 430 ms P5 P5, call: 920 ms P5, prefill: 410 ms P5, call: 628 ms P5, prefill: 440 ms P5, call: 528 ms P5, prefill: 230 ms P5, call: 372 ms P5, prefill: 740 ms P6 P6, call: 877 ms P6, prefill: 1,270 ms P6, call: 709 ms P6, prefill: 440 ms P6, call: 583 ms P6, prefill: 490 ms P7 P7, call: 481 ms P7, prefill: 280 ms P7, call: 336 ms P7, prefill: 260 ms P7, call: 216 ms P7, prefill: 390 ms P7, call: 296 ms P7, prefill: 230 ms P7, call: 895 ms P7, prefill: 470 ms P8 P8, call: 1,534 ms P8, prefill: 320 ms P8, call: 388 ms P8, prefill: 490 ms P8, call: 211 ms P8, prefill: 230 ms P8, call: 486 ms P9 P9, call: 1,269 ms P9, prefill: 370 ms P9, call: 174 ms P9, prefill: 560 ms P9, call: 696 ms P9, prefill: 470 ms P10 P10, prefill: 590 ms P10, call: 828 ms P10, prefill: 750 ms P10, call: 600 ms P10, prefill: 670 ms P11 P11, call: 1,018 ms P11, call: 1,255 ms P11, prefill: 330 ms P11, call: 228 ms P11, prefill: 210 ms P12 P12, prefill: 790 ms P12, call: 371 ms P12, prefill: 230 ms P12, call: 1,360 ms P12, prefill: 510 ms P13 P13, call: 429 ms P13, prefill: 590 ms P13, call: 169 ms P13, call: 1,128 ms P14 P14, call: 234 ms P14, call: 943 ms P14, prefill: 320 ms P14, call: 379 ms P15 P15, call: 421 ms P15, prefill: 680 ms P15, call: 190 ms P15, call: 724 ms P15, prefill: 270 ms P16 P16, call: 250 ms P16, prefill: 230 ms P16, call: 245 ms P16, prefill: 350 ms P16, call: 782 ms P16, prefill: 410 ms P17 P17, call: 486 ms P17, prefill: 510 ms P17, call: 344 ms P17, prefill: 500 ms P18 P18, call: 604 ms P18, prefill: 230 ms P18, call: 1,257 ms P18, prefill: 630 ms P19 P19, call: 933 ms P19, prefill: 300 ms P19, call: 722 ms P19, prefill: 250 ms P19, call: 410 ms P20 P20, call: 427 ms P20, prefill: 370 ms P20, call: 326 ms P20, prefill: 210 ms P20, call: 1,090 ms P20, prefill: 270 ms P20, call: 230 ms P20, prefill: 440 ms requests in flight, all 100 players (average 2.36 calls and 1.19 prefills) 0 10 blue: calls · orange: calls + prefills 0 s 20 s 40 s 60 s 80 s 100 s 120 s
Two minutes of a 100-session replay on one B200. Each row is one simulated player: the agent's audio and the child's speech are replayed as pauses, calls go out at their recorded times, and a prefill follows each reply. Bottom: requests in flight across all 100 players.

A configuration holds a number of sessions when its median end-to-end latency stays within 600 ms (we allow 10% of noise), fewer than 5% of calls take over 2 s, and no call errors or session fails. We report the highest number that holds.

We’re mainly interested in three latency metrics.

  • TTFT, time to first token: request sent to the first content token.
  • TTFS, time to first sentence: request sent to the first segment we can send to TTS (we typically end on end of sentence punctuation, scene transitions, audio tags, listening windows).
  • E2E, end to end: request sent to the complete reply.

We also report output tokens per second per GPU, the cache hit rate, and the share of calls over 2 s (those calls would have timed out in production).

Key drivers

We first served Gemma 4 on two B200s (TP=2). Five days later we moved to a single GPU (TP=1) with 4-bit weights. Since then, in our replay, one GPU went from about 33 to about 90 concurrent sessions under our 600 ms median objective by early October, and to 130 by November. The first gains came from giving more cache memory to full-attention tokens, switching from SGLang to vLLM, and dropping one of our two prefill requests. The next ones came from full CUDA graphs, a second cache tier in CPU memory, and longer drafts. In November, larger cache pages and a cheaper drafter step took it to 130. We run our own fork of vLLM, now built on v0.33.0, to get some of them (see Inference engine).

Concurrent sessions one B200 holds under the objective, after each change concurrent sessions per B200 under the objective 0 25 50 75 100 125 150 v1, SGLang, default flags: 33 sessions 33 v1 SGLang, default flags v2, SGLang, cache split tuned: 45 sessions 45 v2 SGLang, cache split tuned v3, vLLM, one prefill per turn: 60 sessions 60 v3 vLLM, one prefill per turn v4, Full CUDA graphs, CPU cache tier: 90 sessions 90 v4 Full CUDA graphs, CPU cache tier v5, 9 draft tokens + prompt lookup: 90 sessions 100 sessions held the median but not the tail over an hour limit 90–100 v5 9 draft tokens + prompt lookup v6, 32-token pages, drafter head: 130 sessions 130 v6 32-token pages, drafter head
Concurrent sessions one B200 holds under the objective in our replay, after each change. The light part of the v5 bar is the limit: 100 sessions kept the median within the objective but not the 2 s tail over an hour. The v6 runs replay a newer corpus whose prompts are as long as production's: 130 sessions held in two runs, at 520 and 588 ms medians with about 3% of calls over 2 s. Above 130, results got worse: the median reached 632 ms at 135 sessions and 745 ms at 140, and at 150 the replica lost sessions to timeouts.
Median latency and share of slow calls against concurrent sessions per GPU, by configuration SGLang v0.5.19, default flags (B200) about 33 sessions SGLang v0.5.19, tuned cache split (B200) about 45 sessions vLLM v0.30.0, default flags (B200) about 60 sessions vLLM v0.30.0-mallow.1 (B200) about 90 sessions, 100 at the limit vLLM v0.30.0-mallow.1 (H200) about 20 sessions vLLM v0.33.0-mallow.2 (B200) about 130 sessions vLLM v0.33.0-mallow.2 (H200) about 35 sessions median end-to-end latency (ms) 200 300 400 500 600 700 800 900 1,000 600 ms objective 20 30 40 50 60 70 80 90 100 110 120 130 140 150 SGLang v0.5.19, default flags (B200), 30 sessions, screening run: 504 ms SGLang v0.5.19, default flags (B200), 35 sessions, confirmation run: 602 ms SGLang v0.5.19, default flags (B200), 35 sessions, confirmation run: 611 ms SGLang v0.5.19, default flags (B200), 40 sessions, screening run: 666 ms SGLang v0.5.19, default flags (B200), 50 sessions, screening run: 1,228 ms ▲ 1,228 SGLang v0.5.19, tuned cache split (B200), 40 sessions, confirmation run: 568 ms SGLang v0.5.19, tuned cache split (B200), 45 sessions, confirmation run: 598 ms SGLang v0.5.19, tuned cache split (B200), 45 sessions, confirmation run: 560 ms SGLang v0.5.19, tuned cache split (B200), 50 sessions, confirmation run: 670 ms vLLM v0.30.0, default flags (B200), 55 sessions, confirmation run: 521 ms vLLM v0.30.0, default flags (B200), 60 sessions, confirmation run: 566 ms vLLM v0.30.0, default flags (B200), 60 sessions, confirmation run: 592 ms vLLM v0.30.0, default flags (B200), 65 sessions, confirmation run: 598 ms vLLM v0.30.0-mallow.1 (B200), 90 sessions, screening run: 510 ms vLLM v0.30.0-mallow.1 (B200), 100 sessions, screening run: 583 ms vLLM v0.30.0-mallow.1 (B200), 100 sessions, hour run: 626 ms vLLM v0.30.0-mallow.1 (B200), 110 sessions, confirmation run: 670 ms vLLM v0.30.0-mallow.1 (B200), 120 sessions, confirmation run: 822 ms vLLM v0.30.0-mallow.1 (B200), 130 sessions, confirmation run: 948 ms vLLM v0.30.0-mallow.1 (H200), 15 sessions, confirmation run: 536 ms vLLM v0.30.0-mallow.1 (H200), 20 sessions, confirmation run: 521 ms vLLM v0.30.0-mallow.1 (H200), 30 sessions, confirmation run: 631 ms vLLM v0.33.0-mallow.2 (B200), 15 sessions, confirmation run: 272 ms vLLM v0.33.0-mallow.2 (B200), 100 sessions, confirmation run: 349 ms vLLM v0.33.0-mallow.2 (B200), 120 sessions, confirmation run: 442 ms vLLM v0.33.0-mallow.2 (B200), 130 sessions, confirmation run: 520 ms vLLM v0.33.0-mallow.2 (B200), 130 sessions, confirmation run: 588 ms vLLM v0.33.0-mallow.2 (B200), 135 sessions, confirmation run: 632 ms vLLM v0.33.0-mallow.2 (B200), 140 sessions, confirmation run: 745 ms vLLM v0.33.0-mallow.2 (H200), 20 sessions, confirmation run: 408 ms vLLM v0.33.0-mallow.2 (H200), 30 sessions, confirmation run: 429 ms vLLM v0.33.0-mallow.2 (H200), 35 sessions, confirmation run: 463 ms vLLM v0.33.0-mallow.2 (H200), 40 sessions, confirmation run: 520 ms share of calls over 2 s 0% 5% 10% 15% 20% 25% 5% limit 20 30 40 50 60 70 80 90 100 110 120 130 140 150 SGLang v0.5.19, default flags (B200), 35 sessions, confirmation run: 3.6% SGLang v0.5.19, default flags (B200), 35 sessions, confirmation run: 4.0% SGLang v0.5.19, tuned cache split (B200), 40 sessions, confirmation run: 1.0% SGLang v0.5.19, tuned cache split (B200), 45 sessions, confirmation run: 3.1% SGLang v0.5.19, tuned cache split (B200), 45 sessions, confirmation run: 2.0% SGLang v0.5.19, tuned cache split (B200), 50 sessions, confirmation run: 8.0% vLLM v0.30.0, default flags (B200), 55 sessions, confirmation run: 1.4% vLLM v0.30.0, default flags (B200), 60 sessions, confirmation run: 3.0% vLLM v0.30.0, default flags (B200), 60 sessions, confirmation run: 3.0% vLLM v0.30.0, default flags (B200), 65 sessions, confirmation run: 4.0% vLLM v0.30.0-mallow.1 (B200), 90 sessions, screening run: 3.0% vLLM v0.30.0-mallow.1 (B200), 100 sessions, screening run: 3.4% vLLM v0.30.0-mallow.1 (B200), 100 sessions, hour run: 5.4% vLLM v0.30.0-mallow.1 (B200), 110 sessions, confirmation run: 7.5% vLLM v0.30.0-mallow.1 (B200), 120 sessions, confirmation run: 14.5% vLLM v0.30.0-mallow.1 (B200), 130 sessions, confirmation run: 19.2% vLLM v0.30.0-mallow.1 (H200), 15 sessions, confirmation run: 2.1% vLLM v0.30.0-mallow.1 (H200), 20 sessions, confirmation run: 5.0% vLLM v0.30.0-mallow.1 (H200), 30 sessions, confirmation run: 11.5% vLLM v0.33.0-mallow.2 (B200), 15 sessions, confirmation run: 0.0% vLLM v0.33.0-mallow.2 (B200), 100 sessions, confirmation run: 0.2% vLLM v0.33.0-mallow.2 (B200), 120 sessions, confirmation run: 0.9% vLLM v0.33.0-mallow.2 (B200), 130 sessions, confirmation run: 3.4% vLLM v0.33.0-mallow.2 (B200), 130 sessions, confirmation run: 2.6% vLLM v0.33.0-mallow.2 (B200), 135 sessions, confirmation run: 3.7% vLLM v0.33.0-mallow.2 (B200), 140 sessions, confirmation run: 5.2% vLLM v0.33.0-mallow.2 (H200), 20 sessions, confirmation run: 0.7% vLLM v0.33.0-mallow.2 (H200), 30 sessions, confirmation run: 3.2% vLLM v0.33.0-mallow.2 (H200), 35 sessions, confirmation run: 4.5% vLLM v0.33.0-mallow.2 (H200), 40 sessions, confirmation run: 6.2% concurrent sessions per GPU 10-minute run 10-minute run 5-minute run 5-minute run 1-hour run 1-hour run
Median end-to-end latency (top) and share of calls over 2 s (bottom) in our replay, against concurrent sessions per GPU. Each mark is one run. A configuration holds a session count while both stay under their lines. The 1-hour run used a later rebuild of the corpus with slightly longer prompts, and the H200 runs another rebuild. The v0.33.0-mallow.2 runs replay a newer corpus whose prompts are as long as production's.

Speculative decoding

We use speculative decoding1 with the drafter Google ships with Gemma 4, a small multi-token prediction (MTP) model that reads the main model’s own cache. We started with three draft tokens per step: the model kept about three tokens per step instead of one, which increased decoding speed by 1.4× at 16 concurrent requests (1.6× for a single request), for 8 ms more TTFT.

Longer drafts are a trade-off. Each extra draft token costs one more pass of the drafter, about 0.43 ms on a B200, and each extra token to verify makes the main model’s step about 0.13 ms longer. On our replies, the drafter’s guesses stay good deep into the draft, so drafting more pays up to 7 to 9 tokens: at 90 sessions, the median drops from 674 ms with three draft tokens to 545 ms with nine.

Tokens kept per step, step time and median latency against draft tokens per step Tokens kept per step 3 3.5 4 4.5 5 5.5 3 5 7 9 11 13 15 3 draft tokens: 3.12 4 draft tokens: 3.57 5 draft tokens: 3.93 7 draft tokens: 4.43 9 draft tokens: 4.72 11 draft tokens: 4.91 15 draft tokens: 5.09 9 draft tokens + prompt lookup to 15: 5.13 Step time (ms) 14 16 18 20 22 3 5 7 9 11 13 15 3 draft tokens: 15 4 draft tokens: 15.2 5 draft tokens: 15.5 7 draft tokens: 16.8 9 draft tokens: 17.6 11 draft tokens: 18.8 15 draft tokens: 21 9 draft tokens + prompt lookup to 15: 18.4 Median latency (ms) best 500 550 600 650 700 3 5 7 9 11 13 15 3 draft tokens: 674 4 draft tokens: 598 5 draft tokens: 569 7 draft tokens: 553 9 draft tokens: 545 11 draft tokens: 561 15 draft tokens: 590 9 draft tokens + prompt lookup to 15: 538 tokens drafted per step Gemma's drafter alone 9 drafted, prompt lookup fills slots 10 to 15
Draft length on one B200 at 90 sessions, replaying sessions from three episodes no drafter was tuned on. Their replies are longer than in our usual corpus, so latencies run higher than elsewhere in this post. The diamond is nine draft tokens, extended to 15 by prompt lookup.

Piecewise and full CUDA graphs

A CUDA graph records the GPU kernels of a forward pass once, then replays them with a single launch, which saves the CPU from launching each kernel. vLLM captures graphs in two modes. A full graph covers the whole step, attention included. A piecewise graph covers what sits between attention layers, and attention runs outside the graph, launched from Python for each of Gemma’s 60 layers.

vLLM treats Gemma 4 as a model whose image tokens attend to each other in both directions. For that mask, it picks an attention backend that can’t run inside a graph, so decoding falls back to piecewise graphs, even for requests without any image. Turning off image and audio inputs, as the published recipe does, isn’t enough: video inputs have to go too. --language-model-only turns off all three. You can’t keep FlashInfer in that mode either: with --attention-backend FLASHINFER and without --language-model-only, vLLM refuses to start.

This is easy to miss. The server starts and replies are correct. The startup log does say it, in one warning among a few hundred lines: CUDAGraphMode.FULL_AND_PIECEWISE is not supported with TritonFlashInferBackend backend (support: AttentionCGSupport.NEVER); setting cudagraph_mode=PIECEWISE. Otherwise, the server is just slower. At 70 sessions, full graphs cut the engine’s time per request from 384 to 324 ms, and sped up decoding from 283 to 346 tokens per second per user.

Prompt lookup

Our replies copy a lot from their prompt: character names, instructions, and the tags the prompt spells out. Most reply tokens sit in a span of 8 or more tokens that also appears in the call’s prompt.

Share of reply tokens copied from the prompt, found only in other sessions, or neither 63% of reply tokens: in a span of 8+ tokens from the call's own prompt 63% in a span of 8+ tokens from the call's own prompt 17% of reply tokens: only in other children's replies 17% only in other children's replies 20% of reply tokens: neither 20% neither
Where reply tokens come from, in held-out sessions. Another 17% appear in other children's replies to the same episode, but we keep sessions apart, so no draft uses them.

Prompt lookup drafts by finding the last few tokens elsewhere in the conversation and proposing what followed them. Used instead of Gemma’s drafter, it lost (589 against 545 ms): the drafter already reads the prompt through the cache, so it copies well where lookup fires. Used after it, lookup helps: the drafter proposes nine tokens, then lookup fills slots 10 to 15 when the draft’s last tokens match the conversation. The model keeps 5.1 tokens per step instead of 4.7, decoding is 7% faster, and the median drops from 545 to 538 ms. Fifteen is the limit: FlashInfer’s decode kernel verifies at most 16 tokens at a time for Gemma’s 512-dimension heads. This extension is our own contribution, living in our vLLM fork.

What didn’t help:

  • other drafters: DFlash decodes 25 to 30% faster but delays the first token and uses memory we need for the prefix cache. RedHat’s public DSpark drafter accepted 17% of drafted tokens in an offline test. We did some preliminary work on training a DSpark drafter on our own sessions, without conclusive results yet.
  • draft trees: proposing a few alternative continuations per step would keep slightly more tokens in an offline replay (5.15 against 4.96 per step), but vLLM removed tree attention. And it seems like too much complexity for little gain.
  • sampled drafts instead of the drafter’s most likely tokens: no gain.
Lab notesDrafters we tried
DrafterResult
Gemma’s drafter, 3 tokens3.4 tokens kept per step at 10 sessions; decoding 1.4× faster at 16 requests
Gemma’s drafter, 9 tokens + prompt lookup to 155.1 tokens kept per step at 90 sessions; production
DFlash, blocks of 8 and 16 tokens4.6 tokens per step and faster decoding, but first sentence 406 against 351 ms at 25 sessions, and 30% of calls over 2 s at 40 sessions
RedHat’s DSpark17% of drafted tokens accepted, offline
DSpark trained on our sessionsPreliminary work, no gain yet

A cheaper drafter step

Each draft token reads the drafter’s own output layer, a 262,144 × 1,024 matrix. In November, we stored it in 4-bit, like the main model’s feed-forward layers. The main model still checks every token with its own 16-bit output layer, so replies don’t change. We also start each draft from the request’s last accepted token, without a prefill pass of the drafter first, as proposed in vLLM PR #60689. Together, at 100 sessions, they took the median from 449 to 388 ms.

Quantization

4-bit weights and an 8-bit KV cache2 more than double the cache one B200 can hold, with an acceptable quality loss on our benchmarks.

KV cache size in tokens on one B200, by weight and cache precision and by engine 0k 250k 500k 750k 1M tokens of KV cache 16-bit weights, 16-bit cache, SGLang 16-bit weights, 16-bit cache, SGLang: 126,016 tokens 126k 8-bit weights, 16-bit cache, SGLang 8-bit weights, 16-bit cache, SGLang: 164,032 tokens 164k 4-bit weights, 16-bit cache, SGLang 4-bit weights, 16-bit cache, SGLang: 164,672 tokens 165k 4-bit weights, 8-bit cache, SGLang 4-bit weights, 8-bit cache, SGLang: 329,280 tokens 329k 4-bit weights, 8-bit cache, vLLM 4-bit weights, 8-bit cache, vLLM: 961,069 tokens 961k
Tokens of KV cache on one B200. The SGLang rows show its full-attention cache at the default split between the two attention caches. vLLM gives the sliding-window layers only what each request needs and the rest to full attention, which explains most of its larger number (see the cache section below).
Lab notesLatency and quality by precision
One call at a time14 sessions10 requests/s
4-bit weights, 8-bit cache393 / 483486 / 1,451546 / 655
4-bit weights, 16-bit cache406 / 559565 / 2,1531,333 / 2,644
16-bit weights, 16-bit cache479 / 617698 / 7,556760 / 1,006
Median / p95 in ms, SGLang on one B200, replayed sessions with 80-token replies.

The larger cache matters most under load: at 14 sessions, the share of the prompt served from cache rises from 85% to 95%. On quality, the 4-bit model passed 68.1% of Archie Bench cases, against 70.7% for the 16-bit model served by a hosted provider. The 95% interval on that difference runs from −3.3 to +6.7 points, and the same 16-bit model measured twice differed by 1.5 points.

BF16NVFP4 + FP8 KV
Archie Bench (pass rate)70.7%68.1%
Archie Bench (exemplary rate)58.9%57.4%
French lexical integrity (pass rate)99.5%99.0%
Pass = adequate + exemplary.

NVIDIA’s 4-bit checkpoint keeps the attention projections in 16-bit, and decoding reads every weight at each step. Since late October, we serve our own variant of it on Hugging Face, with those projections in FP8 and every other tensor unchanged. It weighs 22.5 GiB instead of 30.4, leaves room for about 46,000 more tokens of cache, and took the median at 90 sessions from 513 to 454 ms, with the same scores on our benchmarks.

Increasing cache hit rate

A typical prompt holds about 27,000 tokens, and about 97% of it was already processed on the previous turn. As long as the KV cache has headroom, each call only processes the player’s last utterance, then decodes 30 to 120 tokens; the decoding part takes roughly 100 to 350 ms. Our latency objective thus breaks when we miss KV cache.

This section explores various ways to increase cache hit rate.

Prefilling

Our agent knows how the next prompt starts before the child speaks: the history, its own reply, and the instructions for what comes next. So right after each reply, while the audio plays, it sends that prompt to the server with no output requested. By the time the child answers, the real call only has to process the transcript. Since we rent the GPU by the hour, this costs no money, although it uses capacity: a prefill can delay a real call. Our fork now schedules real calls ahead of prefills, which ask for zero output tokens and skip drafting. The same idea works at the start of a session: preparing the episode’s opening prompt before the first call cut the first answer from 868 to 322 ms.

The agent also sent a second prefill when the child stopped speaking, before the transcript arrived. That hook dates back to when we used a hosted provider, where it opened the connection early to save a handshake. With our own server, it mostly re-sent a prompt the first prefill had already cached, and it reached the GPU at the worst moment, a fraction of a second before the real call; a quarter of them were cancelled by the real call. Dropping it costs each call about 200 extra tokens (about 10 ms) and, on vLLM at 55 sessions, more than halved the share of slow calls. On SGLang it made no difference.

Prefills sent (vLLM, 55 sessions)MedianOver 2 sGPU busy
Both567 ms3.9%65%
End of speech only585 ms5.2%58%
Post-reply only537 ms1.7%52%

Full-attention and sliding-window cache

Gemma 4 has two kinds of attention layers. Fifty of them only look at the last 1,024 tokens (sliding window attention), and ten look at the whole conversation (full attention) [1]. SGLang keeps one cache per kind and splits the memory with a single setting, --swa-full-tokens-ratio. With the default 0.8, 89% of the cache memory goes to the sliding-window layers. Above 35 sessions, the full-attention cache runs out and the hit rate goes down (at 40 sessions, 88% instead of 94%). At 0.4, a single B200 can reach 45 sessions while maintaining its cache hit rate. At 0.2, the sliding-window cache runs out first.

KV cache memory split and median latency at 40 sessions, by sliding-window ratio KV cache memory (GiB) full attention sliding window Median latency at 40 sessions (ms) 0 40 80 120 450 500 550 600 650 700 objective ratio 0.2 full attention: 910,848 tokens, 35 GiB sliding window: 182,144 tokens, 69 GiB 911k full 182k window ratio 0.2: 618 ms at 40 sessions 618 ms capacity 38 ratio 0.4 pool sizes not recorded ratio 0.4: 533 ms at 40 sessions 533 ms capacity 47 ratio 0.5 full attention: 483,904 tokens, 18 GiB sliding window: 241,920 tokens, 92 GiB 484k full 242k window ratio 0.5: 564 ms at 40 sessions 564 ms capacity 43 ratio 0.65 pool sizes not recorded ratio 0.65: 611 ms at 40 sessions 611 ms ratio 0.8 default full attention: 329,280 tokens, 13 GiB sliding window: 263,424 tokens, 100 GiB 329k full 263k window ratio 0.8: 666 ms at 40 sessions 666 ms capacity 36
Median latency at different FA versus SWA cache split, SGLang at 40 sessions.

vLLM sizes the two caches itself. For each request, it reserves sliding-window memory for one window plus the tokens being processed, and gives the rest to full attention. Given 95% of the GPU’s memory, it counts room for about 961,000 tokens (15 conversations at the 64k-token limit) without any tuning, about three times SGLang’s full-attention cache at its default split. Quite convenient!

A cache tier in CPU memory

Even with about a million tokens of cache on the GPU, a busy replica evicts prefixes while children think. At 70 sessions, a call that came 30 to 60 s after the session’s previous one had lost about 2,400 of its cached tokens, and calls after longer pauses lost more. The machine around the GPU has far more memory than the GPU itself, and vLLM can keep a second tier of cache there: blocks evicted from the GPU stay in CPU memory, and a later call loads them back instead of recomputing them.

Out of the box, that tier served nothing. In its default (eager) mode, vLLM copies every block to the CPU as it’s written. Our initial CPU tier was smaller than the GPU cache, so blocks left the CPU tier before the GPU evicted them. Lazy mode, which copies blocks only when they’re about to leave the GPU, fits our case better, but it served no hits either.

The cause was the order of vLLM’s free queue, the list of cached blocks that no running request uses, from evicted first to most recently used. In lazy mode, vLLM copied the blocks at the eviction end to the CPU, then put them back at the other end, as if they had just been used. The GPU then evicted other blocks instead, ones the CPU didn’t hold, and the copier moved on to copy those. We fixed it in vLLM PR #59383, merged in November: copied blocks go back to the eviction end.

GPU free queue after a lazy CPU copy, in vLLM v0.30.0 and with PR 59383 cached on the GPU, copy also in the CPU tier cached on the GPU only vLLM v0.30.0 · copies go back to the most-recently-used end GPU free queue evicted first most recently used next eviction The blocks evicted next were never copied, so the scan copies again. The 40 GiB CPU tier was rewritten every 7 s and served no hits: 880 ms median at 75 sessions. With PR #59383 · copies stay at the eviction end GPU free queue evicted first most recently used next eviction The blocks evicted next already have a copy in the CPU tier. A later call that needs them reloads them from CPU memory: 548 ms median at 75 sessions.
The GPU free queue after a lazy copy to the CPU tier, simplified to 14 blocks. Measured with a 40 GiB CPU tier at 75 sessions.

Two more pieces come from other people’s work, which we backported to our fork: joint GPU and CPU prefix lookup (#57325), without which 68% of CPU lookups stopped at a block that was still on the GPU, and Prometheus metrics for the CPU tier (#57251).

At 90 sessions, we use a 180 GiB tier. It holds about 1.3 million tokens and adds about 15% of the replica’s price. Doubling it gained little for 18% more. The misses that remain, about 425 tokens per call, come from prompts that differ from their prefill, not from eviction.

Lab notesCPU tier size at 90 sessions
CPU tierMedianOver 2 sServed from the GPU cache
40 GiB725 ms9.5%82%
180 GiB606 ms2.5%86%

One B200, our vLLM fork before the longer drafts (three draft tokens), one run each (the 40 GiB run had a 5-minute window, the 180 GiB run a 10-minute one). With the larger tier, the engine also recomputed 29% fewer prompt tokens per second.

Larger pages

vLLM stores the cache in fixed-size pages, and by default a cache hit drops its last page: an EAGLE drafter recomputes its own cache there, but Gemma’s drafter reads the main model’s cache and writes none. Keeping that page (disable_eagle_block_drop) cut the prompt tokens the GPU computes at 100 sessions by 10%.

Doubling the page size helped more: with 32-token pages (64 on the full-attention layers), a session that comes back after a pause more often finds its whole private prefix in the CPU tier. At 120 sessions, the median went from 610 to 442 ms, and calls over 2 s from 3% to 1%. Larger full-attention pages would need a FlashInfer prefill kernel that doesn’t exist yet for Gemma’s 512-dimension heads with an FP8 cache.

Streaming

Our agent waits for the whole reply before sending it to text-to-speech. A reply is about 65 tokens at the median, but the first sentence ends after about 20. In our September replay, streaming the model output and sending to TTS as soon as a complete sentence is received would have saved 100–200 ms, at the expense of a TTS seam. Decoding has since become about twice as fast: on November’s production replies, we estimate the saving at about 50 ms at the median and 180 ms for the slowest 10%. This change hasn’t reached production yet.

Inference engine

We started with SGLang [2] because vLLM was slow out of the box with an 8-bit cache and speculative decoding, and we didn’t investigate further at that point. When we took the time to configure it properly [3] (see below), vLLM beat SGLang at every load we tried. At the same number of sessions, its first token arrives about 80 ms sooner and its median is about 130 ms lower. At this point, we have no clear explanation for this: it isn’t decoding waiting behind prefills because SGLang mixed batching didn’t help.

On 150 production prompts, a blind judge found no quality difference between the two engines.

We now run our own fork of vLLM, built on v0.33.0, and publish each build with its patch list (latest release). It adds pull requests that v0.33.0 doesn’t include, some of them by other people, and a few changes that are only ours:

  • #59383, ours: lazy CPU offload returns copied blocks to the eviction end of the free queue. vLLM merged it in November, after v0.33.0.
  • #64229: the lazy offload counts bounded sliding-window allocations when it decides how many blocks to copy.
  • #57325: joint GPU and CPU prefix lookup.
  • #53273: one kernel launch fewer per layer, by fusing a residual add into the next norm.
  • #60689: drafts that start from the last accepted token (see A cheaper drafter step).
  • Ours, not proposed upstream: prompt lookup after the drafter’s tokens (see Prompt lookup), the drafter’s output layer in 4-bit, and prefills that ask for zero tokens, skip drafting and wait behind real calls.
Lab notesvLLM config
  • vLLM 0.33.0, our fork
  • NVIDIA’s 4-bit weights with FP8 attention projections
  • FlashInfer attention everywhere
  • full CUDA graphs in decode (--language-model-only)
  • GPU memory 0.95: about 1,010,000 tokens of FP8 cache
  • 32-token pages, 64 on the full-attention layers; disable_eagle_block_drop
  • 180 GiB CPU tier: SimpleCPUOffloadConnector in lazy mode
  • Gemma’s drafter with nine tokens and its output layer in NVFP4, prompt lookup up to 15
  • 8,192 batched tokens, 64 sequences, async scheduling, -O3
  • fastokens tokenizer on 4 threads
  • prefills send max_completion_tokens: 0

Long tail of minor gains

  • Tokenize on the client, send token ids: −50 ms on SGLang, no change on vLLM
  • Compile cache on a persisted volume reduces cold start 9 min → 2–5 min (not a latency gain per se, but makes auto-scaling much easier)
  • Basic networking helps, such as keep-alive connections (−80 ms on a subset of calls). One gotcha: cancelling a request over HTTP/1.1 closes its connection, so the next call pays a new handshake. In production, 12.6% of our calls paid a handshake, most of them right after a cancelled prefill.
  • Not done yet: optimizing prompt format to reduce the number of tokens, primarily on the critical path (i.e. everything that happens after a prefill and before a reply)
Lab notesExperiment log

Many things didn’t help, or not enough to keep. We list them briefly: most are one run, on one host, so “no gain” means “no gain we could see”.

TriedResult
Two B200s with tensor parallelismFixed the tail (p95 5.8 → 1.2 s at 14 sessions) at 1.9× the price; one GPU with 4-bit weights got close (1.45 s)
FP8 weights aloneSame quality, small latency gain
SGLang’s Triton attention (its only option for an FP8 cache at first)1.7 to 5× slower
4-bit KV cache (SGLang, vLLM), TurboQuantDoesn’t start for Gemma 4
Google’s quantization-aware 4-bit weights (W4A16)vLLM runs them through a slower kernel: prefill 3.5× slower, and most sessions time out while joining
DFlash drafterFaster decode, later first token, worse from 25 sessions
RedHat’s DSpark drafter17% acceptance; training our own is still preliminary
Longer drafts on SGLangCrash or garbled output from four draft tokens
SGLang flags: prefill CUDA graphs, 2k chunks, more memory, HiCache, 4 tokenizer workers, mixed batching, v0.5.20No gain
torch.compile on SGLangDoesn’t start
vLLM: 4k batch limit, two API serversWorse or no gain
LMCache as the CPU tierIts Gemma 4 recipe needs Triton attention with the drafter
KV split at 0.2A 3-minute run suggested twice the sessions; 5- and 10-minute runs gave 38, less than 0.4
Other GPUsH100 with our fork: 787 ms at 20 sessions. RTX PRO 6000: no speculative decoding kernel for Gemma’s head size, 1.6 s. B300: none available in the EU
Prompt reordering for cachingBroke prefix sharing across sessions
Warm spare connectionSaves 93 ms when a prefill is interrupted, about 2 ms on average
Nightly restartA fresh replica looked 50 ms faster; never confirmed with a matched comparison

Hopper GPUs

At most providers, Hopper GPUs are easier to get than B200s, and an H200 rents for less. Out of the box, though, Gemma 4 on an H200 was far from our target: about 1.8 s at three sessions on SGLang, and 2.4 s on vLLM.

Two fixes made it work better:

  • vLLM v0.30.0 sent Gemma 4’s 512-dimension attention layers with an 8-bit cache to a slow Triton kernel on Hopper. vLLM PR #53175 selects FlashAttention 4 for them instead.
  • FlashAttention 4’s Hopper kernel ignored how many parts it should split a long cache into, so one part read the whole cache alone: an attention call took 538 µs instead of 56 µs at 10,800 tokens of context. flash-attention#198 fixes it.

Both are part of vLLM since v0.33.0. On our v0.33.0 fork, one H200 holds 35 sessions: 463 ms at the median, with 4.5% of calls over 2 s. At 40 sessions, 6% of calls take over 2 s. It also absorbs fewer new sessions at once: with 20 players joining a minute, their first prompts queued until they timed out, so our H200 runs join at 10 a minute.

The limit is memory bandwidth, not memory size. Each decoding step reads about the same amount of weights, at 4.8 TB/s on an H200 against 8 TB/s on a B200. An idle H200 makes a token every 3.9 ms, about what a B200 does at 90 sessions (3.2 to 3.4 ms): the H200 starts where the B200 ends. Its cache isn’t the problem: at 40 sessions, it still served 95% of prompt tokens from cache, as much as a B200 at 130. Shorter drafts don’t help either: with five draft tokens instead of nine, each token took 6% longer.

In the end, at their public list prices, when accounting for price per hour and capacity, a B200 stays about 2.9 times less expensive per session than a H200.

Tooling

We used Modal to run those experiments and loved the developer experience: every replica above was a short-lived app with a TTL, billed by the second. Paired with strong coding agents, Modal makes running experiments extremely easy and fast.

Investing in a good load-testing benchmark pays off quickly. Most numbers above are very sensitive to precise traffic patterns, exact timing, prompt content, and many other parameters that can’t be simulated easily. Getting confidence in a config requires confidence in the test bench itself.

References

  1. Google DeepMind, Gemma 4 Technical Report, 2026.
  2. SGLang, Gemma 4 cookbook.
  3. vLLM, Gemma 4 Usage Guide.
  4. LiveKit, Latency optimized inference: Gemma 4 on LiveKit, July 2026.
  5. InferenceBench, Gemma 4 31B on H100: The Complete Inference Benchmark, April 2026.
  6. NVIDIA, Dynamo recipe: Gemma 4 31B.

Footnotes

  1. A small draft model proposes the next few tokens, and the large model checks all of them in one forward pass, keeping the ones it agrees with. The output follows the same distribution as without a drafter; decoding is faster when the guesses are right. ↩

  2. Quantization stores numbers with fewer bits: 16 (BF16), 8 (FP8) or 4 (NVFP4). Here it applies to the model weights and to the KV cache, the attention state the server keeps for tokens it has already processed. Smaller weights leave more GPU memory for the cache, and are faster to read at each step. ↩