Repository navigation
[Triton/Gluon] Add per token scale to a8w8 moe gemm - #6106
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The unrelated FNUZ tail-path correction should be moved to a focused follow-up PR with dedicated coverage.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds optional per-token activation and per-expert weight scaling to the Triton A8W8 MoE GEMM.
Changes:
- Validates and forwards the new scale tensors.
- Applies scales before bias and activation.
- Extends tests and updates the shared-kernel caller.
| File | Description |
|---|---|
op_tests/triton_tests/moe/test_moe_gemm_a8w8.py |
Tests token/expert scaling. |
aiter/ops/triton/moe/moe_op_gemm_a8w8.py |
Exposes and validates scale arguments. |
aiter/ops/triton/moe/moe_gemm_mxfp8.py |
Updates the shared-kernel call signature. |
aiter/ops/triton/_triton_kernels/moe/moe_op_gemm_a8w8.py |
Applies scales and modifies FNUZ tail handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
993d8ce to
78e2021
Compare

Motivation
Add per-token activation scales and per-expert weight scales to the Triton a8w8 MoE GEMM
Technical Details
moe_gemm_a8w8takes two new optional args:x_token_scale: fp32, one scale per row ofxw_expt_scale: fp32[n_expts], one scale per expertGatherIndxwhen it is set.moe_gemm_mxfp8passesNonefor both.USE_FNUZ) MX path's handling of the last, partial K block (not EVEN_K). It now builds the weight block-scale the same way as the main K loop. The old code applied scales to the wrong K elements and only compiled whenBLOCK_N == BLOCK_K. No current caller reaches this path, becausemoe_gemm_mxfp8usesBLOCK_K = 32and requiresK % 32 == 0.Test Plan
test_moe_gemm_a8w8.py: newtoken_expt_scalesTest Result
test_moe_gemm_a8w8.py+test_moe_gemm_mxfp8.py645 passed, 512 skippedSubmission Checklist