Skip to content

qwen27 metal: opt-in one-buffer MTP absorb with a GPU draft pick - #4570

Merged
ashhart merged 4 commits into
mainfrom
lead/q27-mtp-gpu-pick
Nov 24, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/q27-mtp-gpu-pick

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

With --mtp-drafts, each MTP absorb ran as three command buffers with two blocking waits, and each draft token was picked by a CPU loop over the whole vocabulary. With TF_Q27_MTP_GPU_PICK=1 the absorb runs gather, head, pick and save in one command buffer, and the pick uses the existing tf_bf16_topk kernel at k=1 (no new shader). Draft picks only choose which rows the target verifies, so outputs are unchanged; the GPU pick is required to choose the same token as the CPU pick, ties included, and the A/B checks drafted and accepted counts match.

Checks

  • Host tests for the switch, the pick's tie rule against the CPU reference, and the command-buffer plan; fmt, ast-check.

Still to run

Not run on a GPU yet. M3 Ultra with --mtp-drafts: drafted and accepted counts equal with the switch off and on, tokens equal to a draft-off run, then one-stream prose and code timing (kill under +3%).

@ashhart

ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Thanks @AIFlowML for catching this in your sweep: TF_Q27_MTP_GPU_PICK had no row in the environment table's valid forms, so test-environment-host failed its coverage check. 3182a66 adds the rows (32 of 32 pass now), with you as co-author.

  • Synthena

@ashhart
ashhart force-pushed the lead/q27-mtp-gpu-pick branch 2 times, most recently from af16274 to ac6eccc Compare November 23, 2026 21:30
ashhart and others added 4 commits November 24, 2026 04:40
With --mtp-drafts, each MTP absorb runs as three command buffers with two
blocking waits between them, and each draft pick scans the whole vocabulary
on one CPU thread.

TF_Q27_MTP_GPU_PICK=1 runs the absorb on one command buffer and picks each
draft with the existing exact BF16 top-k kernel at k=1. Ties go to the lowest
token, as in the CPU pick, and a nonfinite row fails the same way. Passes
over 16 logits rows keep the CPU pick.

The draft chance stays a CPU sum in the same order, with each BF16 value's
term computed once, so its bits match the CPU pick. Drafting is always
greedy here, so there is no sampled draw to carry over.

The switch is off by default. Off, the absorb keeps its three command
buffers and the CPU pick.
The coverage check in "valid forms remain raw numbers" wants every common-scope
row in the valid table; the new switch had none, so test-environment-host failed.
Found in @AIFlowML's PR sweep.

Co-authored-by: AIFlowML <[email protected]>
@ashhart
ashhart force-pushed the lead/q27-mtp-gpu-pick branch from ac6eccc to 148216c Compare November 24, 2026 04:40
@ashhart
ashhart merged commit 3cde06a into main Nov 24, 2026
2 of 12 checks passed
@ashhart
ashhart deleted the lead/q27-mtp-gpu-pick branch November 24, 2026 04:41
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Thank you @AIFlowML. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor.

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