Skip to content

[Triton/Gluon] fix gluon import and benchmark + tune fused_clamp_act_mul for gfx950 - #5800

Merged
brunomazzottiamd merged 6 commits into
ROCm:mainfrom
nidal567:fused_clamp_act_mul_bench_tune
Oct 2, 2026
Merged

brunomazzottiamd merged 6 commits into
ROCm:mainfrom
nidal567:fused_clamp_act_mul_bench_tune

Conversation

@nidal567

Copy link
Copy Markdown
Contributor

Motivation

On gfx950, fused_clamp_act_mul regression on Triton 3.8 at large-M prefill shapes up to 7.2%

M N (n_half) Triton 3.4 Triton 3.8 delta
16384 2048 34.02 us 36.47 us +7.18%
8192 4096 34.44 us 36.00 us +4.52%
16384 4096 62.26 us 64.88 us +4.21%

The kernel was not tuned at M, as it was only tuned previously on row width (N). Essentially, M=1 and M=16384 at the same N received the same launch config. The triton path launches grid=(M,), meaning one program per row, and BLOCK_SIZE_N is the whole row. In this case, num_warps is the only knob to be tuned, and past a few thousand rows, the grid alone fills the GPU. The shipped width-keyed value is tuned for small M and is too high for prefill. Decode (M <= 128) is unaffected and measures identically on both compilers.

Also, the benchmark for this kernel was not usable on main. It fails to import _is_gluon_available() and it crashes rocprofv3 runs for shapes due to rep being hardcoded. Both issues are fixed here.

Technical Details

The kernel now checks the N-specialized FUSED_CLAMP_ACT_MUL-N={N}.json for the largest M_GEQ_<x> <= M before falling back to the existing DEFAULT.json, which is unchanged.

aiter/ops/triton/fusions/fused_clamp_act_mul.py                     +32 -8
op_tests/op_benchmarks/triton/bench_fused_clamp_act_mul.py          +10 -2
configs/gfx950/triton/fusions/fused_clamp_act_mul/FUSED_CLAMP_ACT_MUL-N=2048.json  (new)
configs/gfx950/triton/fusions/fused_clamp_act_mul/FUSED_CLAMP_ACT_MUL-N=4096.json  (new)

Tuned values (gfx950, from a num_warps sweep of 1/2/4/8/16 per shape):

N shipped M >= 4096 M >= 16384
2048 4 2 1
4096 8 4 4
512, 8192 1, 8 unchanged (optimal)

Benchmark fixes

  • is_gluon_available() restored, as the benchmark didn't import properly. The guard now asserts properly.
  • --rep made configurable, because the default 100 crashes rocprofv3. Make it an argument so that one can define the number of reps desired.

Test Plan

  • Correctness tests with pytest
  • Black and Ruff checks
  • rocprofv3 --kernel-trace runs with kernel time (10/80/10 trimmed mean)
  • 23 shapes: N in {512, 2048, 4096, 8192} x M in {1, 16, 64, 128, 4096, 8192, 16384}, covering every config bucket plus decode and prefill

Test Result

23 shapes: 0 regressions, 5 improvements, 18 neutral. The 5 improvements are exactly the 5 measured shapes whose num_warps changes; every shape whose routing is unchanged is neutral.

M N main this PR change
4096 2048 9.95 us 9.31 us -6.4%
16384 2048 36.46 us 34.63 us -5.0%
4096 4096 19.07 us 18.44 us -3.3%
8192 4096 35.89 us 34.62 us -3.5%
16384 4096 65.60 us 63.17 us -3.7%

Decode unchanged. All 13 shapes at M <= 128 are neutral
Correctness: 330 passed, 454 skipped, 200 warnings in 16.15s
Style: black and ruff==0.16.0 clean.
Benchmark: imports and runs; its default sweep profiles under rocprofv3 without crashing, and --rep 100 still reproduces the SIGSEGV on --shape 1 512 and --shape 16384 512.

Submission Checklist

@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; main branch always runs both MI35X and MI300X
multigpu 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 5800 --add-label <label>

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 opt this PR out.

@nidal567 nidal567 changed the title fix gluon import exception and benchmark + tune with fused_clamp_act_… fix gluon import and benchmark + tune fused_clamp_act_mul for gfx950 Sep 23, 2026

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

Proposed change makes sense. I'm only worried about code complexity and AI-driven code duplication. Please evaluate my requests with your own judgement.

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

  1. Why tune for only 1 or 2 Ms? Why not more?
  2. Can you state the benchmark command you used for the sweep just for reference so that we know if default args were used or more?

@zufayu
zufayu requested review from a team and azaidy September 26, 2026 00:20
@nidal567
nidal567 force-pushed the fused_clamp_act_mul_bench_tune branch from ffb9d2a to 696ea1a Compare September 28, 2026 18:16
@github-actions github-actions Bot changed the title fix gluon import and benchmark + tune fused_clamp_act_mul for gfx950 [Triton/Gluon] fix gluon import and benchmark + tune fused_clamp_act_mul for gfx950 Sep 28, 2026

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

This comment was marked as low quality.

@brunomazzottiamd

Copy link
Copy Markdown
Contributor

Unrelated test failures on gfx942:

  • op_tests/triton_tests/attention/test_pa_mqa_logits_mxfp4.py
  • op_tests/triton_tests/rope/test_rope_mxfp4.py

I think it's asserting arch == gfx950 for Gluon kernels.

@brunomazzottiamd

Copy link
Copy Markdown
Contributor

Unrelated test failures on gfx942:

  • op_tests/triton_tests/attention/test_pa_mqa_logits_mxfp4.py
  • op_tests/triton_tests/rope/test_rope_mxfp4.py

I think it's asserting arch == gfx950 for Gluon kernels.

Should be fixed by #5958.

@nidal567
nidal567 force-pushed the fused_clamp_act_mul_bench_tune branch from d38d553 to c9e2ac1 Compare September 30, 2026 16:23
azaidy
azaidy previously approved these changes Sep 30, 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.

Last nit. Either address it here on in a follow up if CI has passed.

@nidal567
nidal567 dismissed stale reviews from azaidy and brunomazzottiamd via ce1c3af September 30, 2026 18:26
@nidal567
nidal567 force-pushed the fused_clamp_act_mul_bench_tune branch from c9e2ac1 to ce1c3af Compare September 30, 2026 18:26

@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! Thanks for the contribution and addressing the multiple rounds of review.

@brunomazzottiamd
brunomazzottiamd merged commit 3eca6e4 into ROCm:main Oct 2, 2026
26 checks passed
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