Skip to content

qwen CUDA: DSpine drafter for Qwen3.8-27B, opt-in by --drafter - #2633

Merged
ashhart merged 6 commits into
ashhart:mainfrom
jschmied:dspine-27b
Nov 9, 2026
Merged

ashhart merged 6 commits into
ashhart:mainfrom
jschmied:dspine-27b

Conversation

@jschmied

@jschmied jschmied commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Opt-in only: nothing changes unless --drafter points at a DSpine folder.

What this changes

DSpine (tencent/Qwen3.8-27B-DSpine-b16, rev ea909c0f5f) as a second kind of the CUDA Qwen3.8-27B drafter, next to DFlash2.

  • core/dspine.zig (be389b24e, backend-neutral, also used by the Metal PR): DSpine's config contract and admission, the per-row sender lookup, and the exact-sender table walk.

  • CUDA (cb1f9fdc6): --drafter <DSpine folder> selects it from the folder's dflash_config. New: bridge weights plus two tables built at load (~0.8 GB), 8 kernels in qwen35_dspine.cuh (bridge read, code, message and write; sender lookup and message; the per-sender table; a load-time transpose), and the per-step draft code. Taps, tap ring, absorb, head/top-16 and the chain/tree walkers are DFlash2's. The ring attention kernel gains a chunk count and a block-causal switch; DFlash2 passes the old values (same bits). This argument change is the one seam I'd like your view on.

  • All draft linears affine-4, as DFlash2.

  • Issue: refs Draft acceptance on a GB10 before a port: tencent DSpine vs DFlash2 for Qwen3.8-27B #2592 (measurement and method), RFC: families compose core blocks: a conformance kit first, then sampler, config, drafter and format loaders #2460 (shared drafter pieces).

  • Base: main e5889236b.

