use ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM to enable non shuffle triton gemm#1031
Merged
Conversation
5375206 to
c3e9ae0
Compare
c3e9ae0 to
5603464
Compare
Signed-off-by: zhuyuhua-v <yuhzhu@amd.com>
5603464 to
6d85564
Compare
Signed-off-by: zhuyuhua-v <yuhzhu@amd.com>
XiaobingSuper
previously approved these changes
Jun 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an environment-variable-controlled switch to use AITER’s non-shuffled Triton FP4 GEMM path (intended to improve small-batch/decode performance) and wires it into the FP4 GEMM dispatch and weight post-processing logic.
Changes:
- Document a new env var to enable non-shuffle Triton FP4 GEMM behavior.
- Add env var plumbing in
atom.utils.envs. - Update FP4 GEMM selection logic and weight/scale shuffle handling in
atom/model_ops/linear.py.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs/environment_variables.md | Documents the new env var and its precedence relative to ATOM_USE_TRITON_GEMM. |
| atom/utils/envs.py | Adds the new env var accessor (with suggested aliasing to match PR text). |
| atom/model_ops/linear.py | Adds non-shuffle Triton FP4 GEMM dispatch and adjusts shuffling behavior for FP4 weights/scales. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+131
to
+133
| "ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM": lambda: ( | ||
| os.getenv("ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM", "0") == "1" | ||
| ), |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
39
to
+40
| | **ATOM_USE_TRITON_GEMM** | bool | 0 (false) | If set to `1`, use AITER Triton FP4 weight preshuffled GEMM. Otherwise use AITER ASM FP4 weight preshuffled GEMM. | | ||
| | **ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM** | bool | 0 (false) | If set to `1`, use AITER Triton FP4 GEMM with non-shuffled weights. Takes precedence over the FP4 preshuffled GEMM path selected by `ATOM_USE_TRITON_GEMM`. | |
Comment on lines
+131
to
+133
| "ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM": lambda: ( | ||
| os.getenv("ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM", "0") == "1" | ||
| ), |
Comment on lines
+45
to
+56
| def use_fp4_non_shuffle_triton_gemm() -> bool: | ||
| return envs.ATOM_USE_FP4_NON_SHUFFLE_TRITON_GEMM | ||
|
|
||
|
|
||
| if use_fp4_non_shuffle_triton_gemm(): | ||
| try: | ||
| from aiter.ops.triton.gemm_afp4wfp4 import gemm_afp4wfp4 # noqa: E402 | ||
| except ImportError as e: | ||
| logger.warning(f"Triton FP4 GEMM not available: {e}") | ||
| gemm_afp4wfp4 = None | ||
| else: | ||
| gemm_afp4wfp4 = None |
valarLip
approved these changes
Jun 2, 2026
zejunchen-zejun
approved these changes
Jun 3, 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.
Motivation
As shown below, atom use preshuffled asm gemm as default path for fp4 gemm path while mori-sglang using non-shuffle gemm for better performance, plus, triton preshuffle fp4 gemm got a worse perf:

Test Plan
benchmark + gsm8k
Test Result
https://github.com/ROCm/ATOM/actions/runs/26651782340 for benchmark test:

Submission Checklist