Repository navigation
Conversation
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 ROCm#7489. Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
There was a problem hiding this comment.
🟡 Changes recommended
Two remaining comment and docstring style issues need shorter wording, with change history removed from the test docstring.
2 open issues
What changed in this PR
This follow-up to #7489 restores the quantization tile-width guard in fused_clamp_act_mul, so narrow Triton tiles fail before kernel launch.
Changes:
- Add a quantized-path assertion before backend dispatch while retaining Gluon’s configured-tile check.
- Add regression cases for half-widths of 32 and 64 with a quantization group size of 128 on both backends.
| File | Description |
|---|---|
op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py |
Add tests expecting an assertion when the quantization group exceeds the tile width. |
aiter/ops/triton/fusions/fused_clamp_act_mul.py |
Restore the pre-launch quantization tile-width guard. |
Review effort: Balanced

Summary
Follow-up to #7489. Restores the quant-tile-width guard on the Triton backend of
fused_clamp_act_mul, which was lost when the whole-group width requirement was relaxed.Motivation
#7489 (commit
becee62) relaxed the width check and removed the only constraint that keptnext_power_of_2(n_half) >= quant_block_size. The Gluon branch still assertsBLOCK_SIZE_N % quant_block_size == 0(fused_clamp_act_mul.py:307), but the Triton branch had no equivalent. A row narrower than one quant group therefore reached_fp8_quant_op(_triton_kernels/quant/fused_fp8_quant.py:34-35) withNUM_QUANT_BLOCKS = BLOCK_SIZE_N // QUANT_BLOCK_SIZE == 0, reshaping to 0 elements against a non-empty tile instead of raising the cleanAssertionErrorboth backends produced before.The hole is exactly
n_half <= quant_block_size / 2— at the defaultquant_block_size = 128,n_half = 32andn_half = 64. On the merge base and at8f12739both widths raised cleanly; afterbecee62only Gluon still did.Changes
aiter/ops/triton/fusions/fused_clamp_act_mul.py: hoistassert BLOCK_SIZE_N % quant_block_size == 0above the backend branch underif HAS_QUANT, guarding the Triton tile (next_power_of_2(n_half)). The Gluon branch keeps its own assert (it may overrideBLOCK_SIZE_Nfrom config) and its no-quantminclamp.op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py: addtest_fused_clamp_act_mul_quant_group_wider_than_tile_raises(n_half 32/64, quant_block_size 128, both backends).Performance (if applicable)
Not applicable — adds a pre-launch assert on an already-invalid shape; no change to any valid path.
Testing
New test asserts both backends raise
AssertionErrorat the previously crashing shapes.black --checkandruff checkclean. The Triton case runs on non-gfx1250 Triton CI (skipped on gfx1250 by the test harness); the Gluon case runs on gfx1250.Documentation
Behavior is unchanged for all valid widths; the guard only restores the pre-existing clean error for invalid ones.
Dependencies
Breaking Changes
None. Widths that worked before are unaffected; shapes with
n_half <= quant_block_size / 2go back to raising a cleanAssertionErroron Triton (as Gluon already did) instead of a confusing reshape crash.PR Self-Review
Reviewed revision
31e4973
Behavior and intent
The Triton path lost its quant-tile-width guard in #7489, letting
n_half <= quant_block_size / 2reach the kernel withNUM_QUANT_BLOCKS == 0. Hoisting the assert underHAS_QUANTabove the branch restores a clean failure for the Triton tile while leaving Gluon's config-aware assert and no-quant clamp intact.Validation and unverified scope
blackandruffclean on both files. Added regression test raises on both backends at n_half 32/64, quant_block_size 128. Not re-run here: device execution of valid partial-width shapes (unchanged by this patch).PR-specific question
The guard uses the same
BLOCK_SIZE_N = next_power_of_2(n_half)the Triton kernel launches with, so it exactly matches the Triton tile. Gluon still validates its own (possibly config-overridden)BLOCK_SIZE_N, so no backend loses coverage and no valid shape changes behavior.Changed op tests
op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py: addstest_fused_clamp_act_mul_quant_group_wider_than_tile_raises, covering the exact hole (n_half <= quant_block_size / 2) on both backends. Not redundant — existing partial-width tests use widths where the tile is at least one quant group wide, so they never exercise theNUM_QUANT_BLOCKS == 0path.