Skip to content

[Triton/Gluon] [GFX12] Add optimized gluon backend for mhc_fused_post_pre - #6442

Merged
azaidy merged 2 commits into
mainfrom
shaoclee/mhc_gluon_backend
Oct 13, 2026
Merged

azaidy merged 2 commits into
mainfrom
shaoclee/mhc_gluon_backend

Conversation

@k50112113

@k50112113 k50112113 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Gluon backend will be used if all following conditions are met:

  1. gfx1250
  2. M < 1024
  3. Residual shuffled, note that Gluon uses 64-block wide shuffle as opposed to HIP's 32-block wide, but this does not break e2e even if prefill and decode use different shuffle width, because residual is consumed and produced on-the-fly unlike the weights.
  4. C = 4096 or 7168

DeepSeek-V4-Pro (hidden 7168)

M HIP fused_post_pre HIP reduce HIP total Gluon fused_post_pre Gluon reduce Gluon total speedup
8 3.79 6.68 10.47 4.04 4.30 8.34 1.26x
16 3.92 7.05 10.97 4.03 4.38 8.41 1.30x
32 4.47 6.33 10.80 4.16 4.69 8.85 1.22x
64 5.34 6.74 12.08 4.41 4.54 8.95 1.35x
128 7.13 7.29 14.42 5.67 4.43 10.10 1.43x
256 9.27 8.64 17.91 7.66 4.81 12.47 1.44x
512 13.04 9.57 22.61 10.12 5.91 16.03 1.41x

err values seen (hip, gluon): ['0']

DeepSeek-V4-Flash (hidden 4096)

M HIP fused_post_pre HIP reduce HIP total Gluon fused_post_pre Gluon reduce Gluon total speedup
8 3.78 5.07 8.85 3.48 3.91 7.39 1.20x
16 3.90 5.15 9.05 3.41 3.89 7.30 1.24x
32 3.69 4.88 8.57 3.31 3.82 7.13 1.20x
64 4.80 5.51 10.31 3.74 3.98 7.72 1.34x
128 5.87 5.74 11.61 4.50 4.06 8.56 1.36x
256 7.00 6.16 13.16 5.65 4.24 9.89 1.33x
512 9.34 7.39 16.73 7.32 4.80 12.12 1.38x

err values seen (hip, gluon): ['0', '4.768e-07']

@k50112113
k50112113 requested a review from a team October 12, 2026 16:15
@k50112113 k50112113 changed the title [Triton/Gluon] [GFX12] Add gluon backend and config [Triton/Gluon] [GFX12] Add optimized gluon backend for mhc_fused_post_pre Oct 12, 2026
@github-actions

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:windows Windows JIT op smoke test on the gfx1201 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 6442 --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.

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

Automatic dispatch rejects supported inputs, and the updated test path fails for its permitted FP16 mode.

3 open findings
What changed in this PR

Adds automatic gfx1250 Gluon dispatch for optimized shuffled-residual mHC post/pre processing.

Changes:

  • Adds backend selection and residual-layout handling.
  • Tunes split-K and RMSNorm launch parameters.
  • Extends HIP/Gluon correctness and performance comparisons.
File Description
aiter/​ops/​mhc.py Adds automatic Gluon dispatch and layout selection.
aiter/​ops/​triton/​fusions/​mhc.py Adjusts split-K and RMSNorm launch sizing.
aiter/​ops/​triton/​utils/​mhc_config_utils.py Documents new tuning parameters.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​mhc/​mhc_post_pre/​DEFAULT.json Adds small-M tuning buckets.
op_tests/​test_mhc.py Compares forced HIP and Gluon paths.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread aiter/ops/mhc.py Resolved
Comment thread op_tests/test_mhc.py Resolved
Comment thread op_tests/test_mhc.py Resolved
@zufayu
zufayu requested review from a team and vgokhale October 13, 2026 01:40
@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

[ROCm/aiter] PR #6442 — [Triton/Gluon] [GFX12] Add optimized gluon backend for mhc_fused_post_pre

Routes aiter.mhc_fused_post_pre to the gfx1250 Gluon two-launch kernels — 64-wide residual shuffle blocks and retuned split-K / fused-RMSNorm launch parameters — automatically whenever the residual is shuffled and the hidden size is 4096 or 7168, where the HIP kernels ran before.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 and this account cannot open /dev/kfd (root:render; user not in the render group), so the triaged target op_tests/test_mhc.py could not run on base or head; environment gap, not a PR defect
Perf (advisory): NOT RUN — no usable GPU from this account (same /dev/kfd permission gap), so nothing was re-run; the PR's own back-to-back tables (M=8..512, hidden 4096/7168, HIP vs Gluon totals, 1.20x-1.44x) are the only timing evidence

⚠️ [verified] The automatic dispatch at aiter/ops/mhc.py:1108-1110 picks the Gluon kernels on gfx1250 whenever the residual is shuffled and hidden_size is 4096/7168, but the Gluon kernels additionally require sinkhorn_repeat>0, bf16 inputs and hc_mult==4 (mhc_post_pre_gfx1250_supported, aiter/ops/triton/fusions/mhc.py:541-593) — configs the HIP path still accepts (aiter/ops/mhc.py:1140-1142 explicitly allows sinkhorn_repeat=0, and the HIP GEMM dispatches all float16 types) now raise ValueError instead of running, and the caller's residual is already shuffled into 64-wide Gluon blocks by the new default ks, so the error's "use res_preshuffle=False" advice costs a re-shuffle. Author must confirm no consumer calls res_preshuffle=True with sinkhorn_repeat=0 / fp16 / hc_mult!=4 on gfx1250 hidden 4096/7168, or keep those configs on the HIP 32-wide blocks.

⚠️ [verified] The changed path is gfx1250-only but no CI job exercises it: the automatic aiter-test suite runs gfx942+gfx950 (GPU_ARCH_LIST in .github/workflows/aiter-test.yaml) where the new dispatch in aiter/ops/mhc.py is dormant, the opt-in ci:gfx1250-ffm-triton label (absent from the PR) runs only op_tests/triton_tests, which never calls mhc_fused_post_pre, and op_tests/test_mhc.py itself never passes backend=None — it forces "hip" and "gluon" — so the automatic production dispatch is validated only by the author's local runs. Reviewer should ask for a gfx1250 CI run of op_tests/test_mhc.py (plus a backend=None test case) before merge.

⚠️ [verified] op_tests/test_mhc.py:978-999 now hard-forces backend="gluon" for the gfx1250 comparison, which raises ValueError for fp16 inputs (the Gluon kernels take bf16 only), so --dtype fp16 — an explicit argparse choice — crashes on gfx1250 where the old code fell back to the plain Triton kernels inside mhc_post_pre, and fp16 coverage there is gone. Author must restore a plain-Triton fallback (or a logged skip) for input classes the Gluon path rejects.

📝 [verified] The perf tables carry no reproduction info — no GPU model, ROCm/driver version, or the op_tests/test_mhc.py command line behind the 1.20x-1.44x totals — M=1 (a default -m value) and 512<m<1024 sit inside the dispatch range unmeasured, and the body's "does not break e2e" claim is backed only by op-test err values, not an e2e run. Reviewer should ask for the benchmark environment, the command line, and an e2e/ATOM validation reference for the new 64-wide default.

📝 [verified] aiter/ops/mhc.py:1058-1106 returns the unfused HIP path (m>=1024 without force_fused) or the gfx950 large-M path before the Gluon branch at 1108, so backend="gluon" is silently ignored there and a benchmark forcing it on those shapes measures HIP kernels. Reviewer should ask whether backend should raise when the requested backend cannot run, or the docstring should state the force applies only below the fuse/unfuse boundary.

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

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

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.

6 participants