Optimize large NVFP4 QMV on M5 Max - #3961
Open
dhiltgen wants to merge 1 commit into
Open
Conversation
Use a narrower output tile for large NVFP4 matrix-vector products on M5 Max GPUs. Reducing the results per SIMD-group from four to two lowers register pressure for output dimensions of 4096 or greater. Keep the existing kernel configuration for other architectures, quantization modes, and smaller output dimensions. Add coverage for batched and unbatched large-output QMV across the supported floating-point types.
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.
Proposed changes
Use a narrower output tile for large NVFP4 matrix-vector products on M5 Max GPUs. Reducing the results per SIMD-group from four to two lowers register pressure for output dimensions of 4096 or greater.
Keep the existing kernel configuration for other architectures, quantization modes, and smaller output dimensions.
Add coverage for batched and unbatched large-output QMV across the supported floating-point types.
Performance
Apple M5 Max, 40-core GPU, 128 GB, macOS 26.5.2.
The optimized path is intentionally limited to M5 Max (
applegpu_g17s), which is the only M5 configuration I was able to test. The narrower tile may also benefit other M5 GPUs, but I do not have the hardware to validate that tradeoff without risking regressions.After a warmup, baseline and candidate were run in B/A/A/B order. Results are the midpoint of the paired nine-trial medians.
Ollama MLX generation improved by 2.8% on Qwen3.5 4B NVFP4 and 3.9% on Qwen3.5 9B NVFP4; prompt throughput was effectively unchanged.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes