Skip to content

qwen27 metal dflash2: opt-in batched drafter absorb across streams - #4629

Merged
ashhart merged 3 commits into
mainfrom
lead/q27-absorb-batch
Nov 22, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/q27-absorb-batch

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

On Metal, a shared Qwen3.8-27B DFlash2 round already shares one drafter frame, but each stream still runs its own absorb pass, re-reading the drafter's fc, hidden norm and every layer's K/V projections per stream. TF_Q27_DFLASH_ABSORB_BATCH=1 (default off) absorbs up to 128 rows from 2 to 8 streams in one pass, so those weights are read once a round. The second commit passes "no stacked absorb" from the GLM Metal caller of the shared absorbBlocks.

Exactness

Absorb fills the drafter's own cache; each stream's rows keep their arithmetic and order, and the target verifies every row as before, so replies stay token-equal to main. With the switch off nothing changes.

Measured

Two M3 Ultras, Qwen3.8-27B MLX 4-bit with its DFlash2 drafter, base = this branch with the switch off, new = on, aggregate tok/s:

prompt, temperature 2 streams (two Macs) 4 streams (two Macs)
chat, 0 +0.9%, +1.2% -2.2%, +1.1%
chat, 1 +1.0%, +0.8% -0.6%, +2.7%
code, 0 +0.7%, +0.8% +1.7%, +1.1%
code, 1 +0.7%, +0.7% +0.5%, +0.5%

A small, steady gain at 2 streams; at 4 streams 7 of 8 cells gain, and the one dip has its mirror on the other Mac.

Tests

Host tests on the batch's routing, byte-equal against per-stream absorbs on host arithmetic (test-qwen27-draft-tree-host), and on the switch's registration (test-environment-host); zig fmt, ast-check and the lean check.

A shared round absorbed each stream's new taps in its own pass, so N streams read the absorb weights N times.
TF_Q27_DFLASH_ABSORB_BATCH=1 (default off) stacks up to 128 rows from 2 or more streams into one pass.
Each row keeps its own position and each stream's keys and values go to its own caches.
A larger round, a lone stream and other families sharing this drafter keep the per-stream absorb.
Host cells compare the caches byte for byte at 1, 2 and 4 streams with uneven rows and planted NaN and Inf.
@ashhart
ashhart force-pushed the lead/q27-absorb-batch branch from 839daee to 7d83d49 Compare November 22, 2026 21:56
@ashhart
ashhart merged commit 4fbeb0a into main Nov 22, 2026
1 check passed
@ashhart
ashhart deleted the lead/q27-absorb-batch branch November 22, 2026 21:56
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.

1 participant