Checks on this head

  • Head d6a84a87d, on main e5889236b, 5 commits, no CHANGELOG commit. Since 44fce1c10 (where the GB10 checks below ran) the only code change: the DSpine kernels call tf_common::block_sum_serial instead of a local block_sum (main's cuda_common_check); registers unchanged, dspine-table outputs unchanged on 3 seeds, T=0 trees identical to the old binary 6/6.
  • GitHub CI green on d6a84a87d (zig, zig-windows, zig-macos-dev-tools, fmt, pytest, release-paths, benchmark-clients), merge state clean.
  • On d6a84a87d: cuda_common_check 0 violations, cuda_fragment_check 0 misses (22 unittests OK), x86 zig build test 601/601 steps, limits 13.0 and 13.2 0 stale for the DSpine kernels with every control red, live contract 0 problems, pr_check 0 errors, lean 0 new.
  • On 44fce1c10 (GB10): full CI set 660/660 steps, lean 0 new, pr_check --pr 2633 clean. Limits: 13.0 audit passes with every record current and every control red; 13.2 has no stale DSpine entries (the stale ones are main's pending records). Live kernel contract on the DSpine kernels: 0 problems. dspine-table: pass on 3 seeds, 12/12 controls red. Smoke serve of both drafters OK.
  • T=0 identity against a torch reference with the same affine-4 weights (6 prompts, 128 tokens): 116/144 draft chains identical, 92 % of draft tokens; every divergence starts at draft row 3 or later at ~0.1-logit near-ties. Control with the second pass off: 20/144.
  • Tree walker: the commit lifts the host tree walker into core/lanes/draft_tree.zig (Candidates with a backend word layout, the scoring, chain and best-first grow), so Metal (qwen27 Metal: DSpine drafter for Qwen3.8-27B, opt-in #2634) uses the same walker; the CUDA file is a thin wrapper. x86 zig build test 592/592 steps, 8072 tests; GB10 draft host tests 105/105; no kernel changes.

Receipt (GB10, trees, 4 prompts a class, 192 tokens, decode tok/s DSpine vs DFlash2)

class T=0 T=1
agent (replayed SWE tool-call turns) 64.3 vs 54.8 (+17 %) 57.1 vs 51.6 (+11 %)
chat 63.8 vs 68.3 (−7 %) 53.9 vs 57.9 (−7 %)
code 55.0 vs 57.9 (−5 %) 56.4 vs 59.6 (−5 %)

Draft step 10.3–12.8 ms (DFlash2 10.2–11.5), verify 90–95 ms in both, so the difference is acceptance. Precision A/B (affine-4 / BF16 bridge and second pass / full BF16) moves tokens per round by about ±0.1; affine-4 stays. Full tables in #2592. Memory: +~0.8 GB tables, a 168 MB context buffer a stream (DFlash2 42 MB). The 8192 window is capped by the target rows the tap ring keeps.

Checklist

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@jschmied, GB10 cells on cb1f9fdc6f (this PR's second commit, before the tree walker moved into core). One GB10, Qwen3.8-27B MLX 4-bit target, --context 32768 --parallel 2, 256 tokens a reply, fresh servers in the order DFlash2, DSpine, DSpine, DFlash2, drafts off.

Exact. Every DSpine reply equals the same request with drafts off, at T=0 and seeded T=1: all 32 agent requests and all 40 chat and code requests. At two streams the two replies can finish in either order, so those are compared as sets.

Agent-shaped requests. These use a coding agent's system prompt, three tools, and tool turns carrying one to five source files. Decode tok/s, median of four runs each side:

Request (prompt tokens) T DFlash2 DSpine Change
short (3,786) 0 268.2 285.6 +6.5%
short 1 192.3 206.2 +7.3%
mid (8,822) 0 99.0 118.5 +19.7%
mid 1 48.0 53.1 +10.6%
long (13,465) 0 103.0 114.1 +10.8%
long 1 48.3 49.8 +3.1%
xlong (22,719) 0 46.9 50.5 +7.8%
xlong 1 55.5 66.4 +19.7%

Chat and code prompts (1 and 2 streams, decode tok/s):

Prompt T Streams DFlash2 DSpine Change
chat 0 1 51.6 43.5 -15.6%
chat 0 2 92.5 76.9 -16.7%
chat 1 1 50.4 43.4 -13.9%
chat 1 2 76.8 69.7 -9.3%
code 0 1 68.2 61.4 -10.7%
code 0 2 122.7 110.4 -9.9%
code 1 1 76.1 61.3 -19.3%
code 1 2 140.4 113.9 -18.8%

Why. Both drafters propose about the same number of tokens a round (about 15 on chat and code, 17 to 18 on agent requests), so the drafter's cost is level. The difference is acceptance:

  • Chat and code: DSpine commits 4.20 tokens a round against DFlash2's 4.88.
  • Agent requests: DSpine commits 8.10 against 7.27.

So on CUDA it matches your table: a gain on agent turns and a loss on chat and code, which is why opt-in is the right shape. We'll run the same cells on the new head once the kernel records are in, and on the M5 Ultra and M3 Ultra once #2634 serves.

@jschmied

jschmied commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart thanks, that is the clearest picture yet: exact everywhere, +3 to +20 % on the agent-shaped requests, −9 to −19 % on chat and code, from acceptance alone (8.10 vs 7.27 and 4.20 vs 4.88 committed a round). Opt-in it stays.

The records, a float64 table test with four planted controls and the CHANGELOG line are in final CI here and land on this branch as three commits on top of aec25a1b4; I'll say when the head is final for your re-run.

jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 9, 2026
@jschmied
jschmied marked this pull request as ready for review November 9, 2026 02:46
@jschmied

jschmied commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart the head is final for your re-run: 44fce1c10 (fast-forward, three commits on aec25a1b4: kernel-contract records for the new kernels and the changed ring attention, a float64 dspine-table test with planted controls, the CHANGELOG line). Full CI set 660/660 here, limits and live contract clean on the DSpine kernels, smoke serve OK. Marked ready for review; the body lists the checks.

jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 9, 2026
@jschmied

jschmied commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart one correction: the branch conflicted with main on the CHANGELOG, so CI could not run. Replayed on main as fbef9140a, code identical to 44fce1c10; x86 host tests and the CUDA host compile pass on it, and CI is running. Use fbef9140a for the re-run.

@jschmied

jschmied commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart main's CHANGELOG moved again within the hour, so I left our CHANGELOG commit out (you place the line at landing; the proposed text is in the body). Head is now 08d1d6600, same code; that is the one for the re-run.

@jschmied

jschmied commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart CI caught main's new cuda_common_check: the DSpine kernels had a local block_sum. They now call tf_common::block_sum_serial (same serial order; registers, dspine-table outputs and T=0 trees unchanged). Head d6a84a87d on main e5889236b; that is the one for the re-run.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@jschmied the same cells on aec25a1b4b (the tree walker in core), one GB10, the same settings: the picture is unchanged. Agent requests are faster with DSpine: +7.0 to +19.4% at T=0 and +2.4 to +19.8% at T=1. Chat and code are slower: -10.1 to -19.4%. In every arm all 56 replies equal drafts off (concurrent replies compared as sets), so the lift into core keeps the drafter exact. Moving the walker didn't change speed against cb1f9fdc6f beyond run-to-run spread.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@jschmied, thanks. On d6a84a87d9 the only code change since our cells is the move to tf_common::block_sum_serial, which sums the warps in the same order the local block_sum did. The new records and the dspine-table runner are in, and CI is green.

Next is the CUDA kernel contract on a GB10 for this head, with dspine-table run after it; it's queued. If it shows no failures that main doesn't also have, this goes into the landing queue. I'll place the CHANGELOG line using our GB10 ranges: agent requests +3 to +20% against DFlash2, chat and code 9 to 19% slower.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@jschmied, our GB10 cell on this head (d6a84a87d), main against this branch without --drafter: 0 of 20 prompt rows differ, chat replies are equal, and prefill and decode are level (2K prefill 1,456 to 1,452 tok/s, decode 24.4 both). So the default path is unchanged. With the drafted runs we measured earlier, this is on the landing queue now. Thank you.

jschmied and others added 6 commits November 9, 2026 18:07
…ckend

Tencent's DSpine block drafter (tencent/Qwen3.8-27B-DSpine-b16) admitted from its config.json alone:
block-causal bridge, exact-sender serial table, independent writes, all-sliding plain-rope layers.
The table walk (sender = the chosen candidate's index in the row before) is backend-neutral so the
CUDA and Metal drafters share it.
--drafter at tencent/Qwen3.8-27B-DSpine-b16 selects it from its config.json (core.dspine.declared); DFlash2
folders are unchanged. It is a second kind of the CUDA Draft, sharing its tap ring, absorb, context rings,
batched frame, head spans, top-k, chain/tree/lane walkers and the lanes Drafter contract:
- attention: tf_q35d_attn_partial/merge take the chunk count (33 for the 8,192 window) and a causal flag
- layers without the conv, each closed by the code bridge (read code, codebook anchor, gated message, write)
- second pass on the GPU: every row's 16 candidates scored after each of the row before's (exact sender),
  normalized logits; TG = W_write^T (final_norm * head row) built at load through the target head
- the walkers read that table (core.dspine.sender), so greedy, sampled draws and trees all follow it
- absorb keeps at most the rows the target's tap ring holds (tap_rows - most_verify) behind its newest
Draft linears are affine-4 as DFlash2's.
…able rows) shared by every backend; CUDA keeps a thin wrapper
…ender table against float64 with four controls
@ashhart
ashhart merged commit a156bfe into ashhart:main Nov 9, 2026
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 10, 2026
…ne; DSpine's core parts are on main, Metal is open
ashhart added a commit that referenced this pull request Nov 10, 2026
Figures corrected to the PRs' measured ones (#2699 head runs, #2509,
#2633, #2436, #2644, #2593, #2430, #2568), scope fixed (#2253, #2287,
#2511, #2569, #2337, #2627, #2351, #2626), unsourced figures dropped
(#2181, #2606, #2257's pricing clauses), the shipped #2176, #2565,
#2548 and gfx12 silu entries and the first #2625 copy removed, and
the #2568 and #2352 entries unwrapped to one line each.
jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 10, 2026
jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 10, 2026
@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied! This is in TensorFold 1.2.6, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.6

  • Synthena (Ash's Agent)

ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 10, 2026
, ashhart#2464, ashhart#2375, ashhart#2634) and adds row 29, DSpine (ashhart#2633)

Rebased onto main after ashhart#2760's row 28 (Scale index), which stays as on main. DSpine is row 29 with ashhart#2633's
final GB10 ranges: agent 2-20 % faster, chat and code 10-19 % slower.
ashhart pushed a commit that referenced this pull request Nov 11, 2026
, #2634) and adds row 29, DSpine (#2633)

Rebased onto main after #2760's row 28 (Scale index), which stays as on main. DSpine is row 29 with #2633's
final GB10 ranges: agent 2-20 % faster, chat and code 10-19 % slower.
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