Skip to content

fix: the M5 draft head reads the target head at its own group size - #147

Closed
gilby wants to merge 1 commit into
ashhart:mainfrom
gilby:fix/draft-head-group
Closed

gilby wants to merge 1 commit into
ashhart:mainfrom
gilby:fix/draft-head-group

Conversation

@gilby

@gilby gilby commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Problem

On the M5 lane path, DFlash2's reduced draft-vocabulary head reads the target lm_head with the wrong group size when the head is quantized in groups of 32. DFlashDrafter._sub_head slices the lane-tiled head but doesn't keep its group size. candidate_logits then calls lane_matmul(hidden, weight, sbt, tiled=True, nt=nt) without group=, so the call defaults to 64.

oMLX's oQ4e checkpoints keep lm_head at their 4-bit/32 base. For them:

  • the draft logits are wrong;
  • replies stay exact, because verification passes the group;
  • DFlash2 accepts 0.1–1% of drafts.

The model just looks slow. The M1–M4 path (_plain_sub_head) already records the group, so only the M5 is affected.

Change

  • _sub_head keeps the head's group_size, and candidate_logits passes group= to lane_matmul.
  • A one-time check on the first draft: it compares the reduced head's logits with the full head's on the same rows, using the tolerance the test uses. On a mismatch it logs a line and drafts with the full head, so a head-format mismatch can't silently disable drafting again.
  • tests/test_dflash_draft_vocab.py: a 4-bit group-32 head. It fails before this change and passes after.

lane_fuse._project has the same default, but its stacks are built from group-64 members only, so it's correct today. Left as is.

Checks

  • M5 Ultra: tests/test_dflash_draft_vocab.py 8 passed (the new g32 case fails on main). Drafting, lane, loading and quantization suites: 594 passed, 2 skipped.
  • Qwen3.8-27B-oQ4e-mtp (text-only oQ4e) + z-lab/Qwen3.8-27B-DFlash2, --parallel auto --reasoning-effort medium, greedy, 512-token replies:
accepted 1 stream N=4 aggregate replies
M5 Ultra, main 0.1–1% (10/999, 5/2071, 10/7455) 33 tok/s 114 —
M5 Ultra, this branch 46–56% 131–160 tok/s 314–322 byte-identical to main's, drafted and concurrent
M3 Ultra, main 54–75% 68–89 140 —
M3 Ultra, this branch 54–75% 68–91 144 identical to main's (the M1–M4 path was already right)

The first-draft check stayed silent on both chips. TF_DRAFT_VOCAB=full on main gives the same acceptance as this branch, which confirms the reduced head was the cause.

🤖 Generated with Claude Code

The reduced draft-vocabulary head (DFlashDrafter._sub_head) sliced the lane-tiled target lm_head but did not keep
its group size, and candidate_logits called lane_matmul without group=, so a head quantized in groups of 32 (oMLX
oQ4e keeps lm_head at its 4-bit/32 base) was read with the group-64 kernel. Draft logits were wrong, replies stayed
exact (verification passes the group), and DFlash2 accepted 0.1-1% of drafts.

- _sub_head keeps the head's group size; candidate_logits passes group=.
- A one-time check on the first draft compares the reduced head with the full head on the same rows and falls
  back to the full head, with a log line, when they differ.
- tests/test_dflash_draft_vocab.py: a 4-bit group-32 head (fails before this change).

Qwen3.8-27B-oQ4e-mtp + z-lab/Qwen3.8-27B-DFlash2 on an M5 Ultra: accepted 46-56% (was 0.1-1%), 131-160 tok/s
single stream (was 33), N=4 314-322 (was 114); replies byte-identical to 0.5.0's.
@ashhart

ashhart commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks for finding this. On an M5 Ultra the draft head was reading a group-32 target head at group 64, so with DFlash2 the acceptance fell to 0.1-1%. The 27B oQ4e went from 33 tok/s to 131-160, and the replies were identical. The head now reads at its own group size. This is in 0.6.0, out tonight.

@ashhart ashhart closed this Sep 30, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
@ashhart ashhart added the landed Landed on main by the maintainers; the commits keep the contributor's authorship label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants