Repository navigation
GLM: run the fragment check at load - #745
Conversation
GLM's prompt kernels and decode attention take nax.h's fragment layout, as Nemotron's and Flash Next's do. Those families run frags.check at every load and stop with error.FragLayout when the layout gives wrong sums on the GPU. GLM didn't, so a GPU with a broken layout would serve wrong tokens. GLM now runs the same check right after its kernels compile.
|
Thank you, @harrisonfriia. GLM reads the same fragments as Nemotron and Flash Next, so it should stop on the same check, and now it does. Your commit landed in 1.0.9 under your name ( On an M3 Ultra, GLM-5.3-Flash 4-bit with 8 of its 45 layers (
On two M5 Ultras, the whole model loaded through the check on both Macs, and every reply equalled 1.0.8's, with the same prompt resumes. We didn't run GLM on a single M5 Ultra for this release; the 1.0.9 notes say so. One thing we noticed, not for this PR: the EXLR8 GLM path ( |
What this changes
GLM's prompt kernels and decode attention use
nax.h's fragment layout: simdgroup matrices before M5, and tensor units on M5. Nemotron and Flash Next verify that layout withfrags.checkat every load, but GLM doesn't.This runs the same check right after GLM's kernels compile. A GPU whose layout gives wrong sums now fails the load with
error.FragLayoutinstead of serving wrong tokens. On a GPU that passes, the load adds one small dispatch.Part of #743.
Receipt
0efbd44, candidated5500d6. Zig 0.17.0, native Metal, no MLX or PyTorch, Xcode 27.0 (Metal 32023.921). M3 Ultra (80-core GPU, 256 GB, macOS 27.0.1). CheckpointTensorFold/GLM-5.3-Flash-MLX-4bit-MTPatd2b17f5253440224422b150705c1109a9a3a0368.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:token_shafromtf-glm-runwithGLM_DEPTHS=0,3and 256 tokens on the four promptstools/zig/glm_ref.py --long 2048writes (story,code,facts,long2048). Every candidate reply equals base token for token at both depths, and depth 3 equals depth 0:734d8ccb649bc216,1fee24201b70a4b2,b68f3ad0f0a28070,9f6599659a2baa06.tools/bench_openai.py:--tokens 256 --reps 3 --temperatures 0againsttensorfold-native serve, median tok/s base then candidate:fibonacci-raw74.4 and 74.4 (runs 74.4 to 74.5, and 74.4 to 76.2),gpu-chat-no-think67.6 and 68.6 (runs 67.6 to 68.4, and 67.6 to 68.7). The difference is within the runs' spread.tools/prefill_cold.py: not run. The change touches no prompt code, andtf-glm-runread the 2,048-token prompt in 3.99 s on both builds. Load time, one load each:tf-glm-run29.8 s and 29.7 s, the server 32.4 s and 32.5 s.zig build test test-golden -Dcpu=apple_m1: 1,505 passed, 0 failed, 8 skipped, the same as the base. 158 of 160 steps succeed. The failing step fails on the base too:core.checkpoint_metal's split-checkpoint test passes but logscheckpoint tensor text.weight stays in its file: read it through a Stage. Goldens: 309/319 equal to the frozen answers, 10 declared differences, 0 unexpected.zig build native -Dcpu=apple_m1 -Dversion=1.0.0builds.zig fmt --check build.zig zigis clean.python3 tools/zig/lean_check.pyreports 539 problems, the same as the base, all inherited.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Drafted and plain replies are in the receipt; resume and concurrency code is unchanged.frags.check's own.