Skip to content

[Triton/Gluon] fused_indexed_gated_residual: reject overlapping output rows - #8681

Open
Shan2L wants to merge 2 commits into
ROCm:mainfrom
Shan2L:triton/gated-residual-reject-overlap
Open

Shan2L wants to merge 2 commits into
ROCm:mainfrom
Shan2L:triton/gated-residual-reject-overlap

Conversation

@Shan2L

@Shan2L Shan2L commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

aiter.ops.triton.fusions.fused_indexed_gated_residual (merged in #6416) now rejects an out tensor whose rows overlap. The issue was found by @junhaha666 in review of the HIP version of the same op (#6417, comment #6417 (comment)).

Motivation

An out whose rows overlap passes validation. For example, torch.empty((1, N)).expand(M, N) has row stride 0, so all M rows are written to the same addresses, and the result is wrong and nondeterministic.

Changes

  • fused_indexed_gated_residual: assert M <= 1 or N == 0 or out.stride(0) >= N before launch, in the same assert style as the existing checks. Padded row strides and the in-place alias out=residual stay valid.

No kernel change. The benchmark fix that was part of this PR is now a separate PR, #8717, as requested in review.

Performance (if applicable)

Not applicable: the change adds one host-side assertion before launch.

Testing

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

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The new check only rejects inputs that already gave wrong results.

AI assistance: this change was developed with the help of an AI coding assistant (GitHub Copilot). The check was run on the listed hardware before the test was removed (see Validation).

PR Self-Review

Reviewed revision

64562c4

Behavior and intent

fused_indexed_gated_residual now raises AssertionError for an out with overlapping rows (M > 1, N > 0 and out.stride(0) < N). Before, such an output passed validation, several programs wrote the same addresses, and the results were wrong and nondeterministic. Valid outputs, including padded row strides and out=residual, behave exactly as before.

Validation and unverified scope

  • gfx1201 (Radeon AI PRO R9700), torch 2.14.0 + ROCm 10.1: python3 -m pytest -q op_tests/triton_tests/fusions/test_fused_indexed_gated_residual.py 35 passed at 2a5494c (on main afce047), including test_rejects_overlapping_output_rows.
  • That test was removed in review, and the remaining tests were not re-run after that. With the new assert replaced by True, only that test failed (36 passed, 1 failed, measured before the rebase), so nothing in the file covers the check now.
  • Unverified: MI hardware (none available to me); CI covers gfx942/gfx950.

PR-specific question

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?

No op test is changed by this PR (the test it first added was removed in review), so there is none to answer for.

Changed op tests

None.

@Shan2L
Shan2L requested a review from a team November 25, 2026 10:47
@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 8681 --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.

@github-actions github-actions Bot changed the title [Triton] fused_indexed_gated_residual: reject overlapping output rows, benchmark the eager-rounded path [Triton/Gluon] fused_indexed_gated_residual: reject overlapping output rows, benchmark the eager-rounded path Nov 25, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot November 25, 2026 14:33

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

The benchmark rounding and equality-check changes are unrelated to the output-overlap fix and must move to a follow-up PR to satisfy the one-problem-per-PR rule.

1 open issue
What changed in this PR

This PR strengthens output validation for AITER’s existing Triton fused_indexed_gated_residual op and aligns its benchmark with eager arithmetic. The GPU kernel is unchanged.

Changes:

  • Reject overlapping output rows while preserving padded layouts and valid in-place updates.
  • Add rejection tests for broadcast and short-stride outputs.
  • Benchmark with round_intermediate=True and check exact equality with eager before timing.
File Description
op_tests/​triton_tests/​fusions/​test_fused_indexed_gated_residual.py Tests rejection of two overlapping output layouts.
op_tests/​op_benchmarks/​triton/​bench_fused_indexed_gated_residual.py Enables eager-compatible rounding and checks results before timing.
aiter/​ops/​triton/​fusions/​fused_indexed_gated_residual.py Adds output-row overlap validation before launch.

Review effort: Balanced

Comment on lines +62 to +66
kernel_fn = (
functools.partial(fused_indexed_gated_residual, round_intermediate=True)
if provider == "fused"
else _eager_fn
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, split. This PR now contains only the overlap check and its test (77006be). The benchmark rounding fix and the equality check moved to #8717.

@aiter-bot

aiter-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 64562c4694be · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

`fused_indexed_gated_residual` now raises `AssertionError` for an `out` with overlapping rows (M > 1, N > 0 and `out.stride(0) < N`). Before, such an output passed validation, several programs wrote the same addresses, and the results were wrong and nondeterministic. Valid outputs, including padded row strides and `out=residual`, behave exactly as before.

Validation and unverified scope

- gfx1201 (Radeon AI PRO R9700), torch 2.14.0 + ROCm 10.1: `python3 -m pytest -q op_tests/triton_tests/fusions/test_fused_indexed_gated_residual.py` 35 passed at 2a5494c1 (on main afce0474), including `test_rejects_overlapping_output_rows`.
- That test was removed in review, and the remaining tests were not re-run after that. With the new assert replaced by `True`, only that test failed (36 passed, 1 failed, measured before the rebase), so nothing in the file covers the check now.
- Unverified: MI hardware (none available to me); CI covers gfx942/gfx950.

PR-specific question

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?

No op test is changed by this PR (the test it first added was removed in review), so there is none to answer for.

Changed op tests

None.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

@Shan2L
Shan2L force-pushed the triton/gated-residual-reject-overlap branch from 8f469fe to 77006be Compare November 26, 2026 00:11
@Shan2L Shan2L changed the title [Triton/Gluon] fused_indexed_gated_residual: reject overlapping output rows, benchmark the eager-rounded path [Triton/Gluon] fused_indexed_gated_residual: reject overlapping output rows Nov 26, 2026
@zufayu
zufayu requested review from a team and Boss2002n November 26, 2026 02:48
An out tensor whose rows overlap (e.g. torch.empty((1, N)).expand(M, N),
row stride 0) passed validation, and rows then raced on the same
addresses. Reject M > 1 with out.stride(0) < N; padded row strides and
exact in-place aliases stay valid. Found in review of the HIP version
(ROCm#6417).

Signed-off-by: Sylvan Liu <[email protected]>
@Shan2L
Shan2L force-pushed the triton/gated-residual-reject-overlap branch from 77006be to 2a5494c Compare November 26, 2026 05:54

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.

pls remove the additional test function - other than that LGTM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 64562c4. The PR is now only the host-side assert; the PR description is updated to match.

@Shan2L

Shan2L commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@Boss2002n The extra test is removed in 64562c4, so the PR is now only the overlap assert in the wrapper. Could you take another look?

The two failing checks (Triton Tests (MI35X) / Shard 0 and Triton Test Results) come from op_tests/triton_tests/kimi_delta_attn/test_flash_kda.py (18 failures); this PR does not touch that op.

This branch has not been deployed

No deployments
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