Skip to content

[Triton/Gluon] Muse fused kernel for rmsnorm + add + rmsnorm - #6343

Merged
azaidy merged 19 commits into
mainfrom
vinayak/muse-rms-add-rms-fused
Oct 13, 2026
Merged

azaidy merged 19 commits into
mainfrom
vinayak/muse-rms-add-rms-fused

Conversation

@vgokhale

@vgokhale vgokhale commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Add support for muse's fused rmsnorm + add + rmsnorm kernel. This brings the total kernel time to ~3us for con1 vs having two separate kernel calls of 3us each.

Keep the first norm, residual addition, and residual output in FP32. Round only the final pre-norm output to BF16. Register the callable for torch.compile and test BF16/FP32 residual inputs on gfx950.
Restrict the supported residual input to BF16, retain only the requested x shape and dtype assertions, and multiply both RMS sums by the host-computed inverse width. Gfx950 measurements show equivalent accuracy and eliminate two FP32 division sequences.
Keep the FP32 intermediate computation, write the residual sum to a caller-provided BF16 buffer, and return only the final BF16 norm. Test the output mutation under torch.compile.
Use a caller-provided BF16 final norm buffer when present and allocate one otherwise. Keep residual_out caller-owned and register the buffer-writing kernel as a torch custom op for safe compilation.
Remove the private custom op and fake implementation. The public wrapper handles optional output allocation and launches Triton directly; tests cover both output modes and compile-time launch branches.
Register a mutation-only inner custom op so framework fake tracing works without returning an aliased mutable input. Keep optional output allocation and return in the public wrapper.
Register the public AITER fusion directly with a fake implementation. Allocate the BF16 pre-norm return internally while retaining the caller-owned residual sum buffer.
@vgokhale
vgokhale requested a review from azaidy October 9, 2026 20:47
@vgokhale
vgokhale marked this pull request as ready for review October 9, 2026 20:47
@vgokhale
vgokhale requested a review from a team October 9, 2026 20:47
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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: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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 6343 --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.

@github-actions github-actions Bot changed the title [Triton] Muse fused kernel for rmsnorm + add + rmsnorm [Triton/Gluon] Muse fused kernel for rmsnorm + add + rmsnorm Oct 9, 2026
@azaidy

azaidy commented Oct 10, 2026

Copy link
Copy Markdown
Contributor
  1. No benchmark and no performance number. README.md:493-494 says "a kernel ships as kernel + wrapper + test + benchmark". The PR body is one sentence. The whole point is a fusion, and nothing shows it beats rms_norm plus fused_rmsnorm_add run back to back. Also add a generate_*_inputs helper to the test — all three sibling benchmarks import one from their test file.

  2. _rmsnorm_op is not reused. It sits at fused_rmsnorm_add.py:11-16, in the same directory. The new kernel writes the same math inline twice. Context that softens this: a copy with a typo, _rmsmorm_op, already exists at fused_add_rmsnorm_pad.py:8-14. So the right fix is to lift one copy into _triton_kernels/common/.

@vgokhale

azaidy
azaidy previously approved these changes Oct 10, 2026

@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!

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

Input validation, config-based tuning, kernel representation, and the required benchmark need to be addressed.

4 open findings
What changed in this PR

Adds a fused BF16 Muse-style RMSNorm → residual-add → RMSNorm Triton operation.

Changes:

  • Adds the fused Triton kernel and public wrapper.
  • Supports torch.compile with mutated residual output.
  • Adds correctness and compilation tests.
File Description
aiter/​ops/​triton/​normalization/​fused_rmsnorm_add_rmsnorm.py Adds the public launcher and compile integration.
aiter/​ops/​triton/​_triton_kernels/​normalization/​fused_rmsnorm_add_rmsnorm.py Implements the fused kernel.
op_tests/​triton_tests/​normalization/​test_fused_rmsnorm_add_rmsnorm.py Tests numerical correctness and compilation.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu
zufayu requested review from a team and azaidy October 12, 2026 01:27
@vgokhale

Copy link
Copy Markdown
Contributor Author

@azaidy I added your suggestion #2. Re. #1 I don't think having benchmarks for every single kernel is important if the kernel is trivial like this one.

@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!

@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

[ROCm/aiter] PR #6343 — [Triton/Gluon] Muse fused kernel for rmsnorm + add + rmsnorm

Adds a Muse-style fused Triton op that applies the post-attention RMSNorm, adds the residual into a caller-owned buffer, and applies the pre-FFN RMSNorm in one kernel launch, and lifts the rmsnorm math duplicated across the two existing fused-normalization kernels into a shared helper.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled, no report exists — environment gap, not a PR defect); the target op_tests/triton_tests/normalization/test_fused_rmsnorm_add_rmsnorm.py ran green in Triton Tests (MI35X, gfx950) CI on head f31166a, and the one red job (Flash Attention - Triton / MI35X) failed inside its docker build on a git-clone timeout of Dao-AILab/flash-attention — an infra flake unrelated to this diff.
Perf (advisory): NOT RUN — perf required (runtime surface changed) but the test target exposes no benchmark entry point, and this box has no torch/triton environment to run the PR's op_tests/op_benchmarks/triton/bench_fused_rmsnorm_add_rmsnorm.py by hand; no base-vs-head or fused-vs-unfused timing exists anywhere.

⚠️ The PR's entire justification — the body's "~3us for con1 vs having two separate kernel calls of 3us each" — is demonstrated nowhere: no benchmark output is posted, and op_tests/op_benchmarks/triton/bench_fused_rmsnorm_add_rmsnorm.py times only the fused kernel with no baseline row, so a reviewer cannot tell whether the fusion actually beats rmsnorm + fused_rmsnorm_add run back to back. [verified that no backing output exists; the perf direction itself is unmeasured] Author must post the comparison — bench_fused_rmsnorm_add_rmsnorm next to bench_rmsnorm.py + bench_fused_rmsnorm_add.py --add-residual on the same box, or a baseline row in the benchmark — before merge.
⚠️ aiter/ops/triton/normalization/fused_rmsnorm_add_rmsnorm.py:71 hardcodes num_warps = 4 if M <= 128 else 8 in wrapper source while the sibling normalization wrappers read the knob from the tuned config system (fused_add_rmsnorm_pad.py:82 config["num_warps"] via _get_config/select_leq_config; rmsnorm.py:168 _cfg["num_warps"]), so both the value and the unexplained M <= 128 threshold are invisible to tuning sweeps and untuned on every arch. [verified for the hardcode and the config bypass; any latency impact is unmeasured] Author must move num_warps into the normalization config JSONs, or post a sweep on gfx942/gfx950 justifying 4/8 and the 128 threshold.
📝 The new public op fused_rmsnorm_add_rmsnorm has no caller: nothing in aiter imports it beyond its own test and benchmark, and no Muse integration PR (vLLM/SGLang/ATOM) is linked, so the kernel is unreachable from any serving path until a consumer wires it. [verified — grep of aiter/ and op_tests/ finds only the new test and benchmark as importers] Reviewer should ask who lands the call site and in which repo, so the op does not merge as dead code.

@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Where that review came from — I ran the bot on your PR to show what it does. It is not an automatic hook; nothing reviews your PR unless somebody asks.

Any reviewer on the aiter allowlist can ask for one, on any PR including their own. The trigger is a comment containing the words below — shown quoted here, because quoted lines deliberately do not trigger it:

@aiter-bot review

  • Reviews the PR at its current head. Comment again after pushing fixes for a fresh pass; a repeat on the same commit is deduped.
  • One review runs at a time on one box, roughly 20 minutes. If work is ahead of you the bot replies with your place in the queue, and if the runner is down it says so rather than leaving you waiting for a review that will never start.
  • The card is advisory. It never blocks a merge, 🔴 included — it is there to be argued with.

Feedback on the review itself is welcome; it is how the rules get better.

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.

5 participants