Repository navigation
Conversation
|
I cross-checked the device receipt on M5 Max with Zig 0.17.0 at The head merges cleanly with After the DFlash2 merge, I trial-merged this head with I combined The combined M5 tree passed 82 host tests and the restore compile. The existing Igor Lessio - AIFLOW LABS |
|
Thanks @gilby. The fused MTP prep norms and the 4-bit/64 greedy head with top-1 read exact: your One question before we run it: in your The GLM DFlash2 work that landed on main conflicts with this branch in four files. We're rebasing it ourselves, keeping your commit as it is.
|
6c8667a to
44f33e4
Compare
Fuse MTP embedding gather + RMSNorm + hidden RMSNorm into single-pass glm_mtp_prep_{4b,8b} and fuse 4-bit/64 vocab projection + argmax for greedy decoding into glm_head_top1_4b{_one} + glm_reduce_top1 on single-Mac TP=1 loads. Registers glm mtp contract gates/controls/records and Metal parity tests.
Refs ashhart#3152
44f33e4 to
0f64171
Compare
|
I rechecked the rebased On M5 Max with Zig 0.17.0, all 287 host checks passed. The Metal run passed 3 kernels, caught 6/6 planted controls, and reported zero limit problems. zig build tf-kernel-contract test-kernel-contract -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j4 --summary all
./zig-out/bin/tf-kernel-contract --only 'glm mtp'The requested alternating Igor Lessio - AIFLOW LABS |
|
I checked the red hosted jobs for The same published head trial-merges cleanly into Igor Lessio - AIFLOW LABS |
|
Re-ran the requested alternating 1. 4-pair alternating
|
| Cell | Metric | b6701e51d5 (4 runs, min..max) |
Med | 0f641719d9 (4 runs, min..max) |
Med | Paired deltas | Paired med |
|---|---|---|---|---|---|---|---|
code T=0.0 N=3 |
steady_tps |
185.5, 185.1, 185.0, 185.2 |
185.15 | 183.9, 183.6, 183.7, 184.0 |
183.80 | -0.86%, -0.81%, -0.70%, -0.65% |
-0.76% |
code T=0.0 N=3 |
aggregate_tps |
181.7, 181.4, 181.3, 181.5 |
181.45 | 180.2, 180.0, 180.0, 180.3 |
180.10 | -0.83%, -0.77%, -0.72%, -0.66% |
-0.74% |
chat T=0.0 N=3 |
steady_tps |
163.5, 163.1, 163.2, 163.3 |
163.25 | 163.0, 162.8, 162.6, 162.9 |
162.85 | -0.31%, -0.18%, -0.37%, -0.24% |
-0.28% |
chat T=0.0 N=3 |
aggregate_tps |
155.8, 155.4, 155.5, 155.5 |
155.50 | 155.3, 155.1, 155.0, 155.2 |
155.15 | -0.32%, -0.19%, -0.32%, -0.19% |
-0.26% |
code T=1.0 N=3 |
steady_tps |
130.6, 130.2, 130.7, 130.7 |
130.65 | 129.7, 131.9, 129.7, 129.0 |
129.70 | -0.69%, +1.31%, -0.77%, -1.30% |
-0.73% |
code T=1.0 N=3 |
aggregate_tps |
122.3, 117.6, 123.3, 122.4 |
122.35 | 124.6, 122.5, 123.0, 123.8 |
123.40 | +1.88%, +4.17%, -0.24%, +1.14% |
+1.51% |
chat T=1.0 N=3 |
steady_tps |
121.2, 121.3, 121.4, 121.5 |
121.35 | 121.6, 121.3, 121.2, 121.7 |
121.45 | +0.33%, +0.00%, -0.16%, +0.16% |
+0.08% |
chat T=1.0 N=3 |
aggregate_tps |
112.0, 111.5, 109.0, 112.1 |
111.75 | 112.7, 111.3, 111.8, 111.5 |
111.65 | +0.63%, -0.18%, +2.57%, -0.54% |
+0.22% |
Both greedy N=3 cells are slower across all 4 pairs with non-overlapping spreads, so keeping glm_head_top1_4b for multi-row launches does not pay off.
2. Follow-up commit 5487627791: restrict fused greedy head+top1 to rows == 1
zig/src/families/glm/kernels.zig: gatedcanHeadTop1torows == 1, simplifiedheadTop1_4bandHeadTop1Argsto dispatch onlyglm_head_top1_4b_one+glm_reduce_top1, and removed the deadhead_top1_4bpipeline compilation.zig/kernels/metal/glm_mtp_opt.metal,zig/src/core/contract/glm_mtp_records.zig,zig/tests/contract/metal_glm_mtp_opt.zig,zig/src/families/glm/mtp_opt_test.zig: dropped the unreachable multi-rowglm_head_top1_4bentry point and updated limits, contracts (with Gate 1.nonfinitestepping per-row oversmall(..., 5, 8)), and unit/Metal parity tests (glm_mtp_prep_4b+glm_head_top1_4b_one).
3. 2-pair alternating N=1,3 verification with the rows == 1 gate (b6701e51d5 vs gated binary, order base, gated, gated, base)
Run on the same idle Apple M5 Ultra (applegpu_g17, GLM-5.3-Flash-MLX-4bit-MTP, therm=0, 0 failed/unmeasured, 0 alone/serial unequal checks, identical greedy token_sha256 across all runs/reps) against the 1-row-gated build executing the exact same dispatched glm_mtp_prep_4b, glm_head_top1_4b_one, and glm_reduce_top1 kernels before deleting the unreachable multi-row entry point:
| Cell | Metric | b6701e51d5 (v1, v4) |
Med | rows == 1 (v2, v3) |
Med | Paired deltas | Paired med |
|---|---|---|---|---|---|---|---|
code T=0.0 N=1 |
aggregate_tps |
108.3, 108.1 |
108.20 | 108.4, 108.4 |
108.40 | +0.09%, +0.28% |
+0.18% |
code T=0.0 N=3 |
steady_tps |
185.3, 185.2 |
185.25 | 185.2, 185.0 |
185.10 | -0.05%, -0.11% |
-0.08% |
chat T=0.0 N=1 |
aggregate_tps |
88.0, 88.1 |
88.05 | 87.9, 86.8 |
87.35 | -0.11%, -1.48% |
-0.79% |
chat T=0.0 N=3 |
steady_tps |
163.3, 163.2 |
163.25 | 162.9, 163.0 |
162.95 | -0.24%, -0.12% |
-0.18% |
code T=1.0 N=1 |
aggregate_tps |
121.5, 121.5 |
121.50 | 121.7, 121.6 |
121.65 | +0.16%, +0.08% |
+0.12% |
code T=1.0 N=3 |
steady_tps |
130.2, 129.2 |
129.70 | 131.3, 129.8 |
130.55 | +0.84%, +0.46% |
+0.65% |
chat T=1.0 N=1 |
aggregate_tps |
82.6, 81.7 |
82.15 | 83.0, 82.8 |
82.90 | +0.48%, +1.35% |
+0.92% |
chat T=1.0 N=3 |
steady_tps |
121.9, 121.1 |
121.50 | 121.3, 121.5 |
121.40 | -0.49%, +0.33% |
-0.08% |
code T=0.0 N=3steady delta dropped from-0.76%(-1.35tok/s) to-0.08%(-0.15tok/s,aggregate_tps-0.06%).- On
chat T=0.0 N=1,v3dipped to86.8(rep_agg=[86.81, 88.21, 86.83]vsv1 [88.02, 88.04, 86.54],v2 [88.18, 87.92, 87.91],v4 [88.18, 88.12, 88.12]) due to the discrete adaptive depth-schedule transition (tokens_per_chunk=1.842,serial.accepted=120vs1.766/112onv1/v2/v4), with identicaltoken_sha256throughout.
Checks on 5487627791
./zig-out/bin/tf-kernel-contract --only "glm mtp":SUMMARY 3 kernels: 3 pass gates 1-4, 0 fail, 0 known findings; 6 controls: 6 red as planted, 0 missed; 0 limit problems;PASS limits: 4 selected registered Metal launches against M1-M5, 0 problems.zig build tf-kernel-contract test-kernel-contract test-glm-kernel-ownership-host test-glm-scheduling-host test-glm-prefill-widths-host test-metal-residency-owners-host test-metal-runtime-source-modes-host --summary all:101/101 steps succeeded.- Compiled engine test suite (
tensorfold.zig):1325 passed; 14 skipped; 1 failed—0families.glm.*failures, bothfamilies.glm.mtp_opt_test.test.*checks (tryHeadTop1single-row admission andglm_mtp_prep_4b/glm_head_top1_4b_oneMetal parity) passedOK(the lone failure is pre-existing unrelatedfamilies.deepseek_v41.metal.vision.test.the release's vision_config parses to the defaultsreturningerror.ZeroHeads). zig build native -Doptimize=ReleaseFast -Dcpu=apple_m1:66/66 steps succeeded.zig fmt --check build.zig zig,git diff --check origin/main...HEAD,python3 tools/pr_check.py --base origin/main(0 error(s),lean 165 vs 165, 0 new): passed.
What this changes
Fuses the GLM-5.3-Flash MTP preparation step (
embedRows+enorm+hnorm) intoglm_mtp_prep_4b/glm_mtp_prep_8band fuses greedy 4-bit/64 vocab projection + top-1 argmax intoglm_head_top1_4b_one/glm_head_top1_4b+glm_reduce_top1on single-Mac (tp == 1) loads (GLM_RANKS=1preserves full logits viakeep_logits). Inzig/src/families/glm/slots.zig, single-streamdraftAllreuses the already-computediwandqr/xpslices for the absorbed row (drafting == 1) somtp.finishskips redundantx_proj/indexWeightswork while preserving exacte.sc.qrquery norms.main(4c616e63d57204cd8395dc3af9b572d9ec49626b)atc overlap --base origin/main --json:14changed files;6clean PR overlaps (#1508,#1774,#1775,#1780,#1787,#1886),4older conflicting PRs (#1835,#2239,#2273,#2634),5unknown.Checks on this head
4647eba806b59e088b70a0e17f06c53dfdff6618python3 tools/zig/lean_check.py, on the base and on this head:168on base (4c616e63d57204cd8395dc3af9b572d9ec49626b),168on head (4647eba806b59e088b70a0e17f06c53dfdff6618),0new findings (python3 tools/pr_check.py --base origin/mainexits0).main(4c616e63d5):zig/kernels/metal/glm_mtp_opt.metalandzig/src/families/glm/mtp_opt_test.zigare absent onmain(MTP always dispatches separateembed+rms+rmsandqmv+argmax).4647eba806, with the command and pass, fail and skip counts:zig fmt --check build.zig zig— passed (0exit)git diff --check— passed (0exit)families.glm.*unit tests (mtp_opt_test.zigMetal bit-parity againstembed+rmsandqmv+argmax) —All 186 tests passed.zig build test-kernel-contract test-golden test-glm-scheduling-host test-glm-prefill-widths-host check-glm-restore-host— passed (test-golden322/335&69/69,0unexpected differences)./zig-out/bin/tf-kernel-contract --no-gates --only "glm mtp" --offline ...— passed (PASS limits: 5 selected registered Metal launches against M1-M5, 0 problems, M1/M2 offline limits1024/1024/128/512/1024, both limit controls red)./zig-out/bin/tf-kernel-contract --only "glm mtp"on Apple M5 Ultra (applegpu_g17,therm=0) — exited0(details below)--offlinelimits); CUDA/ROCm paths (Metal-only kernels).Receipt
Full scrubbed receipts (contract log,
bench_concurrent.py,bench_openai.pyonMLX-4bit-MTPandoq071): https://gist.github.com/gilby/44ce40c872fb35f27fa275bc74a966ab4c616e63d5) against branch (4647eba806), same Apple M5 Ultra (256 GB) andTensorFold/GLM-5.3-Flash-MLX-4bit-MTP,--prompt-cache-gib 0 --profile stable,therm=0,tools/bench_concurrent.py --alone --serial --tokens 256 --reps 3 --temperatures 0,1.0 --levels 1,3(0unequal /0failed across everyaloneandserialcheck;timing_valid=True; identicaltokens_per_chunkacross cells):main(4c616e63d5)S4(4647eba806)mainsteadyS4steadycode T=0.0 N=1code T=0.0 N=3chat T=0.0 N=1chat T=0.0 N=3code T=1.0 N=1code T=1.0 N=3chat T=1.0 N=1chat T=1.0 N=3tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0,1.0(--prompt-cache-gib 0, median tok/s,12/12replytoken_sha256s bit-identical tomainon both checkpoints):MLX-4bit-MTPmainMLX-4bit-MTPS4oq071mainoq071S4fibonacci-raw T=0.0gpu-chat-no-think T=0.0fibonacci-raw T=1.0gpu-chat-no-think T=1.0glm5_nexton Metal (tp == 1,group == 64;glm_mtp_prep_{4b,8b}wheninject == null,glm_head_top1_4b{_one}+glm_reduce_top1on4/64greedy heads whenGLM_RANKSis unset,draftAlldrafting == 1cache reuse).4647eba806b59e088b70a0e17f06c53dfdff6618atopmain4c616e63d57204cd8395dc3af9b572d9ec49626b0.17.0(-Dcpu=apple_m1), macOS Metalapplegpu_g17, 256 GB unified memory, tensor units true)TensorFold/GLM-5.3-Flash-MLX-4bit-MTPandGLM-5.3-Flash-oQ4e-mtp-oq071MLX-4bit-MTPandoq071, Metal contract + M1/M2 offline limits, unit/golden/host tests.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:bench_concurrent.py --alone --serialonMLX-4bit-MTP:0unequal and0failed across everyalone(concurrent == alone) andserial(drafted == "draft": false) comparison.bench_openai.py:12/12replytoken_sha256s bit-identical tomainon bothMLX-4bit-MTPandoq071.Kernel contract, only when a GPU kernel is new or changed
glm_mtp_prep_4b,glm_mtp_prep_8b— replaces separateembedRows+rms(enorm) +rms(hnorm) inmtp.absorb(bit-equal toembed + 2x glm_rms).glm_head_top1_4b_one,glm_head_top1_4b,glm_reduce_top1— replaces separateqmv(qmv_head) +argmax(glm_argmax) on single-Mac4/64greedy heads (bit-equal top-1 token ID toqmv + glm_argmax).zig/src/core/contract/glm_mtp_records.zig,zig/src/core/contract/registry_joins.zig,zig/tests/contract/metal_glm_mtp_opt.zig,zig/tests/contract/metal_limits.zig, andzig/tests/contract/metal_main.zig.control: glm mtp glm_mtp_prep_4b writes into H(FAIL repeat),control: glm mtp glm_mtp_prep_4b drops tail cols(FAIL shapes)control: glm mtp glm_mtp_prep_8b writes into H(FAIL repeat),control: glm mtp glm_mtp_prep_8b drops tail cols(FAIL shapes)control: glm mtp glm_head_top1_4b writes into X(FAIL repeat),control: glm mtp glm_head_top1_4b drops tail vocab(FAIL shapes)tf_row_projection_q4_f32(2 limit problems),36 KiB tf_ctl_big_tg(8 limit problems);5 selected registered Metal launches against M1-M5, 0 problemsSUMMARYline and exit status:applegpu_g17, tensor units true):SUMMARY 3 kernels: 3 pass gates 1-4, 0 fail, 0 known findings; 6 controls: 6 red as planted, 0 missed; 0 limit problems; gates 7524 ms, limits 5 ms(exit0)--offline;metal_limits.zigchecks M1–M5 limits with0 problems); NVIDIA/AMD untouched (Metal-only change).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled