Optimize fused_dynamic_mxfp4_quant_moe_sort_hip in small M#2700
Merged
Optimize fused_dynamic_mxfp4_quant_moe_sort_hip in small M#2700
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes the HIP fused MXFP4 quantization + MoE scale sorting path for smaller M by changing the sorted_ids access pattern and adjusting the Python-side heuristic for when to use the fused kernel.
Changes:
- Update
mxfp4_quant_moe_sort_kernelto use a strided indexing scheme withinblock_mforsorted_idstraversal. - Pass
tgs_per_block_minto the kernel and derive it fromblock_m / sub_block_m. - Adjust the stage2 dispatch threshold in
fused_dynamic_mxfp4_quant_moe_sortto account fortopk.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
csrc/kernels/quant_kernels.cu |
Implements strided sorted_ids traversal and adds tgs_per_block_m plumbing for the fused HIP kernel. |
aiter/ops/quant.py |
Updates the stage2 cutoff heuristic for selecting the fused HIP path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
valarLip
approved these changes
Apr 13, 2026
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.
test on MI355: python3 op_tests/test_moe_sorting_mxfp4.py -dim1 7168 -dim2 256 -ek 256,8


Stage1:
before:
now:
Stage2:


before:
now: