Skip to content

[Triton/Gluon] fused_clamp_act_mul: guard the Triton quant tile width - #7908

Merged
azaidy merged 1 commit into
ROCm:mainfrom
karverma-amd:karverma-amd/fused-clamp-act-mul-triton-quant-guard
Nov 13, 2026
Merged

azaidy merged 1 commit into
ROCm:mainfrom
karverma-amd:karverma-amd/fused-clamp-act-mul-triton-quant-guard

Conversation

@karverma-amd

Copy link
Copy Markdown
Contributor

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 kept next_power_of_2(n_half) >= quant_block_size. The Gluon branch still asserts BLOCK_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) with NUM_QUANT_BLOCKS = BLOCK_SIZE_N // QUANT_BLOCK_SIZE == 0, reshaping to 0 elements against a non-empty tile instead of raising the clean AssertionError both backends produced before.

The hole is exactly n_half <= quant_block_size / 2 — at the default quant_block_size = 128, n_half = 32 and n_half = 64. On the merge base and at 8f12739 both widths raised cleanly; after becee62 only Gluon still did.

Changes

  • aiter/ops/triton/fusions/fused_clamp_act_mul.py: hoist assert BLOCK_SIZE_N % quant_block_size == 0 above the backend branch under if HAS_QUANT, guarding the Triton tile (next_power_of_2(n_half)). The Gluon branch keeps its own assert (it may override BLOCK_SIZE_N from config) and its no-quant min clamp.
  • op_tests/triton_tests/fusions/test_fused_clamp_act_mul.py: add test_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

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

New test asserts both backends raise AssertionError at the previously crashing shapes. black --check and ruff check clean. The Triton case runs on non-gfx1250 Triton CI (skipped on gfx1250 by the test harness); the Gluon case runs on gfx1250.

Documentation

  • No documentation change is needed, with the reason stated below

Behavior is unchanged for all valid widths; the guard only restores the pre-existing clean error for invalid ones.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None. Widths that worked before are unaffected; shapes with n_half <= quant_block_size / 2 go back to raising a clean AssertionError on 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 / 2 reach the kernel with NUM_QUANT_BLOCKS == 0. Hoisting the assert under HAS_QUANT above 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

black and ruff clean 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: adds test_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 the NUM_QUANT_BLOCKS == 0 path.

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]>
@karverma-amd
karverma-amd requested a review from a team November 13, 2026 02:31
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7908 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 31e4973601d4 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — validation answer must explicitly state what remains unverified (or say none with a reason)

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@karverma-amd
karverma-amd requested a review from azaidy November 13, 2026 03:45

@azaidy azaidy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@azaidy
azaidy merged commit 85ccf17 into ROCm:main Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants