metal: gate the M3-class fusion whitelists on the pre-M5 predicate - #770
metal: gate the M3-class fusion whitelists on the pre-M5 predicate#770kk1987 wants to merge 1 commit into
Conversation
|
Just as a comment, I made a more generalized version of your change to admit any pre-M5 hardware to these M3-class fusion whitelists and it seems to work well on my M1 Ultra 128GB. I would have to get the precise benchmark numbers to validate it, but I am getting around 25 tops of generation on an empty context, which is better than I had before (23.5 on an empty context, consistent with what another M1 Ultra user reported in #706). |
|
So I can test a more generalized version of your PR in case you want to make it (or leave it like this since we don't have an M2 user to verify it on that hardware too). |
The exact-fusion campaign's newest decode ports gate on ds4_gpu_ported_m5_decode_feature_enabled(), whose pre-M5 predicate admits M1-M4. The older fusion sites still used literal M3/M5 device-name whitelists, so pre-M5 devices other than M3 silently skipped fifteen eligible fusions and ds4_test failed its 29 forced-fusion exactness assertions there (pair compressor store, gathered KV staging) because the entry points refuse to run at all. Switch the fifteen sites to the same predicates the ported gate uses: is_pre_m5 || is_m5 where M5 was admitted, plain is_pre_m5 for the M3-only sites (those screened negative on M5, so M5 stays out). Metal 4 tensor API sites and the M5 private scratch heuristic are unchanged (pre-M5 hardware lacks them); the router SIMD sites already use the predicate; ds4.c needs nothing. Verified on M4 Max 128 GiB with the DS4F 0731 IQ2XXS GGUF: ds4_test goes from 29 failures to fully green, per-fusion A/B medians reach +3.8% decode (RoPE pair) and +4.5% prefill (zero-prefix mask cache) with every run bit-exact, and the full ds4-bench curve improves +1.55% median generation over 2K-64K. An equivalent generalization measured ~23.5 -> 25 tok/s empty-context generation on M1 Ultra 128 GB (reported by lmr on the PR). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H58vqtiLFWWWAbcB7oHAp8
7ed2b8f to
dfea3a7
Compare
|
Nice, thanks for testing! That M1 Ultra bump matches what I'd hope for — the RoPE pair fusions were the biggest single win on M4 too. I've switched the PR to the pre-M5 predicate: If you want precise M1 numbers, the harness I used: |
|
Independent replication on a second M4 Max (128 GiB, DS4F 0731 IQ2XXS resident). I measured these before finding this PR, so the numbers are uncoordinated. Applies clean to current main Per-fusion A/B with
Every run bit-exact: Two notes on reading those rows:
I had first patched this by adding |
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
…irez#770 Cherry-picks the hunks of antirez#770 (kk1987) that this branch had not already covered. That PR fixes the same defect found here independently - literal ds4_gpu_device_name_contains("M3")/("M5") whitelists where the surrounding port used ds4_gpu_device_is_pre_m5_apple_silicon() - and reports the same 29 forced-fusion exactness assertions failing, which is the count this branch saw go 29 -> 23 -> 0 across ba132ba and bb576ed. Of its fifteen sites, eight were already converted here (01a56db x4, ba132ba x2, bb576ed, 36d2758). Every one of the remaining seven is a prefill or batch path except shared kvpad, which is deliberately left out below. Six are taken here: 2012 zero-prefix prefill mask cache +4.5% prefill on M4 Max 20623 HC rms-scale-project, n_rows > 8 21869 compressor score + APE add 22677 concat f32 dim1 / ratio-4 pack 22723 ratio-4 direct pool 32096 router select batch weights, n_tokens > 1 +0.8% prefill This branch's decode audit had already classified all six as prefill-only and skipped them for that reason, so no decode change is expected; they are here for the prefill side, which nobody had swept. Taken as upstream wrote them, replacing the name test outright rather than adding an or-arm as the earlier commits here did, so the tree converges with antirez#770 if it merges. The eight sites already converted are left in their existing form: they are measured and working, and rewriting them for cosmetic convergence would risk a regression for no gain. Not applied: 27563, shared kvpad. It removes no dispatch, and ba132ba records the reason for leaving it M3-only - shared_pad stays 0 so the fused stage writes both the K and V pad copies, matching the standalone pad kernel. Upstream measured it in its neutral bucket, so there is nothing to gain against a layout hazard nobody has tested on Apple8. ds4_test --metal-kernels stays OK. Prefill effect unmeasured on this hardware; every site keeps its own DS4_METAL_DISABLE_* switch.
Fixes #769.
The exact-fusion campaign's newest decode ports gate on
ds4_gpu_ported_m5_decode_feature_enabled(), whose pre-M5 predicate already admits M1–M4. The older fusion sites still used literaldevice_name_contains("M3") || ("M5")whitelists, so pre-M5 devices other than M3 silently skipped fifteen eligible fusions, and ds4_test failed its 29 forced-fusion exactness assertions there because the entry points refuse to run at all.This switches those fifteen sites to the same predicates the ported gate uses:
is_pre_m5 || is_m5where M5 was admitted, plainis_pre_m5for the M3-only sites (those screened negative on M5, so M5 stays out). Net −15 lines. Left untouched: the Metal 4 tensor API sites and the M5 private-scratch heuristic (pre-M5 hardware lacks them), and the router SIMD sites (already on the predicate). ds4.c needs nothing.Verified on M4 Max 128 GiB, DS4F 0731 IQ2XXS resident:
make testgoes from 29 failures to fully green, including the bit-exact fused-vs-reference comparisons for both previously failing kernels.metal_decode_schedule_bench/metal_prefill_variant_bench, 3 samples per fusion, cool-down rounds, medians; every run bit-exact over the full vocabulary with identical token selection:On M1 Ultra 128 GB, an equivalent generalization measured roughly 23.5 → 25 tok/s generation on an empty context (thanks @lmr — see comments). M2 has no tester, but every site keeps its
DS4_METAL_DISABLE_*rollback and the forced-fusion test assertions now cover any device the predicate admits.A benchmarking note: on a MacBook the numbers drift heavily once thermal throttling kicks in — enough that two prefill deltas came out with the wrong sign on back-to-back hot runs. The numbers above are cool-down multi-round medians.
🤖 Generated with Claude Code