Repository navigation
Conversation
|
Decode check against #601 on the same pair and checkpoint, at this head (
Not isolated: macOS 27.2 against 27.0, and the shared-event handoff against the in-kernel wait, which cannot run on these machines. The summary prompt is a licence-text summary, since #601's prompt is not published. Posting in case the per-exchange cost is useful for the fix planned in #3158. |
|
Thanks @jcscocca. The separate send and arrival budgets, full-width epoch guards and joined cleanup look sound. The 19 transport tests, GLM host checks and macOS compile checks pass, with no new lean findings. Removing the admission guards also makes the expired-send test fail as expected. This now waits on the focused M5 kernel check; we will run the device check on our side. No source changes requested from you. We’ll track the historical summary-decode gap separately, since the different OS and prompt do not establish a matched performance regression.
|
Independent short-run confirmation on two M5 Ultra StudiosThanks @jcscocca for this patch. We built and tested PR head
This is a bounded independent inference smoke test, not a focused M5 kernel-contract/fault-injection result, a long-context reliability result, or a matched one-/two-Mac speedup measurement. We did not rerun a matched pristine-main control, so this is confirmation of successful operation at the tested PR head, not an independent isolation of the defect's cause. Higher-input and substantive repeatability/benchmark tests remain outstanding. |
|
@jcscocca, the focused M5 Ultra check passes at this head: all eight changed kernels pass gates 1-4, all eight planted controls are caught, and there are no limit problems. The 19 transport tests pass too, along with 451 host tests and the Metal compile checks; one host test is skipped. There are no new lean findings. This settles the local kernel check we promised. We did not rerun a two-Mac pair, so real-link fault, late-peer, cleanup/restart and served-token checks keep their separate receipts. Exact-head CI still needs confirmation before landing.
|
|
@ashhart, thanks for running the M5 Ultra kernel check. On the two things you left with me: Checks at this head, run locallyThe hosted workflows for
One real problem turned up. This change breaks the build of Not run: the Windows job, and the Linux steps on x86_64. Exact-head CI on the hosted runners is still needed. Pair receipts at this headThe fault, late-peer and restart runs in the description were made at this head on 13 November; their rank logs are in the attached The served-token check at this head covered one stream only, so I ran the missing part today on the same pair, checkpoint and binary (
Not rerun today: the injected stall and the two late-peer cases. Their receipts are the 13 November logs, one run each. Those logs show the stall line, the errors, the exchange counts and the exit statuses, but they do not record the |
|
Thanks @jcscocca, and good catch on Main has moved since your base, so the branch needs a rebase:
Once the rebased head is up, please mark the pull request ready for review. We'll approve the fork workflows then, and landing waits on green CI for that head. Thank you for the eight-stream served-token run and the receipts bundle. They answer the exactness question we had left open at this head.
|
cf2c65b to
2181902
Compare
|
@ashhart, rebased onto Resolutions, all in the first commit; the other four apply unchanged:
Run locally at the new head on an M4 Pro: format, lean check (0 new),
Marked ready for review. I'll rebase #3380 onto this head next. |
|
Thanks @jcscocca for the quick rebase and the separate stand-in commit. All three asks from our last comment are resolved at this head:
The patch applies cleanly to current main, every touched file is under 600 lines, and the unpaired path only threads the encoder through What remains:
Landing also waits on green CI for this exact head.
|
|
I reran the exact zig build test-metal-residency-owners-host test-glm-expiry \
test-glm-scheduling-host -Dcpu=apple_m1 -j5 --summary all
zig build tf-kernel-contract -Dcpu=apple_m1 -j5 --summary all
zig-out/bin/tf-kernel-contract --only 'metal glm ep'The Metal contract run passed all eight exchange kernels, eight planted controls and the launch limits. This used one Mac and covers the kernel and transport fixtures. The live pair and one-Mac inference comparisons Ash asked for remain open. The trial merge into Igor Lessio - AIFLOW LABS |
2181902 to
7830de0
Compare
|
I trial-merged the current head I restored the same three-line method from the previous head inside pub fn dispatchType(_: @This()) DispatchType {
return .serial;
}Rerunning the command below passed all 13 build steps, including all 76 residency-owner tests. The 92 scheduling and expiry tests were cached from the preceding run on the same trial tree. zig build test-metal-residency-owners-host test-glm-expiry \
test-glm-scheduling-host -Dcpu=apple_m1 -j3 --summary allIgor Lessio - AIFLOW LABS |
The GLM exchange handoff reopens an encoder with the closing one's dispatch type, so the recording Metal fake needs it to compile test-metal-residency-owners-host.
|
@jcscocca Our earlier rebase of this branch dropped three of your commits: the shared GLM exchange probe, the separate send and peer-arrival deadlines, and the recording mock's
|
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.mainataf9777b4945a03be8266d6fe925e577bd62f32e7. The rebase keeps main's stored MTP draft head and passes the encoder through*Passin the affected GLM callers.writeSignalFromandsignalrecheck the deadline after acquiring the port lock and returnTimeoutbefore entering the native transport if it has expired. FlashNext TP andcore/pair.zigalso use these transport paths.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 ontomainas ofbafe3e07c. 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
2181902265d563b889fdb650da709cfdeab8fd28.zig build native -Dcpu=apple_m1passed 66/66 steps with Zig 0.17.0 and Xcode 27.2 on an M4 Pro.test-metal-residency-owners-hostpassed 76/76, and the server build passed 297/297 steps. The lean checker found 221 findings on both base and head, with zero new findings.Earlier checks
Relay deadline check at
cf2c65bd3e562b9cfd621f56b8af6c45a71bfc3fThat follow-up split 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.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
Paired GLM-5.3-Flash at
2181902265d5I reran the native Metal pair on two M5 Ultra Macs over Thunderbolt. Both ranks loaded the stored MTP head.
The run used checkpoint
TensorFold/GLM-5.3-Flash-MLX-4bit-MTPrevisiond2b17f5253440224422b150705c1109a9a3a0368, an 8,192-token context, temperature 0, and the prompt cache off.The 18 requests each returned 96 tokens. All 15 comparisons matched the full token IDs and hashes. Solo drafted replies and all eight requests in the concurrent drafted batch matched the corresponding solo
draft: falsereplies. Each prompt also matched on a second one-stream drafted request. The concurrency client repeated the Rust fixture at width 1. The drafted replies recorded accepted draft tokens. Both ranks stopped cleanly.bash-line-count02f595095c08715c2bb305745d276024696602fd9d153cfe7a200cd112431cc3fishing-village3618e910f0443528a8725ced0b3cb873b309708d0536175584c453f446d99f17rust-reverse-words96888a0500c5db5acc6560958b16f4c39f260651f13d2f8eb7cca2dafd7d2013Unpaired GLM-5.3-Flash on one M5 Ultra
I ran each baseline and the PR on the same 256 GiB Mac Studio with macOS 27.2 build
26B118, the same pinned checkpoint, an 8,192-token context, one stream, temperature 0, seed 1234,draft: false, and the prompt cache off. The default memory limit left the MTP head on disk in these one-Mac runs. Each comparison used four fresh server starts in main–PR–PR–main order and two measured repeats per fixture per start.All 16 matched samples against the rebase base and all 16 against the newer
mainsnapshot returned identical token IDs. Decode is the median server rate over twelve 128-token replies per build across three prompts. Prefill is the median server time over four uncached 2,048-token requests per build.af9777b4945ae5ea8a6065bcDecode samples ranged from 77.55 to 77.79 tok/s on the rebase-base baseline and from 51.18 to 77.83 tok/s on the PR.
Decode samples ranged from 77.51 to 77.68 tok/s on the upstream-main baseline and from 51.90 to 77.78 tok/s on the PR.
Two PR replies decoded at about 51–52 tok/s on separate server starts. Dividing total decoded tokens after the first token by total server decode time gives 77.69 tok/s on the rebase base and 74.46 tok/s on the PR. Against the newer snapshot, the rates were 77.59 and 74.39 tok/s. The PR's pooled rate was about 4.1% lower in each set. The stalls' cause remains unconfirmed.
quicksort-raw13cd8eed670c183b78958f975db115c38faad6e771582b0c97117d2c29333377fishing-villagef6aa01705f48237bec6696b3f03d6af95cfba35fafbc5ce096cb76a11573ff10rust-reverse-wordsee82b90142ff9c1b4b30b90ccaf3badea55044f6db877e331fb715a85e0d3fc8raw-20485a9eddd69c0315ae7202dc5091c24d7dc9eb88cfdaed1157814989ebe360b33aLonger unpaired run against the rebase base
I alternated the same two binaries across eight server starts with five repeats per fixture per start. I rotated fixture order and sampled host counters around each request. All 80 matched samples returned identical token IDs.
Across 60 128-token replies per build, median decode was 77.33 tok/s on the base and 77.31 tok/s on the PR. Pooled decode was 74.70 and 72.95 tok/s, respectively (-2.35% on the PR). With a slowdown defined as at least 20% more decode time than the base median for that fixture, there were 4 such replies on the base and 7 on the PR. For 20 uncached 2,048-token requests per build, median prefill was 1.2295 s on the base and 1.2294 s on the PR.
Median server CPU time rose from 0.08 to 0.93 s on slower base replies and from 0.08 to 0.90 s on slower PR replies.
Pageout and swap counters stayed flat around those replies.
Randomized one-stream decode rerun
I reused the same base and PR binaries and the same Studio. I randomly assigned first-run order within eight pairs of fresh server starts, with four pairs starting on each build. Each start ran three repeats of the three short decode prompts with the settings above and EOS ignored for a fixed 128-token reply. Every reply matched its reference IDs.
Median decode was 77.46 tok/s on the base and 77.40 tok/s on the PR. Pooled decode was 76.30 and 73.05 tok/s, respectively (-4.26% on the PR). Using the earlier base's per-fixture medians and the same 20% decode-time cutoff, 2 of 72 base replies and 8 of 72 PR replies were slow. Mean decode time was higher on the PR in all 8 pairs. The two-sided paired randomization test for mean decode time gave
p = 0.029across the 70 balanced start-order assignments. The analogous test on stall counts gavep = 0.086.Separate diagnostic builds captured a 0.818 s wait on the base and a 0.842 s wait during PR warmup after a Metal command buffer had been committed and before it started on the GPU. The stall occurs on both builds.
Follow-up unpaired production reruns
I reused the uninstrumented binaries at
af9777b4945a(main before this PR) and2181902265d5(PR). Each comparison used the same machine, checkpoint, one-stream settings, and three short fixtures described above. The original Studio ran three balanced blocks with one fresh start per condition in each block (base, PR, and PR with residency disabled). The second Studio repeated the eight randomized pairs. The table shows default residency in both builds. All generated token IDs matched their references.Both reruns used the original per-fixture stall cutoff of at least 20% above the earlier base median decode time and excluded warmups. Median prefill differences across the three short fixtures were at most 1.4 ms on the original Studio and about 0.2 ms on the second.
The unmodified main binary stalled on both Studios, so the stall predates this PR. The earlier 4.26% pooled decode drop and higher PR stall count did not recur in either production follow-up. Additional diagnostic builds with default residency stalled on 5 of 32 measured replies on each build. The long delays appeared in CPU-side Metal scheduling of the first decode command buffer, around 0.8–1.05 s. The trigger remains unresolved.
The full fix for the shared stall is tracked in #3902. The broader performance checklist item remains open.
Earlier Studio receipts
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.