Repository navigation
[Triton/Gluon] gfx950: turn off SLP single-use seeding for blockwise and weight fp8 quant - #8093
Conversation
…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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 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_optslaunch 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
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
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (4)
- Apply the option only to the fnuz path, or measure e4m3fn.
quant_fp8_blockwise.py:139,250passslp-vectorize-once-used=falseon gfx950 for everyquant_dtype. The stated root cause (SLP packing the software f32→fp8 cvt) exists only for e4m3fnuz: on CDNA4 Triton lowers OCP e4m3fn with the HWv_cvt_scalef32_pk_fp8(ConvertFpCastOpToLLVM.cpp:52hasFnuzFp8HW= CDNA3 only;CvtFp32ToFp8E4M3::convert). The docstrings (:100-101) tell gfx950 users to passtorch.float8_e4m3fn, and that path gets an unmeasured codegen change (bench and tests run fnuz only). Gate onquant_dtype == torch.float8_e4m3fnuz(asquant_mxfp8.py:70gates on dtype), or post gfx950 e4m3fn numbers and fix the comment at:34-36. - 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 hasllvm_cl_optsit also callsget_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. afunctools.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/requantkeep the plain_launch_params. - Fix the comments at
:33-41and:55.:55"importing this module never probes the GPU" is false: the newfrom ...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. - 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-treereports 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_optsis per compilation (ScopedLLVMOptions, reset after the run) and part ofHIPOptions.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]>
|
@valarLip Thanks for the review. All four items are addressed in b6529c1; the details are in my earlier comment (#8093 (comment)). In short:
|
valarLip
left a comment
There was a problem hiding this comment.
✅ LGTM
All four items from my previous review are fixed at b6529c1. Thanks for the relation and ISA write-up.
Prior asks (682d805)
- fnuz-only gating: fixed.
quant_fp8_blockwise.py:59appliesslp-vectorize-once-used=falseonly forfloat8_e4m3fnuzon gfx950. e4m3fn and other archs keep_launch_params. - Per-launch host cost: fixed.
_fnuz_quant_launch_params(:54-61) is cached withfunctools.cacheon(block_size, quant_dtype), soget_arch()runs once per key.segment_m/act_grad/requantare unchanged. - 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.
- #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_optsis a per-compilationHIPOptionsfield, 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).

Summary
On gfx950 with Triton 3.9,
quant_fp8_blockwiseandquant_fp8_blockwise_for_weightare 6–9% and 4–5% slower than with Triton 3.8.0. This PR passesllvm_cl_opts="slp-vectorize-once-used=false"to those two kernel launches only, which brings both back to 3.8.0 performance.Motivation
bench_quant_fp8_blockwise(blockwise and weight columns).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.<2 x float>/<4 x i8>vectors.v_lshrrev_b32_sdwa … BYTE_1,v_or_b32) and unpacks them again (v_bitop3_b16, shifts).v_cvt_*pk_fp8, 487 instructions in the blockwise kernel) and is not affected.Changes
aiter/ops/triton/quant/quant_fp8_blockwise.py:_no_slp_once_used(), which returns the option only when the installed Triton'sHIPOptionshasllvm_cl_opts;_fnuz_quant_launch_params(block_size, quant_dtype), cached withfunctools.cache, which adds the option only whenquant_dtypeisfloat8_e4m3fnuzand the arch is gfx950, so the arch lookup and dict merge happen once per key, not per launch;quant_fp8_blockwiseandquant_fp8_blockwise_for_weightlaunches. Other targets (gfx942, gfx90a, gfx1250) and the OCP e4m3fn path keep their current codegen.act_grad,requantandsegment_mare already faster on 3.9.batched_gemm_a16wfp412–19% andpa_prefill10–12%.Relation to #7905
a9a6edb5935cafterwards.Performance
f1bf9132(mengfei-jiang/tritonrelease_for_aiter_1031) + LLVM322aa8b7.7cb7b059.39b5c8a8f), with and without this PR.bench_quant_fp8_blockwise.pyblockwise, 6 shapes (4096–8192 x 4096–8192)Example, blockwise 8192 x 8192: 3.8.0 96.8 µs; 3.9 103.8 µs; 3.9 + this PR 97.3 µs.
Testing
op_tests/triton_tests/quant/test_quant_fp8_blockwise.py: 22 passed with Triton 3.8.0 and with 3.9 (MI350X).Documentation
Internal compiler option for two launches; there is no user-facing API change.
Dependencies
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 raisesKeyErroron unknown launch options), nothing is passed.Validation and unverified scope
39b5c8a8fwith and without this PR, Triton 3.8.07cb7b059and the 3.9 release candidatef1bf9132. 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.f1bf9132;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:
llvm_cl_opts(e.g. 3.8.0): its JIT raisesKeyError: Keyword argument llvm_cl_opts was specified but unrecognised. The PR probesHIPOptions.__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).llvm_cl_optsbut an LLVM older thana9a6edb5935c: 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 throughllvm::cl::ParseCommandLineOptions(..., &llvm::nulls())inlib/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_infoprobes at import) and should not go into the squash text.🤖 Generated with Claude Code