Repository navigation
qwen3.5 cuda dflash2: opt-in batched drafter absorb across a round's streams - #4648
Merged
Merged
Conversation
TF_Q35_DFLASH_ABSORB_BATCH=1 (default off) absorbs a shared round's live kept rows, two or more streams, in one pass: each stream's gather into its own rows, one fc, norm and k/v projection over all of them (one weight read), then each stream's rope at its own positions and its own ring write. Prompt absorbs, a repeated stream or host features keep the per-stream call. No kernel on the path reduces across rows, and verify keeps decode's bits a row; the contract command absorb-batch compares fc, k and v rows batched and alone byte for byte at 1, 4, 8 and 16 streams, with NaN/Inf and a planted control.
… a round's streams
ashhart
force-pushed
the
lead/q35-absorb-batch
branch
from
November 22, 2026 18:08
94deebc to
0e91337
Compare
ashhart
added a commit
that referenced
this pull request
Nov 22, 2026
…#4648's duplicate out, no 'taken out again' line)
ashhart
added a commit
that referenced
this pull request
Nov 22, 2026
…#4648's duplicate out, no 'taken out again' line)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
On CUDA, a shared Qwen3.5/3.8 DFlash2 round absorbs each stream's target taps into the drafter one stream at a time: for every stream it re-reads the drafter's
fcweight, the hidden norm and every layer's K/V projection weights.TF_Q35_DFLASH_ABSORB_BATCH=1(default off) absorbs the round's live streams in one pass, so those weights are read once a round.The batched path runs only when there are two or more items, each a distinct live stream on device bf16. Prompt absorbs of more than 16 rows stay per stream, because they switch to the prompt GEMM whose bits differ from the verify path.
Exactness
Absorb fills the drafter's own cache. Each row keeps its arithmetic: the norms, rope, gathers and ring writes work row by row, and the affine-4 projections reduce along K inside a row. The target verifies every proposed row as before, so replies stay token-equal to main. With the switch off nothing changes.
Measured
GB10, Qwen3.8-27B MLX 4-bit with its DFlash2 drafter; base = this branch with the switch off, new = on via a local flip-default commit; order warm base new new base; aggregate tok/s, two boxes:
Every cell gains on both boxes, more at 4 streams, where more streams share each weight read.
Tests
New host tests cover which rounds take the batched path and the window bookkeeping moved into
cuda_draft_absorb.zig;zig fmt,ast-checkand the lean check pass.compile-cuda-testsbuilds; the fulltest-cuda-hostrun is left to this PR's CI (our build box was too loaded for a clean run).