fix: select precise M=16 verify kernel on M1 - #8
Open
aunali1 wants to merge 1 commit into
Open
Conversation
The FP16 tree rounds each simdgroup partial before the final reduction on M1, producing a repeatable one-BF16-ULP deviation for the gate/up projection. Route applegpu_g13 auto-selection through the FP32-accumulating combo kernel. Pin the G13 production-shape fingerprints and cover the architecture-specific selector. The combo path reduces the measured gate/up deviation from 0.0078125 to at most 0.000244141 and cuts isolated kernel latency by 41%.
aunali1
marked this pull request as ready for review
August 20, 2026 17:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The M=16 FP16 tree stores each simdgroup partial in FP16 before the final FP32 reduction. On
applegpu_g13s, that produces a repeatable one-BF16-ULP error at the planted gate/up logit: maximum deviation was0.0078125for all three contract seeds, above the existing0.001bound.The pre-existing combo kernel keeps the matrix accumulation and cross-simdgroup reduction in FP32. Its maximum deviation was
0.000122070,0.000122070, and0.000244141across the same seeds, with all margin-certified argmaxes preserved.Performance
On an Apple M1 Max, the isolated
16x5120x17408product-shape kernel benchmark measured 90 synchronized runs per path:1.893625 ms1.112480 ms41.3%This is an M=16 kernel result. The Qwen3.8 DFlash2 checkpoint is native M=8 and does not exercise this path.
Validation
pytest -q tests/test_verify_kernel_contract.py:12 passedpytest -q tests/test_verify_kernel_contract.py tests/test_verify_qmm_parity.py -k m16:9 passed, 2 skipped1323 passed, 14 skippedgit diff --check: clean