Repository navigation
Conversation
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
Paired GLM-5.3-Flash can stall during startup when its Metal kernels poll a peer flag while the host writes it. Use Metal shared events for both directions of the handoff. Publish an arrival only after the peer transfer flushes. Bound each send with a short host deadline and the peer's arrival with a longer one, and use 64-bit epoch guards to release waiters safely when the link fails.
exchange 2: PeerSilentand rank 0 never serves #3158.mainatbafe3e07cb35f1c406a61d61fe3933a415c4f645. The rebased patch is byte-identical to the one used in the original Studio benchmark. Upstream has since advanced to90b4fae6. Its changes are in CUDA and the changelog. A local three-way merge against that tip completed without conflicts.atc overlap --jsonThe selected-PR check against90b4fae6on 2026-11-14 UTC found one conflict with glm metal: one arithmetic order for prompt windows, chunks and decode on M1-M4 (#743) #2128 inzig/src/families/glm/prompt.zig. The registry registration was moved away from metal row projection: windows of 4+ rows run 8 at a time, then 4, 2 and 1, each code unpacked once #3129's insertion, and the follow-up check found no conflict with metal row projection: windows of 4+ rows run 8 at a time, then 4, 2 and 1, each code unpacked once #3129, MoE route tap: optional TF_ROUTE_TAP trace of global top-k #1886, or metal families: refuse a token id at or past the embedding table before the lookup #3045. A separate three-way audit of 68 file overlaps among 361 open PRs found glm metal: one arithmetic order for prompt windows, chunks and decode on M1-M4 (#743) #2128 was the only new conflict.Tested merge resolution for #2128
The trial merge used #2128 at
a2b0943d97f15647210239ca0dc55654968420a5projected ontomainat948e7485840834e5c78f2db1ce4d44322cf72e44. Keep the*Passsignatures andconst e = pass.encinprompt.zigformoeandmla. Restore #2128'sx.k.orderedearly returns, callingordered_prompt.moewithpassandordered_prompt.mlawithe. Inordered_prompt.zig, accept*Passinmoeand forward it tofwd.moe. Ordered dispatch remains limited to the unpaired path.zig build native test-glm-ordered-host tf-kernel-contract -Dcpu=apple_m1 -j2passed 73/73 build steps and 10/10 ordered GLM host tests on the composed tree. The trial merge is separate from this draft. The same patch applied to the projection of #2128 onto currentmainatbafe3e07c. The resolved tree8e7d9c9e1b5e9fb9a3cdbde1b30b4722048a119epassed all 10 ordered GLM host tests. An apply check also succeeded against the projection onto90b4fae6. After applying the replay patch, apply the follow-up test diff fromgit diff --binary 5ec85fd74 27ddaf316 -- zig/tests/contract. The combined apply check on90b4fae6produced treeb54b59f876b5918dba265220f68eff8540b28461. Apply the resolution when rebasing the second PR after the first lands.To reproduce on a clean disposable worktree containing those refs, project #2128 with
git merge-tree --write-tree bafe3e07c a2b0943d, load that tree withgit read-tree -mu <projected-tree>, and apply the replay withgit apply --index merge-2128.patch. Download the tested replay patch.Checks on this head
Head commit
cf2c65bd3e562b9cfd621f56b8af6c45a71bfc3f. The latest follow-up splits the relay's deadline inzig/src/families/glm/ep.zig. One native send and its flush keep the 1 s budget and fail withEpTransferTimeout. The wait for the peer to reach the same exchange and send it now has its own 10 s limit, the same asmain's exchange wait, and fails withPeerSilent. Before this, the 1 s budget started at this rank's GPU post, so a peer running more than 1 s behind ended the pair. AGLM_EP_DELAY_UShold now runs before the send budget starts. A healthy exchange now also re-arms the deadline once after its flush. The fault, late-peer and restart checks were rerun on the Studios at this head. The decode, prefill and exactness tables were measured before this change.Checks at
cf2c65bd3zig build native test-glm-expiry test-glm-scheduling-host tf-kernel-contract -Dcpu=apple_m1 -j4 --summary allpassed 75/75 build steps and 85/85 tests on the M4 Pro.tf-kernel-contract --only 'metal glm ep'exited 0 with 8/8 kernels passing, 8/8 controls caught and zero limit problems.zig fmt --check build.zig zigandgit diff --checkpassed. The No GPU workflow's Zig steps also ran on the M4 Pro with-Dfixed-cpu:test-kernel-contract(205/205 tests),test-golden,test-gradient-serving test-qwen-serving-host,test-server-security test-pull-security(27/27 security checks) andfuzz-cortheonpassed.test-hostregisters only on a Linux host, so all 48test-glm-*andcheck-glm-*steps it collects ran instead with--test-timeout 20m: 185/185 build steps and 374/376 tests passed, with two GLM OCR tests skipped. The focused MCDMA tests were not rerun at this head. The Studio reruns are under Receipt.Previous head
27ddaf3161c07c4197c789aa92425b01496b4dferemoved 41 net lines from the Metal test scaffolding. The same eight kernel probes and eight planted controls use one production Metal library and one fault-injected library. It left the inference source and binary unchanged.Inference checks at
5ec85fd74The native build, focused GLM host targets, both golden suites, and Metal contract build passed inzig build native tf-kernel-contract test-glm-expiry test-glm-scheduling-host test-golden -Dcpu=apple_m1 -j4 --summary all(80/80 build steps, including cached results for the focused host tests). The golden suites reported 322/335 and 55/55 matches with zero unexpected differences. The rebuilt native binary had the same SHA-256 as the Studio benchmark binary. A fresh smoke attempt on the rebuilt binary stopped before any exchange when rank 1 reportedMemoryShort(7.7 GB free or reclaimable against the 8.6 GB admission floor). Both test processes were cleaned up. On the rerun with memory available, the same draft-head binary served on rank 0 in 15.421 s. All three requests returned the expected replies (BANANA,42, andblue), each rank landed all 1,502 exchanges, and both exited cleanly. The focused M4 contract rerun passed 8/8 kernels with all 8 controls caught and zero limit problems.zig fmt --check build.zig zigandgit diff --checkpassed.Lean checker
python3 tools/zig/lean_check.pyreported 341 inherited findings onbafe3e07c,27ddaf316andcf2c65bd3.tools/zig/lean_new.pyreported zero new findings.Developer tools at
27ddaf316zig build tf-kernel-contract dev-tools -Dcpu=apple_m1 -j3 --summary allpassed all 264 build steps. Zig formatting and diff checks passed.Focused MCDMA tests at
5ec85fd7419 passed, 0 failed, 0 skipped. These use fake endpoints for Thunderbolt and ConnectX, so they run without a native MCDMA library.zig test -lc --dep sys --dep verbs --dep bf16_round -Mroot=zig/src/fabric/mcdma.zig \ --dep sys -Mverbs=zig/src/fabric/verbs.zig -Msys=zig/src/platform/sys.zig \ -Mbf16_round=zig/src/core/bf16_round.zigOriginal checks at
948e74858with the contract additionszig build test-kernel-contract -Dcpu=apple_m1passed 229/229 tests. The Metal launch map resolved all 736 registrations and both limit controls. The focused Metal device results are below.Inference source checks before the contract-only additions
zig build native -Dcpu=apple_m1passed.zig build test-glm-expiry test-glm-scheduling-host -Dcpu=apple_m1passed 85/85 tests, and the focused MCDMA unit run passed 19/19.zig build test-golden -Dcpu=apple_m1had zero unexpected differences across both golden suites.zig build test -Dcpu=apple_m1passed 4,949, skipped 57, and failed two local memory-floor tests (paced_readand GLMweights_fix). Both reproduced asMemoryShorton pristinemain.CI GitHub created No GPU and Zig format for
27ddaf316. Both require maintainer approval for the fork. No CI jobs have started.Metal missing-device check at
27ddaf316A process-local dyld interposer forcedMTLCreateSystemDefaultDeviceto returnNULL. The prior runner exited 1 withNoDevice. The fixed runner printsSKIP Metal kernel contract: no Metal deviceand exits 0 in both focused and limits-only modes, before opening a command queue. Both runs emitted no gate summary. With a real M4 Pro device the rebuilt runner passed 8/8 kernels, caught 8/8 controls and had zero limit problems. Filters for a copy kernel, a reduction kernel, controls only and no match retained their expected counts. Limits-only mode checked all eight launches.Not run to completion The full Metal numerical suite was stopped after compiler calibration. The filtered device suite ran every changed handoff kernel. The local glm metal: one arithmetic order for prompt windows, chunks and decode on M1-M4 (#743) #2128 composition was built and host-tested. Its unpaired path still needs an on-device inference comparison if the changes land together.
Receipt
mainat948e74858. Rank 1 failed withPeerSilentat exchange 2, and rank 0 did not become ready within 65 seconds with tracing off. The patched rank 0 became ready in 21.126 seconds and served requests. Both runs used the same Studios, checkpoint, MCDMA library and 66,560-token context, with the prompt cache disabled and tracing off. The startup failure prevented measuring baseline decode throughput or cold prompt time to first token at any width.26B118, one Thunderbolt 5 link, and Zig0.17.0. Checkpoint and integrated MTP weights fromTensorFold/GLM-5.3-Flash-MLX-4bit-MTPrevisiond2b17f5253440224422b150705c1109a9a3a0368. Both ranks used the same MCDMA dylib SHA-256ae63dd35624573a647d8fd23b0a29c436a5d3d3de97d40c29d880ce179ac7679. The original Studio inference benchmark used binary SHA-25654594cc1ec9d2d46d4da484e7b64bd2b3747de58ac1118262a9fcbfaf50f7aa8, built on948e74858with this production diff.EpTransferTimeoutat exchange 183. The stalled rank reported the timeout before the native call returned. Both ranks exited without a GPU watchdog. A fresh pair answeredBANANA,42, andblueand completed 1,502 exchanges on each rank. That run predatescf2c65bd3.cf2c65bd3Same Studios, checkpoint and MCDMA library, with a test-only shim that re-exports the MCDMA library and holds rank 1's 183rd payloadmcdma_fabric_write_signalcall for 1.6 s. Rank 1 reportedEpTransferTimeoutfor exchange 181 after 1.001 s, before the stalled call returned. Rank 0 accepted that late payload, then reportedPeerDownat exchange 182 when rank 1 closed the link. Both exited with status 1 about 2 s after the stall began, without a GPU watchdog. A fresh pair answeredBANANA,42, andBlue, each rank completed 29,460 exchanges, and both stopped with status 0 on SIGTERM.cf2c65bd3WithGLM_EP_DELAY_US=1500000on rank 1, each prompt-chunk send over 1 MiB waited 1.5 s. The pair completed all 180 held exchanges and answered a 392-token prompt withBANANA. The previous 1 s budget would have failed the first held exchange. WithGLM_EP_DELAY_US=12000000, both ranks' command buffers failed withkIOGPUCommandBufferCallbackErrorTimeoutabout 5 s into the first hold, before the 10 s arrival limit. Both reportedGpuFailedand exited with status 1. On these Macs a peer more than about 5 s late therefore ends the pair through the GPU timeout rather thanPeerSilent.The public receipt preserves exact prompt fixtures, full output IDs, cache counts, timing data and settings. Download both files into the same folder and run
python3 verify_studio.pyto verify the comparisons and reproduce the medians. Raw Studio receipt · Verification scriptDecode and cold prefill
Median of three runs per cell with tracing off and the prompt cache disabled. Decode uses 256-token replies across public repository fixtures. Aggregate decode is the total tokens after each stream's first token divided by the time between the first and last emitted tokens across the group. Cold prefill reports client time to first token and uses 16-token replies. Every cold run reported zero cached prompt tokens.
To reproduce startup on each rank, build with
zig build native -Dcpu=apple_m1, then use the same checkpoint and the respective rank's settings file. Start rank 1 before rank 0.For the timing and equality measurements, stream the same requests through rank 0 with
draftset totrueandfalse, and compare the full output IDs alongside the token SHA. For cold prefill, send exact-length token-ID prompts with a fresh KV cache for each request. For cache replay, enable the default prompt cache and repeat the same chat prefix.Kernel contract
ep_pack,ep_unpack,ep_rcombine,ep_rfinal,ep_rsend,ep_rsum,ep_amax_send, andep_amax_mergereplace their same-named flag-based implementations. Cases exercise live and stale epochs, repeatability, guarded buffers, non-finites, launch shapes, and FP32 accumulation and BF16 rounding where applicable.zig build tf-kernel-contract -Dcpu=apple_m1andtf-kernel-contract --only 'metal glm ep'. The M4 run also used--offlineto check M1/M2 launches.25G241. M1 and M2 launch limits were checked offline with Xcode 26.6 and Apple Metal 32023.883. Live execution on M1, M2, and M3 was unavailable.M4 Pro rerun at
27ddaf316, exit 0M4 Pro rerun at
cf2c65bd3, exit 0Checklist
mainreproduced the startup failure. On this patch the Studio smoke test passed, all eight Metal probes passed, and all eight low-word epoch mutations failed their intended checks. The new probes bind the new shader ABI, so their negative GPU evidence comes from the planted mutations."draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampledmainat90b4fae6on the same Studios and checkpoint. The default TP2 split at a 66,560-token context andGLM_EP_SPLIT=expertsat an 8,192-token context both connected and then reportedPeerSilenton rank 1 at exchange 2. Both ran with tracing off and the prompt cache disabled. Rank 0 reached neither HTTP readiness deadline of 65 s. The table reports candidate timings. A relative performance result needs a pair on which pristinemainserves the same workload.--drafterand positive temperature do not apply.