Repository navigation
qwen27 metal: a lone sampled stream's draft tree ranks its candidates with the target draw's keyed noise - #3978
Conversation
|
Thanks @hobbesd. Reviewed as a first review: the two pass-through lines wire the selector noise the way the CUDA path does, greedy keeps main's path, and your receipt shows main and the branch agree on every token hash in all eight cells, so the replies stand unchanged while acceptance rises. What is still open before this lands:
We will run the device check on our side: an M3 Ultra serving the 27B with the DFlash2 drafter, sampled, at 2, 4 and 8 streams plus a resumed turn. We were unable to run any Mac cell here.
|
|
Thanks for the review. Agreed on both open points: nothing beyond one stream has been run on my side, so Your M3 Ultra check at 2, 4 and 8 streams plus a resumed turn covers what the checklist leaves open. |
|
Thanks @hobbesd for the reply and for agreeing on the two open points. Neither point is settled at this head yet. Your new test pins the noise pass-through in selection(), and your table shows main and the branch agreeing on every token hash in all eight cells at one stream. But proposeBatch also reads selection(), and nothing beyond one stream has been measured: two, four and eight streams, a resumed turn against a fresh one, and the widest admitted width. We will run that check on our side: an M3 Ultra serving the 27B 4-bit checkpoint with DFlash2, sampled, at two, four and eight streams plus a resumed turn. GitHub's runners are backed up tonight, so no checks have reported on this head yet; we will read them when they do.
|
|
Thanks @hobbesd. We ran the device check we promised on an M3 Ultra: Qwen3.8-27B 4-bit with DFlash2, main against this head, two runs each in the order base, new, new, base, at two, four and eight streams, greedy and sampled, plus resumed against fresh chats.
So the losses sit exactly where our earlier ask pointed:
|
|
Thanks for running the cells. I have measured nothing past one stream, so what follows is from reading the code, not from a run. The tree is ranked the same way in both cases: Proposal for the next head: pass the noise only for a lone stream ( Keeping the gain in shared rounds would mean giving a shared round's chance a score without the noise, or counts of its own. That goes against what |
|
I ran the current python3 tools/bench_concurrent.py http://127.0.0.1:PORT local-model \
--levels 1,2,4,8 --tokens 160 --reps 1 --temperatures 1 --seed 1234For timing, the two- and four-stream cells were slower on the head in both pairs. Sampled code at four streams was 214.0/190.3 tok/s on base versus 194.2/184.1 on head. At eight streams the base varied from 166.7 to 224.0 while the head gave 231.0/222.4. I would keep the original M3 Ultra paired run as the performance gate, especially at two and four streams. This check used fresh requests only.
Igor Lessio - AIFLOW LABS |
|
Thanks for running this on an M5 Max, and for the exactness cells at all four widths. On the timing, from reading the code, not from a run (I have still measured nothing past one stream): on this head Agreed that the M3 Ultra paired run should be the gate. |
… the target draw's keyed noise
…s keyed noise A shared round reads each node's chance as e^own from its tree's scores, so a batched proposal keeps the drafter's scores as on main.
51ea8f7 to
87e5c1f
Compare
|
Thank you @hobbesd. 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. |
What this changes
A sampled qwen27 stream on Metal draws each token as a keyed Gumbel race (
lanes.sampling), but its DFlash tree ranks candidates by likelihood alone. The selector already has the hook for the draw's noise (selector.Options.noise,temperature); CUDA (94ce0d1c4) and XPU feed it, the Metal lane backend never did. With this changedraftFnpasses a sampled stream's seed and temperature while it is the only stream drafting, so its tree follows the token the draw will pick. The target's draw still decides every token; greedy requests take the same path as before.Streams that share a round draft as on main (since
16c52c4de). The first head passed the noise there too, and the device check on an M3 Ultra (comment of 2026-11-20) found sampled code 6.4% faster at two streams but 3.2% slower at four and 3.8% slower at eight. A shared round reads each node's chance ase^ownfrom the tree's scores (landing.chanceFor), which then carry the noise term; a lone round reads its landing counts. Whether that is the cause is not shown.The change, the measurements and this text were made by a coding agent (an LLM); none of it is written by hand.
94ce0d1c4did for CUDA. Say if you want an issue first.517a44563, four commits:3441a9e96(the pass-through; every number in the receipt is from it),7fd027ed1(theCHANGELOG.mdline),16c52c4de(the pass-through for a lone stream only, with its test) and51ea8f737(the changelog line reworded).atc overlap --json: not run (atc whoreturnedpullFilesUnavailablewith my token). By hand: five open pull requests touch the same files (qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434, Qwen3.5-9B DFlash drafter in Zig engine #1851, Qwen3.5-9B grow-as-used K/V in Zig engine #1896, Qwen3.5-9B prompt rows in one product in Zig engine #1897, qwen27 Metal: DSpine drafter for Qwen3.8-27B, opt-in #2634).git merge-treewith qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434 is clean; the other four conflict with main already and get no further conflict from this branch. None of them setsnoise.Checks on this head
51ea8f737ee723b4f11f1beb40d11753f35a30eepython3 tools/zig/lean_check.py, on the base and on this head (51ea8f737): 189 and 189, 0 new.tools/pr_check.py --base origin/main --pr 3978on this head: 0 errors, 0 warnings.zig build test test-golden -Dcpu=apple_m1 --summary all: on3441a9e96904/904 steps, 15,268 of 15,382 tests passed, 114 skipped, 0 failed; again with16c52c4de's changes over the same cache 904/904 steps, the rerun steps' 689 of 719 tests passed, 30 skipped, 0 failed.zig fmt --check build.zig zigandgit diff --check: clean.16c52c4de's test (qwen27 grants: a shared round's sampled proposals keep the drafter's scores free of the draw's noise, reached byzig build test-qwen27-grants-host) fails whenfollowsDrawignoreslone. The new test (qwen27 window: a sampled proposal's selection ranks its roots with the draw's noise, reached byzig build test-qwen27) fails without the two pass-through lines inselection()(expected 0.5, found 1) and with a planted wrong expectation.16c52c4deor later (for a lone stream it passes the same options as3441a9e96; shared rounds get main's), more than one stream on my side, thinking on, vision, long histories,tools/bench_cache.py, any chip other than the M4 Max. The 8-bit checkpoint with a drafter does not start on main's defaults with 48 GB. No optimization-ledger row, as94ce0d1c4added none.Receipt
Main against branch: cells and numbers, or why they can't be run:
tools/bench_openai.py BASE local-model --tokens 256 --reps 3 --temperatures 0,1, a fresh server per run (--parallel 1 --context 65536 --drafter z-lab/Qwen3.8-27B-DFlash2 --prompt-cache-gib 0), order main, branch, branch, main, branch, main, main, branch, one start of each binary before the first run. Rounds and tok/s are from the server'sdonelines;bench_openai.py'sdecode_tpsagrees within 0.1.token_sha(all runs)Over the six sampled cells: 394 to 396 rounds on main, 369 to 371 on the branch; 41.0 to 41.2% of the offered rows accepted on main, 45.0 to 45.1% on the branch. Decode time of the six cells: main 25.9, 24.5, 24.6, 26.1 s; branch 22.8, 24.3, 24.3, 24.2 s.
How to read the times: the runs fall into two round speeds that follow the machine, not the binary. Five runs stayed at thermal state
nominal(main 1 and 4, branch 2, 3 and 4 in the table) at 65.7 to 66.2 ms a round; three reportedfairat their start or end (main 2 and 3, branch 1) at 61.4 to 62.0 ms. Like against like the branch's sampled decode time is 6.6% lower (nominal) and 7.1% lower (fair). One cell gains nothing: fibonacci-raw with seed 1236 takes 44 rounds on the branch against 43 to 44.One branch run is left out and was repeated: its greedy cells ran at 50.4 and 40.0 tok/s against 83.6 to 84.1 and 55.5 to 56.8 in the other eight runs, so the machine was disturbed. Its token hashes equal the others too.
Boxes it reaches: every Mac serving a qwen27 Metal checkpoint with a DFlash drafter, sampled requests only, one stream (
proposeOptions). Two to eight streams (proposeBatch) get no noise since16c52c4de. Ran: M4 Max, one stream, the 27B 4-bit with DFlash2, on3441a9e96.New switch? Default, accepted values, profile row: none.
Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision:
3441a9e96against517a44563; Zig 0.17.0,zig build native -Dcpu=apple_m1; Apple metal version 32023.922; Apple M4 Max, 48 GB, macOS 27.2.1 (26B131);TensorFold/Qwen3.8-27B-MLX-4bit@22d8d538154e0e5b6f8dcb1fcc74a60a0798104cwithz-lab/Qwen3.8-27B-DFlash2@50307d4c4cde6860d4eee73e2547cd786fe8e8a4.Paths and platforms the change reaches, which I ran and which I could not: the Metal lane backend's draft proposals for a sampled stream drafting alone. Ran: M4 Max (no tensor units). Could not: M1 to M3, M5. Not run by me: two or more streams, thinking, vision, the 9B and MoE checkpoints.
Exactness, from
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: on the branch,--tokens 256 --reps 1 --temperatures 0,1 --levels 1 --alone --serial: four cells, eachalone1 equal, 0 unequal andserial1 equal, 0 unequal. Main and branch give the sametoken_shain all eight cells of every run (table).Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): the table above.
Decode speed before and after, from
tools/bench_openai.py: the table above.Prompt speed before and after: n/a, the change is in the draft proposal after a round and cannot reach prompt processing.
Licence of any new weights or drafter, or "n/a": n/a.
Checklist
The title and description match the head commit, including the receipt and the stack.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Drafted against"draft": falseat one stream: yes, greedy and sampled, on3441a9e96. A resumed prompt and concurrent streams: not run by me; your M3 Ultra check on7fd027ed1reports no token differences. Nothing run on51ea8f737.)No precision traded for speed. If the bits change, the description says which sums change and why.
Decode and prompt processing are no slower than main at one stream and the widest admitted; with
--drafter, no slower than without it, greedy and sampled. (One stream with the drafter, greedy and sampled: yes, table, on3441a9e96. Two to eight streams take main's proposal path since16c52c4de; not measured on this head. Without the drafter: not run.)