Repository navigation
Conversation
The wrapper required the half width to be a multiple of 128, but both the Gluon and Triton kernels already mask the columns past n_half inside their power-of-two tile and skip the scale groups past it. The real constraint is whole quant groups, so allow any multiple of 32 (and of quant_block_size when quantizing). This lets DeepSeek-V4.1-Flash's shared expert take the fused clamp + SiLU*up + MXFP8 path at TP4 (576 columns per rank) and TP8 (288). Adds a gfx1250 Gluon config for N=576 (256-wide tiles, 1 warp): 1.88 -> 1.53 us at M=48 against the default whole-row 1024 tile. At M=48, N=576, 43 calls per HIP graph, the fused kernel against silu_and_mul + group-32 quant: 3.39 -> 1.54 us; with the w2 GEMM after it, 6.37 -> 4.51 us. test_fused_clamp_act_mul_mx_partial_width: widths 288/576/1152/2304, M up to 97, against an fp32 model of the kernel's ue8m0 quant (scale codes within one step on <0.1% of groups, values within E4M3 rounding).
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
The width the wrapper asserts (a multiple of 32) is now a module constant, so a caller can gate on what the installed kernel accepts instead of hard-coding it (ROCm/ATOM#3021 reads it and assumes 128 when it is absent).
There was a problem hiding this comment.
🟡 Changes recommended
The change causes gfx1250 unquantized rows with n_half=32 or 64 to fail a tile assertion and rejects a previously supported FP8 quantization configuration without documenting the breaking restriction.
2 open issues
What changed in this PR
This PR broadens fused_clamp_act_mul width support for shared-expert workloads such as DeepSeek-V4.1 TP4/TP8, allowing more shapes to use fused activation and quantization.
Changes:
- Exports
N_HALF_MULTIPLE = 32and checks that quantized rows contain whole groups. - Adds a gfx1250 Gluon configuration for half-width 576.
- Adds partial-width MXFP8 tests covering tail masking, scales, and zero groups.
| File | Description |
|---|---|
op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py |
Adds an MX reference and partial-width test cases. |
aiter/ops/triton/fusions/fused_clamp_act_mul.py |
Updates width checks, exports the width multiple, and revises documentation. |
aiter/ops/triton/configs/gfx1250/gluon/fusions/fused_clamp_act_mul/FUSED_CLAMP_ACT_MUL-N=576.json |
Adds a 256-column, one-warp Gluon configuration. |
Review effort: Balanced
- Drop the whole-group requirement: both kernels read the columns past n_half as zero, so a partial last group is scaled over its real columns. n_half=384 with quant_block_size=256 is accepted again. - Gluon: without quant, clamp the group to the N tile, so unquantized rows of 32 or 64 columns no longer fail the tile assertion. - Tests: unquantized 32/64-column rows, and partial last groups (384/256, 576/128) against an fp32 reference. Co-authored-by: Cursor <[email protected]>
One conflict, in op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py: both sides appended tests at the end of the file. Both are kept: main's (#7489) first, then this branch's row-count compile test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…#7908) When the whole-group requirement was relaxed (becee62), the Triton quant path lost the check that kept next_power_of_2(n_half) >= quant_block_size. The Gluon branch still asserts BLOCK_SIZE_N % quant_block_size == 0, but the Triton branch had no equivalent, so a row narrower than one quant group reached _fp8_quant_op with NUM_QUANT_BLOCKS = BLOCK_SIZE_N // QUANT_BLOCK_SIZE == 0 and a reshape targeting 0 elements against a non-empty tile, instead of the clean AssertionError both backends raised before. The hole is exactly n_half <= quant_block_size / 2 (e.g. n_half = 32 or 64 at the default quant_block_size = 128): the Triton tile is next_power_of_2(n_half), so it is narrower than one group there. Hoist the divisibility assert above the backend branch under HAS_QUANT so it covers the Triton tile (next_power_of_2(n_half)); keep the Gluon branch's own assert and its no-quant min clamp, since Gluon may override BLOCK_SIZE_N from its config. Add a regression test asserting both backends raise cleanly at n_half = 32 and 64 with quant_block_size = 128. Follow-up to #7489. Co-authored-by: karverma-amd <[email protected]>

Summary
fused_clamp_act_mulrequired the half width to be a multiple of 128. Both the Gluon and Triton kernels already mask columns pastn_halfinside their power-of-two tile and skip scale groups past it, and read the columns past it as zero, so a last quant group thatn_halfdoes not fill is scaled over its real columns. This allows any multiple of 32, exports that multiple asN_HALF_MULTIPLE, and adds a gfx1250 Gluon config for N=576.Related: consumed by ROCm/ATOM#3021 (DeepSeek-V4.1 shared expert at TP4/TP8, opt-in via
ATOM_V4_USE_TRITON_FUSION=1), which readsN_HALF_MULTIPLEand assumes 128 when it is absent.Motivation
DeepSeek-V4.1-Flash's shared expert has 576 intermediate columns per rank at TP4 and 288 at TP8. The 128 assert keeps it on
silu_and_mulplus a separate group-32 quant on every MoE layer.Changes
aiter/ops/triton/fusions/fused_clamp_act_mul.py: assertn_half >= N_HALF_MULTIPLE and n_half % N_HALF_MULTIPLE == 0(N_HALF_MULTIPLE = 32, a module constant callers can gate on); a partial last quant group is allowed, as before for multiples of 128 (e.g. 384 withquant_block_size=256). On the Gluon path without quant, the unused group is clamped to the N tile, so unquantized rows of 32 or 64 columns do not trip the tile assertion. Docstring updated.aiter/ops/triton/configs/gfx1250/gluon/fusions/fused_clamp_act_mul/FUSED_CLAMP_ACT_MUL-N=576.json: new, 256-wide tiles, 1 warp.op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py:test_fused_clamp_act_mul_mx_partial_width.Widths that passed before (multiples of 128) take exactly the same path and configs.
Performance (if applicable)
silu_and_mul+ group-32 quant +w2vs fused +w2(DeepSeek-V4.1-Flash TP4 shared expert)Testing
Tested on gfx1250 only (Gluon backend). The relaxed assert is shared with the Triton backend, whose new partial-width cases run off gfx1250 and were not run here.
Documentation
Dependencies
Breaking Changes
None. Previously accepted widths behave the same (including a partial last group such as 384 / 256); multiples of 32 that used to assert are now accepted.
PR Self-Review
Reviewed revision
8f12739
Behavior and intent
Relaxes the width check from "multiple of 128" to a multiple of
N_HALF_MULTIPLE(32), matching what both kernels already handle through masking, and exports that multiple so callers gate on the installed kernel rather than a hard-coded number. The existing check is insufficient because it rejects valid shapes such as DeepSeek-V4.1-Flash's shared expert at TP4 (576) and TP8 (288), forcing an unfused path. Adds a tuned gfx1250 Gluon config for N=576.Validation and unverified scope
python3 -m pytest -q op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py -k partial_width-> 32 passed, 32 skipped (Triton backend, skipped on gfx1250 by the test).python3 -m pytest -q op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py-> 364 passed, 484 skipped (same reason), re-run at this revision: no regressions in existing cases.w2output is never less accurate than the unfused one against an fp32 reference (e.g. 576, M=48: 2.643e-2 vs 2.664e-2; 288, M=48: 2.617e-2 vs 2.639e-2).black --check(26.10) andruff checkclean on changed files.PR-specific question
The only config change is the new file
configs/gfx1250/gluon/fusions/fused_clamp_act_mul/FUSED_CLAMP_ACT_MUL-N=576.json(keyany)._get_config(M, n_half, ...)loadsFUSED_CLAMP_ACT_MUL-N={n_half}.jsonby filename, so it is consumed only by gfx1250, Gluon backend,n_half == 576, every M. Unrelated shapes keep their selection because no existing file (DEFAULT.json, N=512, N=4096, N=8192) is modified and the lookup is keyed on the exactn_half. Also, before this PRn_half = 576failed the assert, so no previously working shape can change config.Changed op tests
op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py: addstest_fused_clamp_act_mul_mx_partial_width(widths 288/576/1152/2304, M up to 97, MXFP8 ue8m0 output) against an fp32 model of the kernel's quant: scale codes within one step on <0.1% of groups, values within E4M3 rounding. It fails before this PR on 288 and 576 (assert), and would catch wrong masking of the tail tile.test_fused_clamp_act_mul_partial_last_group(384 / 256 and 576 / 128, fp32 scales) checks a partial last group's scale is the amax of its real columns, andtest_fused_clamp_act_mul_narrow_rows_unquantizedcovers unquantized 32- and 64-column rows. Not redundant: the existing cases use only power-of-two / multiple-of-128 widths, where the tile has no masked tail.