Repository navigation
Conversation
|
Independent device run at The exact head merges cleanly with After the DFlash2 merge, this head conflicts with Igor Lessio - AIFLOW LABS |
|
Thanks @gilby. Fusing the 8-bit/64 shared expert into the 4-bit/64 routed MoE reads correct: uniform 4-bit/64 layers keep their pipelines, the mixed layers match The GLM DFlash2 work that landed on main conflicts with this branch in two places. We're rebasing it ourselves, keeping your commit as it is, and then running it on our M5 Ultra and M3 Ultra Macs. We'll post the results here.
|
c14a50c to
e003903
Compare
Extend the fused Metal MoE gather/down kernels (moe_gateup_0_sh8, moe_down_0_sh8, _one, and _pick) via uint4 8-bit/64 shared-expert loads so mixed 4/64 routed + 8/64 shared layers stay on the single fused path instead of falling back to unfused wide launches. Includes M1/M2 512-thread reservation, contract gates/controls/records, and bit-exact parity unit test. Refs ashhart#3152
e003903 to
9d2bcbc
Compare
|
I checked current heads In a scratch resolution I kept both families’ registrations and tests, assigned KVB8 jobs to slots 27–29 and SH8 jobs to 30–35, and left the optional M3 job last at 36. On M5 Max with Zig 0.17.0,
The combined Igor Lessio - AIFLOW LABS |
What this changes
Extends the fused Metal
4/64MoE gather/down kernels (glm_moe_gateup_0_sh8,glm_moe_down_0_sh8,_one, and_pick) withuint48-bit/64-group shared-expert loads so mixed4/64routed +8/64shared layers stay on the single fused MoE launch (both+combine_0) instead of falling back to unfusedwide.moelaunches.Adds
sh8Sourceinzig/src/families/glm/kernels.zig(with[[max_total_threads_per_threadgroup(512)]]on thegateupkernels so M1/M2 offline limits match the runtime dispatch max of 512 threads) and loads the 6sh8pipelines alongsidemoe_gateup_0*/moe_down_0*.Adds
shared8/canBothand fusedsh8dispatch inzig/src/families/glm/moe.zig.Registers
glm sh8contract launches, planted controls, M1/M2 offline records (zig/src/core/contract/glm_sh8_records.zig), and bit-exact parity testzig/src/families/glm/sh8_moe_test.zig.Issue: Refs GLM-5.3-Flash on Metal: decode and prompt speed on M5 Ultra, token-exact (baseline, items and gate) #3152
Stacked on:
main(4c616e63d57204cd8395dc3af9b572d9ec49626b)atc overlap --base origin/main --json:9changed files;6clean PR overlaps,4older conflicting PRs (#1835,#2239,#2273,#2634),5unknown.Checks on this head
59ffca4bb0b6cf3bc70f422f862fa3461d9b88a4python3 tools/zig/lean_check.py, on the base and on this head:168on base (4c616e63d),168on head (59ffca4bb),0new findings (python3 tools/pr_check.py --base origin/mainexits0).main(4c616e63d):shared8andsh8_moe_testare absent onmain, where8/64shared +4/64routed experts fall back to unfusedwide.moe+moe_combineinstead ofboth(canBothis false);sh8_moe_testfails onmainbefore the change and passes bit-for-bit after.59ffca4bb, 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 (sh8_moe_test.zigbit-for-bit againstwide + moe_2) —All 185 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 sh8" --offline ...— passed (PASS limits: 6 selected registered Metal launches against M1-M5, 0 problems; all 6 M1/M2 offline limits pass:512/512,896/896,512/512,832/832,512/512,896/896; both limit controls red)./zig-out/bin/tf-kernel-contract --only "glm sh8"on Apple M5 Ultra (applegpu_g17,therm=0) — exited0(details below)--offlinelimits); CUDA/ROCm paths (Metal-only change).Receipt
Full scrubbed receipts (contract log,
bench_concurrent.py,bench_openai.pyonoq071andMLX-4bit-MTP): https://gist.github.com/gilby/1907aac455d0a30d460938b4a4cb37034c616e63d) against branch (59ffca4bb), same Apple M5 Ultra (256 GB) andGLM-5.3-Flash-oQ4e-mtp-oq071checkpoint (8/64shared +4/64routed experts),--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 every cell):main(4c616e63d)S3(59ffca4bb)mainsteadyS3steadycode 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):oq071mainoq071S3MLX-4bit-MTPmainMLX-4bit-MTPS3fibonacci-raw T=0.0gpu-chat-no-think T=0.0fibonacci-raw T=1.0gpu-chat-no-think T=1.0glm5_nexton Metal (4/64routed +8/64shared single-Mac decode/verify path); uniform4/64(MLX-4bit-MTP) unchanged.59ffca4bb0b6cf3bc70f422f862fa3461d9b88a4atopmain4c616e63d57204cd8395dc3af9b572d9ec49626b0.17.0(-Dcpu=apple_m1), macOS Metalapplegpu_g17, 256 GB unified memory, tensor units true)GLM-5.3-Flash-oQ4e-mtp-oq071(8/64shared +4/64routed) andTensorFold/GLM-5.3-Flash-MLX-4bit-MTPoq071andMLX-4bit-MTP), bit-exact parity unit test, host/golden tests, Metal contract + M1/M2 offline limits.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:bench_concurrent.py --alone --serialonoq071:0unequal and0failed across everyalone(concurrent == alone) andserial(drafted == "draft": false) comparison.bench_openai.py:12/12replytoken_sha256s bit-identical tomainon bothoq071andMLX-4bit-MTP.Kernel contract, only when a GPU kernel is new or changed
glm_moe_gateup_0_sh8,glm_moe_down_0_sh8,glm_moe_gateup_0_sh8_one,glm_moe_down_0_sh8_one,glm_moe_gateup_0_sh8_pick,glm_moe_down_0_sh8_pick— replaces separatewide.moe(glm_rows_q8) +moe_2(moe_gateup_2/moe_down_2) for8/64shared +4/64routed MoE layers (bit-equal output tomoe_2_and_wide_q8).zig/src/core/contract/glm_sh8_records.zig,zig/src/core/contract/registry_joins.zig,zig/tests/contract/metal_glm_sh8.zig,zig/tests/contract/metal_limits.zig, andzig/tests/contract/metal_main.zig.control: glm sh8 fused MoE takes shared slot one early(FAIL shapes)control: glm sh8 pick takes wrong routed expert(FAIL shapes)tf_row_projection_q4_f32(2 limit problems),36 KiB tf_ctl_big_tg(8 limit problems);6 selected registered Metal launches against M1-M5, 0 problemsSUMMARYline and exit status:applegpu_g17, tensor units true):SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 1144 ms, limits 40 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