GLM 5.3 Flash: Metal resident-Q2 prefill −6–8% from 0e9cc2d (attention masking fix), measured on M5 Max
Setup: MacBook Pro M5 Max 128 GB, GLM-5.3-Flash-Q2.gguf (resident, --warm-weights),
ds4-server --ctx 393216 --vision GLM-5.3-Flash-Vision-Encoder.gguf --kv-disk-dir ... --kv-cache-cold-max-tokens 393216,
server chat path, cold prefill on unique text (KV purged per block), server-reported avg=.
Observation: updating from 110afdd to 6289c51 cost GLM cold prefill consistently at every depth,
while decode stayed flat. Interleaved A/B (3 rounds per condition, per-block checkout+binary+KV purge,
thermal settle + cooldowns; first round discarded as cold):
| depth | 110afdd | 6289c51 | delta |
|---|---|---|---|
| 8K cold | 411 t/s | 381 t/s | −7.3% |
| 16K cold | 385 t/s | 362 t/s | −6.0% |
| 24K cold | 372 t/s | 341 t/s | −8.4% |
| 2K delta on warm 14K | 313 t/s | 278 t/s | −11% |
| decode 0–24K | 24.2–31.6 t/s | 24.2–30.4 t/s | flat/noise |
Attribution: direct two-commit differential, 0e9cc2d^ (=9d9e129) vs 0e9cc2d
("Fix GLM attention masking and reductions across GPU backends"), 2 interleaved rounds each,
same harness:
| depth | 9d9e129 | 0e9cc2d | delta |
|---|---|---|---|
| 8K cold | 415 t/s | 382 t/s | −8.0% |
| 16K cold | 386 t/s | 359 t/s | −7.0% |
| 24K cold | 376 t/s | 355 t/s | −5.5% |
That accounts for essentially the whole update delta. The commit message records the Strix continued-prefill improvement (21→68 t/s) and unchanged official scores, but not a Metal cost, so this may be an unnoticed side effect of the added reduction-storage synchronization / padded-selection handling on Apple GPUs rather than an accepted trade-off.
Happy to run patches or diagnostics on this M5 Max config. (Same machine/config as the measurements in #897/#898.)
Data point from a second M5 Max (128 GB). This is a different arm from the report, so it does not overturn it.
Setup: GLM 5.3 Flash with a hybrid quant: the Q2 body, KDA v/output at Q4_K, and routed experts in layers 17–23 at Q4_K. The engine is the base f935161c (0e9cc2d plus the #1090 GLM kernels), Metal, Tensor API off, resident, ds4-bench --ctx-alloc 102400, teacher-forced 256-token decode, powermode 2, fans pinned at max, 30 s gaps.
0e9cc2d makes two separable prefill changes, and I built one binary per change:
- B: dense-attention limit set back to
ctx_cap(4096) instead oftop_k + pool - 1(2051). - C: sparse prefill slices on the
_validpipeline instead of the bounds-checked one.
Both are inexact and were built only to measure speed. Order ABC CBA, 2 cycles (the third was stopped).
| prefill t/s | A base | B dense | C valid | B/A | C/A |
|---|---|---|---|---|---|
| cold 8K | 267.8 | 279.4 | 279.3 | ×1.044 | ×1.043 |
| cold 16K | 258.3 | 266.8 | 266.6 | ×1.033 | ×1.033 |
| cold 24K | 268.3 | 258.3 | 262.9 | ×0.963 | ×0.979 |
| 2K continued on a 14K prefix | 256.1 | 249.5 | 254.6 | ×0.974 | ×0.994 |
- Continued prefill: neither half gets back the reported −11%. The dense-limit change can't affect it anyway: every
dense_limituse only applies below position 4096. - Cold prefill: both reverts are about 3–4% faster at 8K and 16K, but slower at 24K. That's n=2, so it's unresolved. I can't tell whether it's the same effect at a smaller size.
- Decode: unchanged.
The regression may depend on the plain resident Q2 layout or on the build before #1090. If someone can reproduce it, a _valid fast path for slices with no padded IDs would keep exactness. Reverting would not.
Please verify the fix for this regression in PR #1147
Independent verification of PR #1147 on the same config as this report (MacBook Pro M5 Max 128 GB, GLM-5.3-Flash-Q2.gguf resident, --warm-weights), done 2026-09-29:
Correctness — cherry-picked #1147 onto our fork's main (commit 76410a5):
tests/test_glm_attention: the PR's 12 newmetal_prefill_prefix_casecases (heads∈{8,64,17} × count∈{17,2051} × rope∈{0,64}) all pass — bitwise equality rollback-path vs fast-path, plus CPU reference comparison../ds4_test --metal-kernels:OK, zero mismatch, including the pre-existingcompressed selection causalitycheck.- Bit-exact end-to-end beyond the synthetic unit test: dumped full-vocabulary logits (
ds4-bench --dump-frontier-logits-dir) on our actual resident GLM-5.3-Flash-Q2 at ctx=8192 and ctx=16384,DS4_METAL_DISABLE_GLM_PREFILL_PREFIX=1vs enabled — byte-identical JSON at both depths.
Speed (ds4-bench --gen-tokens 0, 4 alternating A/B/B/A passes to cancel thermal drift):
| Interval | Control (avg of 2) | Patched (avg of 2) | Gain |
|---|---|---|---|
| 8K→16K | 389.4 t/s | 415.6 t/s | +6.7% |
| 16K→24K | 379.7 t/s | 408.8 t/s | +7.7% |
This recovers essentially the full regression this issue reports (−7.3%/−6.0%/−8.4% at the equivalent depths vs 110afdd) and lines up with the author's own claimed +7.2%/+7.1% within our machine's measurement noise. No regression found anywhere we looked. We've had #1147 running in production since 2026-09-29 with no issues.
(Full methodology/numbers also posted on #1147 itself: https://github.com/antirez/ds4/pull/1147#issuecomment-5885148959)