Repository navigation
Conversation
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
2 times, most recently
from
November 14, 2026 00:20
52277cf to
f09e9c0
Compare
Owner
Author
|
Device check on an M3 Ultra (base = #2342's head, new = this PR's top commit at 52277cf): GREEN, tokens unchanged. Greedy code prompts, aggregate tok/s:
Sampled prompts (temperature 1.0) are level, +0.3% to +1.8%, as expected: the change only touches plain greedy rounds. I restacked this onto #2342's new head. #2342 gained one commit, the kernel-contract entries for its two pick launches (7917a84). This PR's commit is byte-for-byte the same patch, now f09e9c0. Both are next in the landing queue.
|
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 14, 2026 00:58
f09e9c0 to
9dd124b
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 14, 2026 00:58
7917a84 to
174645f
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 14, 2026 02:18
9dd124b to
1e4e801
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 14, 2026 20:09
1744e68 to
179ed9b
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 14, 2026 20:09
1e4e801 to
ed6f32b
Compare
This was referenced Nov 14, 2026
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 17, 2026 09:04
179ed9b to
4f06405
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 17, 2026 09:05
ed6f32b to
c9125e6
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 17, 2026 17:45
4f06405 to
d7620df
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 18, 2026 02:00
c9125e6 to
fa7d530
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 18, 2026 02:19
d7620df to
d72f3a5
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
2 times, most recently
from
November 19, 2026 04:35
bbf56a9 to
79159c4
Compare
This was referenced Nov 19, 2026
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
2 times, most recently
from
November 21, 2026 15:41
e2b318c to
843d0e9
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 22, 2026 02:15
79159c4 to
958600b
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 22, 2026 03:27
843d0e9 to
0402836
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
2 times, most recently
from
November 23, 2026 19:40
dab3cf3 to
7768fa7
Compare
ashhart
force-pushed
the
lead/qwen27-qk-glue-metal4
branch
from
November 23, 2026 19:55
0402836 to
5439065
Compare
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 23, 2026 21:36
7768fa7 to
335b52d
Compare
A Metal 4 context for one model (zig/src/metal/metal4.zig): its own MTL4 queue, one command allocator, 32 reused command buffers, an argument table, an 8 MB ring standing in for setBytes, and a residency set of its own. command.zig's queue, command buffer and encoder take an optional context and route every call through it. - Residency: a buffer joins the context's set the first time a Metal 4 encoder binds it (setBuffer, useResource, indirect arguments), with its GPU address cached; Buffer.deinit reports frees, and the buffer leaves the set at the context's next idle command buffer. - Each commit takes new MTL4CommitOptions with a feedback handler, a block literal in Zig, that reports Metal's error and GPU start and end. Options reused for a second commit never call back. - Barriers and fences map to the stage-based calls with device visibility; a barrier with no dispatch since the last is skipped, and a serial encoder barriers after each dispatch. - Only Qwen27 verify and decode passes of up to 64 rows take it (decode_round.passQueue): prompt chunks ran 3.5% slower on Metal 4 with qk. Keeps, drafter frames, snapshots, profile traces, the Neural Engine share and seams stay on Metal 3; CPU waits order the two queues. - On by default on chips with tensor units; TF_Q27_METAL4=0 turns it off and 1 turns it on elsewhere (untested there). - core/fence.zig's Metal 4 branch compiles only where the encoder has the field, so recording fakes in tests still build. - tf-qwen27-metal4-ab: Metal 3 against Metal 4 passes, interleaved. Checked on an M5 Max: golden 1024 of 1024 alone on main and with qk and the glue; metal4-ab equal over 68 rounds a side on either kernel set; metal4.zig's unit test with no leaks; zig build test exit 0. It saves 0.3 to 0.5 ms a verify.
…and Metal 4 Two runners on one model, interleaved round by round: one on tf_lane_reg, TensorFold's glue and Metal 3, the other on qk, the flat glue and Metal 4. Every logit and pick must be equal; it prints median wall and GPU time by width. On an M5 Max: equal over 68 rounds a side cool and 244 hot; a 16-row verify is 4.2% faster cool and 5.5% hot. Served streams, the same binary with the switches on and off, were about 5% faster (93.1 against 98.3 tok/s with 120 s rests), and one-row decode about 2.5%, with every reply equal to stock. Prompts stay at stock speed.
… analyze this file compile Buffer.deinit calls metal4.released, so every build that compiles the Metal module (the Qwen4 projection bodies on Linux among them) analyzes the registry lock. std.c.os_unfair_lock asserts it is on Darwin at compile time. Off Apple the lock is now an empty struct whose hold and drop do nothing; on Apple the calls are the same os_unfair_lock ones.
Route the existing Qwen decode and verify passes through main generic Metal 4 timeline while keeping the lane core Drafter authoritative. Host Qwen A/B roots opt into that runtime, and pass selection moves into a small helper to retain the source cap.
ashhart
force-pushed
the
lead/q27-greedy-picks-in-verify
branch
from
November 23, 2026 22:10
335b52d to
dd2cd8b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2930. Stacked on #2342 (rebased today); review the top commit.
A plain greedy Qwen3.8-27B round on Metal picked its tokens with a separate
argmaxRowspass after the verify's last command buffer. Every greedy token paid one more command buffer and a host wait.When a round is plain and greedy (the same condition that called
argmaxRows), the argmax over the round's rows (#2342'sargmaxChunks) is now encoded into the verify's last command buffer as its tail, and the separate pass is skipped. Asamplingprofile scope stays around the pick, so profiles still show the step. Sampled rows still draw on the host. A non-finite row still raisesNonfiniteLogits, and mixed greedy-and-sampled rounds keep today's path.Exact: the same argmax over the same logits, with ties going to the lower id.
Tests (host, recording fakes): a plain greedy round commits no command buffer after the verify's last; a planted NaN row still raises
NonfiniteLogits; a mixed round keeps the host draw.Not yet checked: greedy replies byte-equal on an M5 and an M3, and the A/B (expected +0.2-0.5% greedy, one and four streams).