Skip to content

gemma4 CUDA: a stepped drafted pass keeps its mark after the drafter absorbed the chunk - #1286

Closed
jschmied wants to merge 1 commit into
ashhart:mainfrom
jschmied:pf1188-gemma
Closed

jschmied wants to merge 1 commit into
ashhart:mainfrom
jschmied:pf1188-gemma

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Follow-up to #1188 (prompt steps beside decoding streams), found in a review of main. The test fails on main and passes here.

Since a525f0b98, the drafter wrapper passes prefill_step through. Gemma 4's CUDA backend has prefill_step, reports_fill and features, and no lone driver, so every DFlash request takes the stepped path. The target's step published its prompt-cache mark before the wrapper's take() absorbed the chunk. The drafter's lane wasn't at the mark yet, so keep left k.draft null and resumeAt refused the state for a drafting stream. The prompt was recomputed from 0. A stepped drafted pass now keeps its mark at the next step, after the absorb, as prefillFeatures already did. Nothing changes without a drafter, and no other family is touched.

  • New GPU check tf-cuda-test gemma4-states MODEL DRAFTER TEXT N (31B 4-bit + z-lab DFlash). States are kept at 1000 (off-grid) and 1536 (on-grid). Each state must carry drafter context, and a resume after another prompt scrubs the slot must equal fresh: last-row logits byte for byte, plus 48-token greedy and sampled replies. Drafted is also checked against plain. On main both states lack the context and every resume recomputes from 0. Here everything passes.
  • Served, GB10, 31B + DFlash, --parallel 2 --context 8192, two chat turns over a ~2.9k-token prefix, fresh server per arm, order main/head/main/head, 3 pairs each:
main this PR
turn 2 cached tokens 0 (RestoreRejected every time) 2940-2942
turn 2 TTFT 3.22-3.59 s 0.289-0.293 s
turn 1 TTFT (cold) 3.22-3.36 s 3.21-3.24 s
decode tok/s (all turns) 33.7-46.4 34.5-44.0
turn 2 reply hash 8bb2d450600b 8bb2d450600b

Gates: full zig build test -Dnvcc exits 0. Lean: 0 new problems against the merge base. The served turn-2 reply hash equals main's, so resumed == fresh holds on the server too.

…absorbed the chunk

Since the drafter's wrapper passes prompt steps through, the target's step
published its mark before take() absorbed the chunk, so a kept state at an
intermediate mark had no drafter context and a drafting stream refused to
resume from it (the prompt was recomputed). The mark is now kept at the next
step, as prefillFeatures keeps it after the absorb.

tf-cuda-test gemma4-states (31B 4-bit + z-lab DFlash): states at 1000 and
1536 carry the drafter's context, and resumed == fresh (last-row logits and
48-token greedy and sampled replies); on main both states lack it and every
resume recomputes from 0.
@ashhart

ashhart commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Landed on main (84e0d56..24072ec), with you as author. Thank you, a real win: on a GB10 with Gemma 4 31B and its DFlash drafter, a 30k-token chat's next turn resumed 29,970 tokens and started after 3.6 s instead of 45 s (5.9 s instead of 48 s with thinking), with the same reply; concurrent resumes too. One stream within 0.2% across six alternating runs. With the 12B and its MTP assistant, which already resumed, nothing changes.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants