Skip to content

qwen27 metal dflash2: opt-in adaptive drafter block for a lone stream - #4628

Merged
ashhart merged 5 commits into
mainfrom
lead/q27-adaptive-block
Nov 22, 2026
Merged

ashhart merged 5 commits into
mainfrom
lead/q27-adaptive-block

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

Qwen3.8-27B on Metal drafts a lone stream with a 16-row DFlash2 block (tree_block), while the drafter checkpoint's own block is 8. TF_Q27_DFLASH_ADAPTIVE_BLOCK=1 (default off) lets a lone stream switch between 8 and 16 block rows by how deep its recent rounds landed: after a run of shallow rounds it drafts 8 rows, and a round landing 6 or more tokens returns it to 16 at once. New streams start at 16. Shared rounds are unchanged.

Exactness

Only the drafter's block length changes, so only which rows the target is asked to verify can change. Every verified row goes through the same target path, and replies stay token-equal to main. With the switch off nothing changes.

Measured

Three 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 1 stream (three Macs) 4 streams (three Macs)
chat, 0 +2.7%, +2.8%, +2.8% +0.7%, -2.4%, +4.2%
chat, 1 +2.3%, +2.2%, +1.6% +0.1%, -2.2%, +3.3%
code, 0 +0.5%, +0.4%, +0.4% +0.0%, +0.5%, -0.3%
code, 1 +0.0%, -0.1%, +0.9% +0.1%, +0.0%, -0.0%

One-stream chat gains about 2.5% on every Mac; four streams are unchanged by design (the switch only touches lone streams) and their spread is run-to-run noise.

Tests

Host tests on the block rule over fixed round histories and the off path (test-qwen27-startup-host) and on the switch's registration (test-environment-host); zig fmt, ast-check and the lean check.

TF_Q27_DFLASH_ADAPTIVE_BLOCK=1 (default off) lets a lone stream's drafter
block take 8 or 16 rows. It starts at 16, narrows to 8 after 8 consecutive
rounds landing at most 4 tree drafts, and returns to 16 after a round landing
6 or more. Shared rounds keep 16.

Only the drafter's proposal changes. The target still verifies every row and
draws each token as before, so target tokens are unchanged. With the switch
off, nothing writes the block.
@ashhart
ashhart force-pushed the lead/q27-adaptive-block branch from 5774d7f to 3eec579 Compare November 22, 2026 18:37
@ashhart
ashhart merged commit 462f5ec into main Nov 22, 2026
2 of 12 checks passed
ashhart added a commit that referenced this pull request Nov 22, 2026
@ashhart
ashhart deleted the lead/q27-adaptive-block branch November 22, 2026 18:37
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