Repository navigation
Conversation
…line Take only the deadline-bounded endpoint calls and their tests from ashhart#3293. The hunks for these two files are byte-identical to ashhart#3293 so either change can land first.
Keep explicit residency and probes while allowing callers to omit automatic queue attachment. Cover attachment policy and cleanup through the recording owner.
Give handoff tests independent event values and ordered encoder operations. Retain the dispatch type when recording a reopened compute encoder.
End each producer encoder, post its full-width job epoch, and wait for the host relay before reopening the consumer. Publish valid epochs only after bounded send and arrival phases; terminal releases leave payload epochs invalid. Cover late and stale peer words, failed or expired sends, terminal silence, encoder order and kernel source guards.
Map all seven pair kernels to their production shader and launch records. Add stale-epoch mutation controls and a real GPU handoff loopback under the metal flashnext tp selection.
…g owners Coordinate idle keepalive with request ownership, stop followers before callbacks disappear, and detect terminal failures in the final drain. Bound reciprocal startup and idle peer checks without changing request or step agreement words.
Request and retain the model set in pair mode without attaching it to the queue. Keep single-Mac attachment and test both native inventory paths and cleanup.
TF_TP_LOCAL marks newly encoded jobs submitted after the existing stop and failure checks. Skip the endpoint and peer-readiness clock, and cover a broken endpoint with a full-width job sequence.
Keep host-held timing and add per-kind release-to-post histograms, send time and peer-arrival wait under TF_TP_STATS. Serialize publication with reply snapshots, close partial jobs on failure, and reset at every reply including short replies. Leave the disabled service path without timing clocks or collector locks and preserve GPU work.
Shorten inherited comments and remove measurement history without changing executable statements. Keep the leading fabric prerequisite unchanged; its later comment-only cleanup is separate.
The real relay uses the macOS clock and thread service class. Skip those host probes on other platforms while keeping source, encoding and pure timing checks available.
… runs A paired request left the model unused by any queue: the set is not attached to the engine queue and idle probes stop at the request gate, so macOS unwired the model mid-reply and expert launches stalled on re-wiring. Commit the busy probe through the set on a second queue at the served keepalive interval while the gate is held.
1 task done
7 of 8 tasks
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.
What this changes
On
main, the Flash Next pair's kernels wait for the peer by polling a window flag inside a running command buffer, and on two M5 Ultra Studios the pair fails warm-up withPeerSilent. With this change each producer ends its encoder and signals a Metal shared event, a host relay sends the payload and waits for the peer's word, then publishes a full-width 64-bit epoch that the consumer kernels check before reading. In pair mode the model's residency set is still requested but is no longer attached to the command queue.This is a draft. It fixes the slow replies reported in #3408; the pair is still slower than one Mac. The slow replies were macOS unwiring the model during a paired request: the residency set is not attached to the engine queue and the idle probe stops at the request gate, so nothing used the set while a request ran.
b4ee01293commits the existing busy probe through the set on a second command queue every 400 ms while the request gate is held. With it, 49 requests on the pair have no reply under 10 tok/s (11 before), at a drafted median of 51.1 tok/s and a plain median of 26.3. One Mac does 126.4 and 99.6 on the same requests.--speed-upon two M5 Ultras (macOS 27.2): warm-up failsPeerSilent; with shared-event handoffs it serves, but drafted replies intermittently drop to 1 to 5 tok/s #3408.mainat811c38473e. It does not need glm metal: use shared events for paired transfers #3293 to land first. The first commit takes only the deadline-bounded endpoint calls inzig/src/fabric/mcdma.zigand their tests from glm metal: use shared events for paired transfers #3293's5ec85fd74; those hunks are byte-identical to glm metal: use shared events for paired transfers #3293, so either can land first. No GLM file is included.atc overlap --json: not run yet.Commits:
3684408f5fabric mcdma: bound payload admission and peer flushes by a call deadline70f722e62metal residency: request a set independently of queue attachment43cf092demetal tests: record shared events and encoder boundaries on the host5ea5efa4cflash next tp: release peer consumers through shared-event handoffs9ffbe507fmetal contract: register Flash Next pair epoch guards and relay controls14e0f191cflash next pair: bound startup and drain request work before releasing owners4aff995b1flash next pair: keep requested residency off the command queueb0c25d9daflash next tp: complete local submission without touching the peerba93fe229flash next tp: report release gaps and relay phases for each reply71454c079native comments: keep touched source within the lean comment limits5d0b9bfe1flash next tests: skip relay probes without the native host clockb4ee01293flash next pair: keep the residency set in use while a paired request runsCommits 8 and 9 exist for the measurements asked for in #3408.
TF_TP_LOCALnow also completes the per-command-buffer submit barrier locally, so nothing is sent per command buffer.TF_TP_STATSprints, per reply and per exchange kind, the host-held time, the release-to-next-post gap with a log2 histogram, the send time and the wait for the peer's word. With both switches unset the service loop takes one branch into a path with no timing reads.How this meets the terms in #3408:
zig/src/native/flashnext_host.zig).tp.ziggoes from 592 to 505. The handoff, relay, deadline, submit barrier and statistics are intp_handoff.zig,tp_service.zig,tp_deadline.zig,tp_submit.zigandtp_stats.zig.TF_TP_TRACE,TF_TP_LOCAL,TF_TP_STATSandFZ_BUSYare read exactly as onmain.Checks on this head
b4ee0129375a01a4ec2dcb7dc922accbf8ef1b53. The three entries that follow are at this head; the rest of this section was run at5d0b9bfe15, the previous head.b4ee01293, on an M4 Pro:zig fmt --check build.zig zigandgit diff --checkpass;python3 tools/pr_check.py --base 811c38473e --pr 3480reports lean 321 against 341, 0 new, 0 errors and one advisory warning (no Unreleased bullet names this pull request);zig build test-flashnext-pair-host test-flashnext-cleanup-host test-metal-residency-owners-host test-flashnext-host native tf-kernel-contract -Dcpu=apple_m1 -j4 --summary allpasses 83/83 steps.zig build test test-golden -Dcpu=apple_m1 -j4 --summary all: 868/870 steps, 13,854 passed, 112 skipped, 2 failed; the two failures are the same two as on811c38473e, andtest-goldenpasses.b4ee01293(recording Metal, no GPU): a step under a held request gate commits one probe on the second queue under the owner's lock with no flush and nothing on the engine queue; with no request a step commits nothing; stopping joins the thread; the paired host starts the probe and the one-Mac host makes no second queue; the gate reports active only betweenbeginandend. Four of the five fail with the production change neutralised.b4ee01293: Flash Next--speed-upon two M5 Ultras (macOS 27.2): warm-up failsPeerSilent; with shared-event handoffs it serves, but drafted replies intermittently drop to 1 to 5 tok/s #3408 (comment), with the runs attached: resumed prompts (43 of 49 resumed, all 49 equal to the cache-off replies), concurrent against solo (8 of 8 equal, cache off and on), both ranks equal throughout, and one Mac on the branch (126.4 drafted, 99.6 plain).python3 tools/zig/lean_check.py: 341 findings on811c38473e, 321 on this head, 0 new (tools/zig/lean_new.py).python3 tools/pr_check.py --base 811c38473e: 0 errors, 1 advisory warning (no--prnumber yet for the Unreleased line).zig fmt --check build.zig zigandgit diff --check: pass.zig build native tf-kernel-contract -Dcpu=apple_m1 -j4 --summary all: 69/69 steps.zig build test-flashnext-pair-host test-flashnext-cleanup-host test-flashnext-host test-flashnext-batch-host test-mcdma-host test-benchmark-group-host test-metal-residency-owners-host test-kernel-contract test-metal-launch-map-host test-tp test-tp-suite-host test-tp-fate-host test-cluster test-verbs -Dcpu=apple_m1 -j4 --summary all: 132/132 steps, 1044 passed, 15 skipped, 0 failed.zig build test test-golden -Dcpu=apple_m1 -j4 --summary allon this head: 868/870 steps, 13,758 passed, 106 skipped, 2 failed. On811c38473e: 868/870 steps, 14,117 passed, 113 skipped, 2 failed. The two failures are the same on both:families.glm.weights_fix_test"GLM copies and transforms join before shard eviction" andcore.paced_read"aligned spans copy the bytes asked for". The head's lower pass count is five test steps that were already cached from the command above and print no count.test-goldenpasses on both.main: 49 new or changed named host tests pass on this head. Compiled against a pristine export of811c38473ewith only tests and test fixtures overlaid, 3 fail by assertion ("pair kernel source never polls host-written memory", "every pair kernel checks a full-width epoch before reading payload", and the cleanup test "the pair owns borrowed aliases until all queue work is drained, then closes its endpoint"), 45 cannot compile becausemainhas no host-observable handoff to drive, and 1 comment-only MCDMA test passes on both. The late-peer cases are "relay late peer word releases once with the complete job epoch" and "relay stale peer word does not release the next job" inzig/flashnext_relay_tests.zig; they drive the real service loop and handoff with an epoch above 2^32.atc overlap --json;tools/bench_concurrent.py,tools/bench_openai.pyandtools/bench_cache.py(the Studio runs used a sequential driver that records token IDs from both ranks instead); the full Metal numerical suite (only the filtered pair selection ran); concurrent requests; a resumed prompt against a fresh one (all Studio runs had the prompt cache off).Receipt
Main against branch: on the pair,
maindoes not start, so the comparison is one Mac onmainagainst the pair on this branch, same 49 requests, prompt cache off,--no-thinking, temperature 0.main811c38473emain811c38473eReplies of at least 32 tokens. The pair is slower than one Mac at the median in both modes, and 11 of its 48 replies ran under 10 tok/s. On
mainthe pair fails warm-up on both ranks withPeerSilent(rank 0 at sequence 2, rank 1 at sequence 3),gave_up 0in every trace line.Boxes it reaches: native Metal, Flash Next,
--speed-upover one Thunderbolt 5 link. CUDA, HIP and XPU are outside it.New switch? None.
Environment: TensorFold
811c38473eand5d0b9bfe15, Zig 0.17.0, built on an M4 Pro with Xcode 27.2 and Metal Toolchain 27B47. Two M5 Ultra Mac Studios, 256 GiB each, macOS 27.2 build26B118. CheckpointTensorFold/Qwen3.8-Flash-Next-MLX-6bit-MTPrevision45032a193a5d4126ba8534822cbaf8fb30b3e368. Both ranks load the same MCDMA library, SHA-256ae63dd35624573a647d8fd23b0a29c436a5d3d3de97d40c29d880ce179ac7679.Paths and platforms the change reaches, which I ran and which I could not: ran the pair path on the two Studios and the one-Mac path's host tests. Not run: one Mac on this branch on a Studio (the one-Mac receipts are
main), so "single-Mac attachment unchanged" rests on host tests; any chip other than M5 Ultra and M4 Pro.Exactness: on the pair at this head, 18 replies in three groups (two 61-token prompts three times each and a long prompt twice, each drafted and with
"draft": false): token IDs identical within every group, and rank 1's reply hashes equal rank 0's for all 18. In the 49-request run, all 24 groups of identical bodies have identical token IDs across draft modes and both ranks agree on all 49; the same holds withFZ_BUSY=1 TF_TP_STATS=1. In a 150-request run with--no-drafts, both ranks agree on all 150. A pair reply can differ from one Mac's, asdocs/speed-up-mode.mdsays: for example the 61-token prose prompt hashes29e668310177on the pair and3fd180517008on one Mac.Main against this branch, same machine and checkpoint: the table above.
Decode speed before and after: the table above; the pair has no "before" because
main's pair does not start.Prompt speed before and after: not measured with
tools/bench_cache.py.Licence of any new weights or drafter: n/a.
Kernel contract
tp_argmax_part,tp_pick,tp_ids,tp_copy,tp_plain,tp_branch,tp_merge, mapped to their production shader, plus a GPU loopback of the handoff with a reused receive slot. They replace the polled versions of the same kernels.SUMMARYon an M5 Ultra,tf-kernel-contract --only 'metal flashnext tp', exit 0:8 kernels: 8 pass gates 1-4, 0 fail, 0 known findings; 7 controls: 7 red as planted, 0 missed; 0 limit problems.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled. Not met: the pair is slower than one Mac. See the receipt and Flash Next--speed-upon two M5 Ultras (macOS 27.2): warm-up failsPeerSilent; with shared-event handoffs it serves, but drafted replies intermittently drop to 1 to 5 tok/s #3408.