Skip to content

[job] Qwen3.8-Flash-Next: fast multi-turn TTFT with prefix caching #69

Closed

Description

@AzeezIsh

Status (updated 2026-09-29 12:24Z)

State: the cache works. The "cache miss" suspicion was a misreading. Warm-turn TTFT here is dominated by prefilling new tokens.

  • What job 626's logs actually show: each warm turn restores the previous prompt's tail snapshot and skips it: turn 2 at 23.1k skips 18,496 tokens (16-token anchor gap), and turn 3 at 27.8k skips 23,216. It then replays only the new user turn: warmturn.py appends nwords/4 = 2,500 filler words (~4.65k tokens) per turn. "Intermediate hit" is the log's label for that prompt-boundary snapshot. "0 exact-leaf hits" is expected, because the next prompt is always longer than the leaf.
  • So the 3.7–4.0 s warm TTFT ≈ prefill of ~4.65k new tokens at 23–28k depth (≈1.2k tok/s). That's prefill speed at depth ([job] Qwen3.8-Flash-Next: long-context cold prefill to SGLang parity (stage 1 = #68) #74), not caching.
  • Chat template: the HF template is prefix-stable with thinking off. With thinking on, the re-rendered assistant turn drops the reasoning, so the saved leaf diverges from the next prompt at the completion's start. The tail snapshot is still at the prompt boundary, so the restore point doesn't change.
  • In flight: reiner 645. It runs the same 10k-word conversation with a 250-word vs 2,500-word follow-up, so restore cost and new-token prefill show up separately; tail split on vs off (ATLAS_NO_TAIL_SPLIT=1); and ssm-state-poisoning-gate with prefix caching on (the done bar's correctness gate).
  • Next: if the small follow-up is ≤ 3 s at 27k, the done bar is met on a comparable workload, and this closes. The SGLang comparison (27k re-served in 2.5 s) needs the same per-turn delta to be fair.

Kind

Feature for a model we already support

Model

nvidia/Qwen3.8-Flash-Next-NVFP4

What's the job?

Make multi-turn agent TTFT fast with prefix caching: SGLang re-serves 27k tokens in 2.5 s vs 12 s cold. Atlas has the radix tree + SSM snapshot LRU, but on qwen4_exp the warm SSM hit fires once per prefix, and the tail-split trade (ATLAS_NO_TAIL_SPLIT: −21-29 % cold, +46 % on turn 2) is unsettled. Done = a warmturn.py measurement (turns 1-5 at 8k/27k) showing warm TTFT ≤ 3 s at 27k, ssm-state-poisoning-gate green with prefix caching ON.

Impact radius

Shared code, other models could change

What else could it touch?

spark-runtime/src/radix_tree/snapshot*.rs, the QSA/PLE aux-state snapshot path, the scheduler's prefix restore.

Who's waiting or willing to test?

@AzeezIsh (GB10)

Activity

  1. added
    job
    on Sep 25, 2026
  2. changed the title [-][job] Qwen3.8-Flash-Next: long-context cold prefill to SGLang parity (stage 1 = #68)[/-] [+][job] Qwen3.8-Flash-Next: fast multi-turn TTFT with prefix caching[/+] on Sep 25, 2026
  3. AzeezIsh commented on Sep 26, 2026

    @AzeezIsh
    ContributorAuthor

    First measurement on current code (reiner job 279).

    Setup:

    words turn prompt tokens TTFT median
    4000 1 (cold) 7430-7443 4.76 s
    4000 2 (warm) 9277-9324 1.79 s
    4000 3 (warm) 11145-11218 1.67 s
    • Every warm turn restored an SSM snapshot. The log shows Marconi intermediate hit 9 times, 0 no SSM snapshot, 0 exact-leaf bypasses, and 15 saves.
    • So on this multi-turn shape the warm path works: turn 2 pays only the new suffix plus the SSM replay from the previous turn's tail checkpoint.
    • The earlier "only one hit" observation was identical repeated prompts. Those are exact full-prompt hits, which prefill_b/prefix_lookup.rs deliberately recomputes by default (ATLAS_MARCONI_EXACT=1 re-enables the shortcut). That is a different path from a real multi-turn conversation.

    Not yet measured: the issue's 27k target. My 13000-word arm overflowed max_seq_len 32768 on turn 3 (36k tokens, HTTP 400), so it produced no data. The rerun needs about 10000 words so that turn 3 lands near 28k.

    The agentic perf leg (job 281) runs with ATLAS_SSM_SNAP_STATS=1, so its 1007 turns will also report the hit rate, mean anchor and recompute tokens under real agentic traffic.

  4. AzeezIsh commented on Sep 26, 2026

    @AzeezIsh
    ContributorAuthor

    Warm multi-turn TTFT at ~27k (reiner job 425). Merge-train tree (53f4a3d3a, now main), perf-leg serve profile (the Flash-Next recipe with prefix caching on). 3 conversations, turn deltas of about 4.6k tokens.

    turn prompt tokens TTFT median (min / max)
    1 (cold) 18.5k 12.37 s (12.32 / 12.48)
    2 (warm) 23.1k 3.70 s (3.67 / 3.80)
    3 (warm) 27.8k 3.98 s (3.97 / 3.99)

    Snapshot paths: 6 Marconi intermediate hits, 1 exact-leaf hit, 0 prefix hits without a snapshot, 11 snapshots saved.

    • Against the ≤ 3 s target at ~27k: missed by ~1 s. Warm turns are ~3.3× faster than a cold prefill of the same context, and there's no broken warm path. At 9–11k in job 279, warm turns took 1.7–1.8 s.
    • Where the time goes: each warm turn prefills its ~4.6k new tokens. Most turns resumed from a Marconi intermediate checkpoint (spacing 4096 tokens), not the exact leaf, which adds up to ~4k recomputed tokens. At the recipe's prefill rate at 20–28k context, the new tokens alone cost roughly 2.5–3 s.
    • Levers to try next, both A/B-able:
      • Denser intermediate checkpoints: 16 slots × ~113 MB are in use now, so memory is available.
      • Making the exact leaf hit more often. The perf leg's own conversations reached 98 % exact-leaf-class hits with a mean of 14 recomputed tokens (job 298), so this harness's turn construction may be what forces the intermediate path.
  5. added a commit that references this issue on Sep 26, 2026
  6. AzeezIsh commented on Sep 26, 2026

    @AzeezIsh
    ContributorAuthor

    Triage (2026-09-26). At ~27k, warm turns take 3.70 / 3.98 s (job 425) against the ≤ 3 s bar; SGLang does 2.5 s. The warm path works: 6 Marconi hits and 0 misses.

    The two cheapest levers are both simple A/Bs:

    • denser Marconi intermediate checkpoints (16 × ~113 MB are in use, and memory is available);
    • harness turn construction: the perf leg itself hits the exact leaf 98 % of the time (job 298).

    The done criterion also requires ssm-state-poisoning-gate green with prefix caching ON, and that hasn't been posted yet.

    Suggest timeboxing this to one week. If ≤ 3 s isn't reached, record the curve and close it; 3.3x faster than cold is already a shippable result.

  7. AzeezIsh commented on Sep 27, 2026

    @AzeezIsh
    ContributorAuthor

    Where the missing second probably is (Qwen3.8-Max consult plus our own numbers).

    The engine's exact-leaf path clearly works:

    • The perf leg hit it for 98 % of turns, with a mean of 14 recomputed tokens (job 298).
    • warmturn.py at ~27k mostly resumes from a Marconi intermediate checkpoint (spacing 4096), recomputing up to ~4k tokens (job 425).

    That difference points at turn construction, not the cache. The exact leaf is token-keyed. If the harness re-renders the previous assistant turn (whitespace, a stripped reasoning block, EOS/role tokens), the next prompt diverges from the saved leaf inside the reply, and lookup falls back to the last 4096-aligned checkpoint.

    Cheapest discriminating check (no GPU A/B needed):

    • log the first mismatching token id between turn N's prompt + completion token stream and turn N+1's prompt;
    • then assert saved_leaf_len == prompt_len + completion_len at save time, which rules out a leaf saved before the tail flush / tail-split.

    Then:

    • If it's re-rendering: fix the harness (or template idempotence) and re-measure. Expect warm turns near "new tokens only", which is ~2.5–3 s at 20–28k on current prefill rates.
    • If it's the leaf save: force-materialise the exact leaf at request end.
    • Denser intermediate checkpoints (the queued warmturn-ckpt job) are the fallback, not the first move: they cost memory and I/O on every turn to paper over a key mismatch.

    Timebox as proposed earlier: one week, then record the curve.

  8. AzeezIsh commented on Sep 29, 2026

    @AzeezIsh
    ContributorAuthor

    Done. The done bar is met on main b03dc7363 (GB10, perf-leg serve profile: reasoning off, MTP K=2, prefix caching on, tail split on by default).

    Warm TTFT at 27k (reiner 646, 14,500-word conversation, 250-word follow-ups, 3 reps):

    turn prompt tokens TTFT (median)
    1 (cold) 26.8–26.9k 18.11 s
    2 27.3–27.4k 0.74 s
    3 27.8–27.9k 0.73 s

    The bar is ≤ 3 s; SGLang's 27k re-serve takes 2.5 s. Each warm turn restores the previous prompt's tail snapshot, skipping 27,080 tokens on average, and replays about 511. 0 errors.

    ssm-state-poisoning-gate with prefix caching on: Pass (645): 12 replays within bounds, 0 collapsed.

    The tail split stays on: 645 measured it at +0.1 s cold (12.32 vs 12.24 s at 18.5k) against −1.4 s on turn 2 with small follow-ups (0.71 vs 2.08 s) and −1.4 to −3.1 s with large ones.

    The earlier 3.7–4.0 s warm numbers came from warmturn.py appending ~4.65k new tokens per turn. That's prefill speed at depth, which #74 tracks, not a cache miss. The restore already skipped the whole previous prompt (see 626's Marconi intermediate hit lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    job

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions