Skip to content

[Triton/Gluon] gfx950: turn off SLP single-use seeding for blockwise and weight fp8 quant - #8093

Merged
valarLip merged 7 commits into
ROCm:mainfrom
yanxuer-999:fix/gfx950-quant-fp8-blockwise-slp-once-used
Nov 26, 2026
Merged

valarLip merged 7 commits into
ROCm:mainfrom
yanxuer-999:fix/gfx950-quant-fp8-blockwise-slp-once-used

Conversation

@yanxuer-999

@yanxuer-999 yanxuer-999 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On gfx950 with Triton 3.9, quant_fp8_blockwise and quant_fp8_blockwise_for_weight are 6–9% and 4–5% slower than with Triton 3.8.0. This PR passes llvm_cl_opts="slp-vectorize-once-used=false" to those two kernel launches only, which brings both back to 3.8.0 performance.

Motivation

  • The Triton 3.9 release weekly perf compare (MI350X) confirms the regression in bench_quant_fp8_blockwise (blockwise and weight columns).
  • Root cause: LLVM a9a6edb5935c ("[SLP]Vectorize single-user instructions as the last-attempt seeds"), which is in Triton's frontend LLVM since [LLVM] Update LLVM to 18f9e623 triton-lang/triton#12236.
    • SLP now also seeds from single-use values and packs the software f32 → fp8 (e4m3fnuz) conversion into <2 x float> / <4 x i8> vectors.
    • gfx950 has no such vector ALU, so the backend builds them byte by byte (v_lshrrev_b32_sdwa … BYTE_1, v_or_b32) and unpacks them again (v_bitop3_b16, shifts).
    • On main's launch config (block 128, num_warps 4) the blockwise kernel goes from 3440 instructions / 2699 VALU on 3.8.0 to 3590 / 2860 on 3.9 (+161 VALU); the weight kernel from 3330 / 2578 to 3402 / 2771. The kernels are limited by instruction issue, so the time grows by about the same amount.
    • Only the e4m3fnuz output takes this software conversion on gfx950. OCP e4m3fn uses the hardware convert (v_cvt_*pk_fp8, 487 instructions in the blockwise kernel) and is not affected.
  • Ruled out: the Triton IR is identical between 3.8 and 3.9, and FP fusion has no effect (the asm is byte-identical with it on or off).
  • With the option off, the 3.9 kernels compile to 3389 / 2665 (blockwise) and 3323 / 2578 (weight), back to 3.8.0's level.

Changes

  • aiter/ops/triton/quant/quant_fp8_blockwise.py:
    • add _no_slp_once_used(), which returns the option only when the installed Triton's HIPOptions has llvm_cl_opts;
    • add _fnuz_quant_launch_params(block_size, quant_dtype), cached with functools.cache, which adds the option only when quant_dtype is float8_e4m3fnuz and the arch is gfx950, so the arch lookup and dict merge happen once per key, not per launch;
    • use it for the quant_fp8_blockwise and quant_fp8_blockwise_for_weight launches. Other targets (gfx942, gfx90a, gfx1250) and the OCP e4m3fn path keep their current codegen.
  • Not changed:
    • act_grad, requant and segment_m are already faster on 3.9.
    • Not applied globally: turning the option off for all kernels costs batched_gemm_a16wfp4 12–19% and pa_prefill 10–12%.

Relation to #7905

Performance

  • 3.9: Triton f1bf9132 (mengfei-jiang/triton release_for_aiter_1031) + LLVM 322aa8b7.
  • 3.8.0: 7cb7b059.
  • AITER: main (39b5c8a8f), with and without this PR.
  • Method: fresh container, 3 interleaved rounds, Triton cache cleared before every run.
  • Change is vs 3.8.0 without this PR; positive = faster.
Hardware Workload/configuration Before (3.9) After (3.9 + this PR) Change
MI350X (gfx950) bench_quant_fp8_blockwise.py blockwise, 6 shapes (4096–8192 x 4096–8192) −5.8% to −7.0% vs 3.8.0 −0.4% to −1.3% vs 3.8.0 +5.5% to +5.8%
MI350X (gfx950) same, weight column −4.0% to −5.0% vs 3.8.0 −0.3% to −1.2% vs 3.8.0 +3.3% to +4.4%
MI350X (gfx950) same, act_grad / requant / segment_m +1.1% to +3.7% vs 3.8.0 unchanged ±0.3%
MI350X (gfx950) all columns, Triton 3.8.0 — — ±0.6% (no-op)

Example, blockwise 8192 x 8192: 3.8.0 96.8 µs; 3.9 103.8 µs; 3.9 + this PR 97.3 µs.

Testing

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

op_tests/triton_tests/quant/test_quant_fp8_blockwise.py: 22 passed with Triton 3.8.0 and with 3.9 (MI350X).

Documentation

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

Internal compiler option for two launches; there is no user-facing API change.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None

PR Self-Review

Reviewed revision

b6529c1

Behavior and intent

Only the compiler options of two quant kernel launches change. The numerical result is the same: the same scalar operations, without vector packing, and the unit tests pass. On Triton builds without llvm_cl_opts (e.g. 3.8.0, whose JIT raises KeyError on unknown launch options), nothing is passed.

Validation and unverified scope

  • Validated on MI350X (gfx950), AITER main 39b5c8a8f with and without this PR, Triton 3.8.0 7cb7b059 and the 3.9 release candidate f1bf9132. Fresh container, 3 interleaved rounds, Triton cache cleared per run.
    • python op_tests/op_benchmarks/triton/bench_quant_fp8_blockwise.py (default sweep): results in the Performance table above.
    • pytest op_tests/triton_tests/quant/test_quant_fp8_blockwise.py: 22 passed on 3.8.0 and on 3.9.
  • What remains unverified:
    • performance on MI300X (gfx942) and MI250X (gfx90a);
    • Triton main builds newer than f1bf9132;
    • end-to-end model runs (only the op bench and op tests were run).

PR-specific question

Most important boundary / failure mode: passing an LLVM option that the installed Triton or LLVM does not know. There are two layers, each with evidence:

  1. Triton without llvm_cl_opts (e.g. 3.8.0): its JIT raises KeyError: Keyword argument llvm_cl_opts was specified but unrecognised. The PR probes HIPOptions.__dataclass_fields__ and passes nothing in that case. Evidence: the 3.8.0 bench is a no-op (±0.6%) and its unit test passes (22/22).
  2. Triton with llvm_cl_opts but an LLVM older than a9a6edb5935c: this exists, because triton#12382 (llvm_cl_opts, merged 2026-10-20 15:23 UTC) landed before the LLVM bump triton#12236 (2026-10-21 02:52 UTC). Triton applies the options through llvm::cl::ParseCommandLineOptions(..., &llvm::nulls()) in lib/Tools/LLVMOptions.cpp, documented as "Keep ignoring unknown options, which may differ between LLVM revisions". So the option is silently ignored there, and those builds don't have the regression anyway.

The option only changes SLP seeding inside these two kernels: no numerical change, verified by the unit tests.

Changed op tests

None

Squash message: please use the PR title and summary; commit 221865f's sentence "importing the module still does not probe the GPU" is wrong (arch_info probes at import) and should not go into the squash text.

🤖 Generated with Claude Code

…ight fp8 quant

With Triton 3.9's LLVM (since triton#12236), the SLP vectorizer also seeds from
single-use values (llvm a9a6edb5935c). In quant_fp8_blockwise_kernel and
quant_fp8_blockwise_for_weight_kernel it packs the software f32 -> fp8 (e4m3fnuz)
conversion into <2 x float> / <4 x i8> vectors that gfx950 has to unpack again with
byte inserts and shifts: the blockwise kernel grows by about 6% in instructions, and
the quant runs 6-9% (blockwise) and 4-5% (weight) slower than with Triton 3.8.0.

Pass llvm_cl_opts="slp-vectorize-once-used=false" to these two launches only.
act_grad, requant and segment_m are already faster on 3.9 and are left alone;
turning the option off globally would cost other kernels 10-19%. Triton builds
without llvm_cl_opts reject unknown launch options, so the option is only passed
when HIPOptions has the field.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@yanxuer-999
yanxuer-999 requested a review from a team November 17, 2026 09:39
@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 8093 --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] gfx950: turn off SLP single-use seeding for blockwise and weight fp8 quant [Triton/Gluon] gfx950: turn off SLP single-use seeding for blockwise and weight fp8 quant Nov 17, 2026
@aiter-bot

aiter-bot commented Nov 17, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 979a3f8e792c · 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 is the most important boundary or failure mode introduced by this change, and what evidence covers it?
  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 — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

Dewei-Wang-sh
Dewei-Wang-sh previously approved these changes Nov 17, 2026

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 gfx950 workaround checks only compiler support, unintentionally changing compilation on unvalidated GPU targets, so both call sites need gfx950-specific gating without import-time GPU probing.

1 open issue
What changed in this PR

This PR addresses the reported Triton 3.9 performance regression in AITER’s blockwise and weight FP8 quantization on gfx950 by disabling single-use SLP vectorization seeds for two kernel launches.

Changes:

  • Detects whether Triton supports the llvm_cl_opts launch option.
  • Applies the workaround to blockwise and weight quantization, leaving other quantization launches unchanged.
File Description
aiter/​ops/​triton/​quant/​quant_fp8_blockwise.py Adds compiler-option detection and applies the SLP workaround to two launches.

Review effort: Balanced

@zufayu
zufayu requested review from a team and Boss2002n November 18, 2026 01:25
yanxuer-999 and others added 2 commits November 18, 2026 10:17
The slp-vectorize-once-used workaround was measured on gfx950 only, but the
launches passed it on every AMD target whose Triton has llvm_cl_opts (gfx942,
gfx90a, gfx1250). Check the launch target with arch_info.get_arch() at launch
time, so other targets keep their current codegen and importing the module still
does not probe the GPU.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Action required before merge (4)

  1. Apply the option only to the fnuz path, or measure e4m3fn. quant_fp8_blockwise.py:139,250 pass slp-vectorize-once-used=false on gfx950 for every quant_dtype. The stated root cause (SLP packing the software f32→fp8 cvt) exists only for e4m3fnuz: on CDNA4 Triton lowers OCP e4m3fn with the HW v_cvt_scalef32_pk_fp8 (ConvertFpCastOpToLLVM.cpp:52 hasFnuzFp8HW = CDNA3 only; CvtFp32ToFp8E4M3::convert). The docstrings (:100-101) tell gfx950 users to pass torch.float8_e4m3fn, and that path gets an unmeasured codegen change (bench and tests run fnuz only). Gate on quant_dtype == torch.float8_e4m3fnuz (as quant_mxfp8.py:70 gates on dtype), or post gfx950 e4m3fn numbers and fix the comment at :34-36.
  2. Remove the per-launch host cost on every arch. Every launch of both ops now calls _no_slp_once_used_on_gfx950() and unpacks another dict; with a Triton that has llvm_cl_opts it also calls get_arch() per launch. In-process A/B (pinned core, interleaved, base/base and head/head controls within ±20 ns): +70..125 ns on Triton 3.8 (today's CI pin, any arch), +170..310 ns on gfx942/gfx1250 with Triton 3.9, which never get the option. Resolve it once: e.g. a functools.cached helper keyed on (block_size, quant_dtype) returning the merged launch kwargs (arch looked up on first call). Measured ~300-500 ns cheaper than base. segment_m / act_grad / requant keep the plain _launch_params.
  3. Fix the comments at :33-41 and :55. :55 "importing this module never probes the GPU" is false: the new from ...utils._triton import arch_info (:15) runs _probe_arch() at import (arch_info.py:17-20); with the cached helper from item 2 it can simply go. The same claim is in the 221865f commit message; please drop it from the squash text. In :33-41, link the upstream tracker (AMD-Triton/triton-tickets#2129 or an LLVM issue) and state when the workaround can be removed.
  4. State how this relates to #7905 and correct the ISA evidence. #7905 (yours, open) fixes the same A4 regression on the same launch line with a pinned 16-warp gfx950 config and git merge-tree reports a content conflict. This PR's body cites "898 → 953 for the num_warps=16 variant", but main launches block 128 with 4 warps (_launch_params, :65) and your bench ran 4 warps; #7905 also attributes the cause differently (bf16→fp32→fp8 lowering). Say which PR supersedes the other, or post numbers for both together, and fix the ISA sentence.

Not blocking / FYI:

  • llvm_cl_opts is per compilation (ScopedLLVMOptions, reset after the run) and part of HIPOptions.hash(), so there is no leak into other kernels. The real fix belongs in the LLVM AMDGPU SLP cost model; a per-kernel knob is an acceptable stop-gap (aiter already does this for FlyDSL kernels, aiter/ops/flydsl/kernels/kernels_common.py:261).
  • This needs no ordering with #8266: on the pinned Triton 3.8.0 the probe returns {} (no-op), so CI never exercises the option until #8266 lands. #7544 does not overlap.
  • CI at 682d805 is green. The earlier 221865f failures (Standard Tests / Triton shard 5 / OPUS) were Docker Hub pull-rate-limit errors, not this PR and not FlyDSL.

Reviewed at 682d805 (Deep tier: orchestrator pass + 2 verifiers + independent pass B). Already fixed: Copilot's gfx950-only gating ask (221865f).

…e it once

Address review on the slp-vectorize-once-used workaround:

- Apply it only when quant_dtype is float8_e4m3fnuz on gfx950. The SLP packing
  it avoids is in the software f32 -> fnuz conversion; OCP e4m3fn uses the
  hardware convert on gfx950 (v_cvt_*pk_fp8, 487 instructions in the blockwise
  kernel) and compiles to identical assembly with or without the option.
- Resolve the launch kwargs once per (block_size, quant_dtype) with
  functools.cache instead of building them and calling get_arch() per launch.
- Fix the comments: link AMD-Triton/triton-tickets#2129, state when the
  workaround can be removed, and drop the incorrect claim that importing the
  module does not probe the GPU (arch_info probes at import).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@Dewei-Wang-sh Dewei-Wang-sh 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

@yanxuer-999

yanxuer-999 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@valarLip Thanks for the review. All four items are addressed in b6529c1; the details are in my earlier comment (#8093 (comment)). In short:

  1. The option now applies only to float8_e4m3fnuz on gfx950. On gfx950, e4m3fn uses the hardware convert and compiles to identical assembly with or without the option, so it's left alone.
  2. Launch kwargs are resolved once per (block_size, quant_dtype) with functools.cache, so there is no per-launch arch lookup or dict merge.
  3. The comment is fixed: the wrong "does not probe the GPU" claim is gone, it links AMD-Triton/triton-tickets#2129, and it says when the workaround can be removed. Please keep 221865f's sentence out of the squash text, as noted in the description.
  4. The ISA numbers are corrected for main's 4-warp config: 3440 → 3590 instructions (+161 VALU) on 3.9, and 3389 with this change. The description now has a "Relation to [Triton/Gluon] gfx950: recover three regressions from the LLVM 18f9e623 bump #7905" section with combined numbers; the two PRs are complementary.

@yanxuer-999
yanxuer-999 requested a review from valarLip November 24, 2026 03:36

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ LGTM

All four items from my previous review are fixed at b6529c1. Thanks for the relation and ISA write-up.

Prior asks (682d805)

  1. fnuz-only gating: fixed. quant_fp8_blockwise.py:59 applies slp-vectorize-once-used=false only for float8_e4m3fnuz on gfx950. e4m3fn and other archs keep _launch_params.
  2. Per-launch host cost: fixed. _fnuz_quant_launch_params (:54-61) is cached with functools.cache on (block_size, quant_dtype), so get_arch() runs once per key. segment_m / act_grad / requant are unchanged.
  3. Comments: fixed. The comment links AMD-Triton/triton-tickets#2129 and says when to remove the workaround. The false "never probes the GPU" line is gone.
  4. #7905 relation and ISA numbers: fixed. The body uses main's 4-warp numbers and gives combined measurements. The two PRs are complementary; whichever lands second should merge the two launch-param helpers into a single cache.

FYI (no action needed):

  • llvm_cl_opts is a per-compilation HIPOptions field, so nothing leaks to other kernels. The __dataclass_fields__ check probes Triton, not aiter, and it is needed: Triton 3.8.0 and the upstream PyPI 3.9.0 wheel reject the kwarg.
  • gfx950 production callers use OCP e4m3fn (aiter dtypes.fp8, ATOM lumen), so this only helps fnuz callers such as the bench and the tests.
  • The CI at this head ran before #8266 (Triton 3.9.0 24d5394c) was merged, so the option path was off in CI. Re-running Triton shard 5 on current main before merge would exercise it.
  • Squash: use the PR title and summary, without 221865f's "does not probe the GPU" sentence, as you noted.

Reviewed at b6529c1 (round 2: pass A + independent pass B). Already fixed: all 4 asks from 682d805; Copilot's gfx950-only gating (221865f).

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at 979a3f8 (only a merge of main since b6529c1; the PR's own change to quant_fp8_blockwise.py is unchanged).

@valarLip
valarLip merged commit b49b9c2 into ROCm:main Nov 26, 2026
67 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.

6 participants