Repository navigation
GLM-5.3-Flash: end the last expert's sorted pairs at the pair count - #864
Conversation
…count glm_rows_sorted read each expert's end as offsets[e + 1], but the route's sort writes one offset per expert, so the last expert's run ended at the buffer's spare word, which nothing writes, and its pairs were skipped. Prompt chunks take this kernel unless a layer's routed gate, up and down are all 4-bit or all 2-bit at group 64, so long prompts on a checkpoint with 5- or 6-bit routed experts went wrong. The kernel ends the last expert at the pair count, as the affine_mm gathers do, and the offsets buffer drops its spare word. tf-glm-rows-check lays out the offsets the way the route writes them, so it fails on the old kernel and passes on this one.
|
Thanks, @harrisonfriia. Ready at 09b9df6. |
…lm_rows_check.zig) Layout only, by zig fmt after closing commas.
|
Thank you, @harrisonfriia. Finding that the last expert's end was a word the sort never writes, and that only checkpoints with 5- or 6-bit routed experts reach that kernel, explains the empty replies past 12,000 tokens, and your receipt shows it from both sides. Your commit ships in TensorFold 1.0.12 as it is, merged in
Posted by Ash's AI Assistant Synthena |
… pairs at the pair count
….zig, glm_rows_check.zig) Layout only, by zig fmt after closing commas.
…shhart#862, ashhart#863, ashhart#864, ashhart#866, ashhart#821, ashhart#822, ashhart#823, ashhart#851, ashhart#738, ashhart#523, ashhart#547 and ashhart#875, with the HIP and loader fixes
What this changes
glm_rows_sortedskipped the last expert's pairs on prompt chunks. It read that expert's end fromoffsets[e + 1], a word the route's sort never writes (prefill/sort.metal:44). It now ends the last expert at the pair count, as theaffine_mmgathers do, and the offsets buffer drops the unwritten word.Only layers whose routed experts aren't all 4/64 or all 2/64 use this kernel, so the 4-bit checkpoint never hits the bug. Checkpoints with 5- or 6-bit routed experts do. On the checkpoint below, main returns empty replies from 12K tokens up.
Receipt
c7137bb3, candidate09b9df6f. M3 Ultra (80-core GPU, 256 GB), macOS 27.0.1, Xcode 27.0, Zig 0.17.0, no MLX or PyTorch.ddalcu/GLM-5.3-Flash-MLX-Serve-iQ-MLX-5.1bpwat2b1c4539, with 5- and 6-bit routed experts in layers 3 to 26. Served withGLM_LOAD_LIMIT_GB=215,--parallel 3,--temperature 0.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:bench_concurrent.py --levels 3 --temperatures 0 --alone --serial, base and candidate alike: 9 of 9 concurrent replies equal their request alone, and 1 of 1 alone reply equals"draft": false.bench_cache.pyon 8K-, 12K- and 20K-token prompts: on the candidate, both repeats and all 3 concurrent copies have the first reply'stoken_sha.tools/bench_openai.py: n/a, decode doesn't use this kernel.ttft_sfromtools/bench_cache.py --require-cold. At 8K tokens, 37.1 s on base and 37.2 s on the candidate. At 12K and 20K tokens, base streams no text, so it has nottft_s; the candidate's are 57.7 s and 97.1 s.temperature0: on a 22,048-token prompt, a 13,768-token prompt and a follow-up that resumed 13,766 tokens from cache, base returned empty content all three times. The candidate answered all three about the prompt's code.tf-glm-rows-checknow lays out the offsets the way the route writes them. It passes on the candidate (8,909,088 bit-equal pairs) and fails withBitsDifferon main's kernel.zig build test test-golden -Dcpu=apple_m1, base and candidate alike: 164/164 steps, 1,981 of 1,989 tests passed, 8 skipped. Goldens 309/319, 0 unexpected.lean_check.pyreports 527 problems, the same as base.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.