Repository navigation
[Triton/Gluon] Add arch_info.is_sw_emulated_fp8_avail() for gfx11 and enable the Triton MHA fp8 path and the MXFP8 quant tests on it - #6782
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
The newly enabled legacy MHA and FP8 decode paths lack direct numerical test coverage.
2 open issues
What changed in this PR
This PR separates software-emulated FP8 support from native hardware support and enables selected Triton attention paths and quantization tests on gfx11.
Changes:
- Add a software-emulated FP8 capability check without changing native FP8 checks.
- Enable gfx11 FP8 gates in MHA and existing attention and MXFP8 test suites.
- Allow
gfx1101in the C++ interface JIT build architecture list.
| File | Description |
|---|---|
op_tests/triton_tests/quant/test_quant_mxfp8.py |
Enable Triton MXFP8 tests on emulated architectures. |
op_tests/triton_tests/attention/test_mha_v3.py |
Extend FP8 test eligibility to gfx11. |
op_tests/triton_tests/attention/test_mha_fp8.py |
Extend the FP8 suite’s architecture gate. |
csrc/cpp_itfs/utils.py |
Allow gfx1101 for JIT builds. |
aiter/ops/triton/utils/types.py |
Accept software-emulated FP8 in legacy MHA detection. |
aiter/ops/triton/utils/_triton/arch_info.py |
Add the software-emulated FP8 capability helper. |
aiter/ops/triton/_triton_kernels/flash_attn_triton_amd/utils.py |
Add the emulated architecture set and capability property. |
aiter/ops/triton/_triton_kernels/flash_attn_triton_amd/fwd_prefill.py |
Permit software-emulated FP8 prefill. |
aiter/ops/triton/_triton_kernels/flash_attn_triton_amd/fwd_decode.py |
Permit software-emulated FP8 decode. |
aiter/ops/triton/_triton_kernels/flash_attn_triton_amd/bwd.py |
Permit software-emulated FP8 backward execution. |
Review effort: Balanced
Enable the Triton MHA fp8 path and the MXFP8 quant tests on gfx1100, gfx1101, gfx1102, gfx1150 and gfx1151 through software-emulated fp8, and add gfx1101 to allowed_archs in csrc/cpp_itfs/utils.py. Signed-off-by: Martin Domanský <[email protected]>
test_flash_attn_kvcache_fp8 runs flash_attn_with_kvcache on pre-quantized e4m3 inputs with descale factors and cache_seqlens, checked against a reference on the dequantized values. _is_fp8() keeps is_fp8_avail() only: the Triton backend of attention.mha does not pass descale factors on, and its forward kernel fails to compile with descale_q_ptr=None. Signed-off-by: Martin Domanský <[email protected]>
5662a12 to
4e67945
Compare
brunomazzottiamd
left a comment
There was a problem hiding this comment.
Thanks for you PR! Please take a look at my comments.
|
Added ci:triton-300x label so we can trigger test execution on |
… the decode test - Add ANY_FP8_ARCHS and GpuArch.supports_any_fp8 in flash_attn_triton_amd/utils.py and arch_info.is_any_fp8_avail(); the kernels and the tests use them instead of the repeated "hardware or software-emulated" expression. - Remove the GitHub link from the comment in utils/types.py. - Move the csrc/cpp_itfs/utils.py change to a separate [HIP] PR. - Drop test_flash_attn_kvcache_fp8: no RDNA job runs op_tests and the decode path is unchanged for the CDNA archs. Signed-off-by: Martin Domanský <[email protected]>
|
Added GpuArch.supports_any_fp8, backed by ANY_FP8_ARCHS = FP8_ARCHS | SW_EMULATED_FP8_ARCHS; the three checks in fwd_prefill.py, fwd_decode.py and bwd.py use it, and the tests import ANY_FP8_ARCHS. FP8_ARCHS and supports_fp8 are unchanged, so callers that need hardware fp8 (recommended_fp8_dtype, the gemm variants that assert gfx950) keep their meaning. On the name: the kernels ask whether the fp8 path runs on this arch, not how; any says "either set" without listing the sets, keeps the supports_ prefix of the neighbouring properties, and the same stem works in all three places (ANY_FP8_ARCHS, supports_any_fp8, arch_info.is_any_fp8_avail()). |
brunomazzottiamd
left a comment
There was a problem hiding this comment.
Hello @Ragua1. I think the PR is good and we can merge it. Let's wait for AITER CI to run and check the results before merging it.
I appreciate your effort to increase coverage in gfx11 GPU family. I also invite you to take a look at #6770. In this PR, the author dropped some FP8 stuff from Sage Attention in gfx1100 GPU because the emulated FP8 was hurting performance. So, this FP8 emulation may be a double edged sword. Take care.
I am investigating the same slowdown on gfx1101. This PR is the first step: it makes the fp8 path run on gfx11. Its performance there has several open problems, and this PR does not address them.
Kernel only, batch 2, 16 heads, sequence length 1024, head dimension 128, non-causal, Triton 3.8.0, median of 5 fresh processes. The amdgcn shows where the time goes. Both builds use the same 32 Triton generates the conversion. On gfx11 it converts fp8 in software, so the whole gfx11 family is affected, as #6770 shows on gfx1100. triton-lang/triton#11254 and triton-lang/triton#12492 target this conversion; neither is merged yet. Two parts are on the AITER side: the config, and P being cast to fp8 in every tile ( |
|
CI is green. I'm going to merge this since it enables some MHA kernels in gfx11. Performance issues can be addressed in the scope of future PRs. |

Motivation
utils/types.pytreats gfx1100, gfx1101, gfx1102, gfx1150 and gfx1151 as fp8-capable since #5217:get_fp8_dtypes()returnsfloat8_e4m3fnandfloat8_e5m2there.arch_info.is_fp8_avail()andFP8_ARCHSinflash_attn_triton_amd/utils.pydo not list these archs, so on gfx11 themha_v3entry points raise<arch> does not support FP8(fwd_prefill.py,fwd_decode.py,bwd.py), and the fp8 tests are skipped.gfx11 has no fp8 WMMA and no fp8 conversion instructions, so the existing lists are correct as a statement about hardware. Triton 3.8 nevertheless compiles fp8 on these archs: it converts fp8 operands to fp16 in software and runs the fp16 WMMA. This PR keeps
is_fp8_avail()andFP8_ARCHSas they are and adds a separate helper for software-emulated fp8, following the approach proposed for FP4 in #6685.Technical Details
aiter/ops/triton/utils/_triton/arch_info.py: addis_sw_emulated_fp8_avail()for gfx1100, gfx1101, gfx1102, gfx1150 and gfx1151, the gfx11 archsget_fp8_dtypes()already lists.flash_attn_triton_amd/utils.py: addSW_EMULATED_FP8_ARCHSandGpuArch.supports_sw_emulated_fp8; the fp8 checks infwd_prefill.py,fwd_decode.pyandbwd.pyaccept either property.test_mha_fp8.py,test_mha_v3.pyandtest_quant_mxfp8.pyrun on the emulated archs. The DeepSeek-V4 fused quant tests added totest_quant_mxfp8.pyin [Triton/Gluon] [GFX12] Gluon a8w8 Sparse MLA #6116 keep their ownis_fp8_avail()check.test_mha_v3.pygetstest_flash_attn_kvcache_fp8: fp8 decode throughflash_attn_with_kvcachewith pre-quantized e4m3q,k_cacheandv_cache, per-(batch, kv head) descale factors andcache_seqlens, checked against a reference on the dequantized inputs; the existing KV-cache tests run in bf16, so the fp8 decode path had no test on any arch. The MXFP8 quant kernels have no arch check of their own; only their tests were skipped.test_gemm_afp8wfp8.pyandtest_fused_bmm_rope_kv_cache.pykeepis_fp8_avail(): they are not validated on gfx11, and severalgemm_afp8wfp8variants assert gfx950. Each family can opt in separately once it is validated.csrc/cpp_itfs/utils.py: addgfx1101toallowed_archsinvalidate_and_update_archs(). WithGPU_ARCHSunset,get_gfx_runtime()returnsgfx1101and the assertion fails; onlyGPU_ARCHS=nativepasses, because the check runs beforenativeis resolved. This affects the Linux JIT build of thecpp_itfsmodules only.Only gfx1101 was tested. The two fp8 helpers also list gfx1100, gfx1102, gfx1150 and gfx1151 to match
get_fp8_dtypes(); gfx1103 is not listed, becauseget_fp8_dtypes()does not list it.allowed_archsgets gfx1101 only.Test Plan
gfx1101 (Radeon RX 7800 XT), Windows 11, TheRock ROCm 10.2 (
torch 2.15.0a0+rocm10.2.0a20260926), Triton 3.8.0,AITER_TRITON_ONLY=1, aitermain@adfafd1dwithout and with this change. A sample of 96 evenly spaced tests per file.tl.dotonfloat8_e4m3fnand onfloat8_e5m2operands, amdgcn inspected, output compared with an fp32 matmul of the same inputs.test_quant_mxfp8.py,test_mha_fp8.py,test_mha_v3.py -k fp8, and all 32 cases of the newtest_mha_v3.py -k kvcache_fp8.allowed_archs:validate_and_update_archs()withGPU_ARCHSunset,gfx1101andnative.op_tests/test_sampling.pyon Linux (WSL2, same torch and ROCm build), run before the rebase onmain@53efe606with this change,AITER_TRITON_ONLY=1andGPU_ARCHSunset, so the kernels are built through the newallowed_archsentry.CK_DIRpointed to a composable_kernel checkout outside the repo, because the submodule was not initialized. The current Windows driver reports this card to WSL as gfx1102, so the run setsHSA_OVERRIDE_GFX_VERSION=11.0.1; the generated Makefiles use--offload-arch=gfx1101.Test Result
Both fp8 dtypes compile to
v_wmma_f32_16x16x16_f16with no fp8 conversion instruction; maximum absolute difference to the fp32 reference 1.9e-6.test_quant_mxfp8.pyis_fp8_avail(), 4 Gluon, gfx950/gfx1250 only)test_mha_fp8.pytest_mha_v3.py -k fp8test_mha_v3.py -k kvcache_fp8(new, 32 cases)None of the sampled tests failed on a numerical check or on compilation. With this change
-k fp8collects 136 tests instead of 104, because it includes the 32 new decode cases. The four failures are out of memory in backward tests with head dimension 64 and sequence length 2048. The runner caps the PyTorch allocator at 90 % of the 16 GiB card (14.39 GiB). Run one per process, all four still exceed the cap.allowed_archs: before the changevalidate_and_update_archs()fails its assertion withGPU_ARCHSunset orgfx1101; after it, it returns['gfx1101']in all three cases.op_tests/test_sampling.pyon Linux: 270 passed, 4 skipped, 88 failed. All 88 failures are the JIT build ofmodule_top_k_per_row, used by the top-k fast path; that module is not gated byallowed_archs, and in this setup it was built against CK headers other than the pinned submodule. With the fast path disabled (_TOPK_FIRST_FAST_MIN_VOCABinaiter/ops/sampling.pyraised above any vocabulary size), all 48 degenerate-row cases, 24 of which had failed through it, run throughsampling.cuhand pass. No test of thecpp_itfs/samplingkernels failed.Not included
types._is_fp8(), the fp8 check of theattention.mhaentry points (mha.py,mha_fused_bwd.py,mha_onekernel_bwd.py), is unchanged, with a comment pointing here.flash_attn_funcwithbackend="triton"does not passq_descale,k_descaleandv_descaleon to_FlashAttnFunc(its docstring says they are honored only by the Gluon backend). With the arch check bypassed on gfx1101, fp8 inputs with descale factors fail in the Triton compilation of the forward kernel attl.load(descale_q_ptr + ...)withdescale_q_ptr=None, for the forward and for both backward modes;flash_attn_fused_backwardandflash_attn_onekernel_backwardalso readdescale_q.stride(0)withdescale_q=None. A test with pre-quantized inputs cannot pass through that path, so it stays native-only here.In the generic RDNA branch of
fwd_prefill.py,BLOCK_Nis 64 for gfx1100 only; gfx1151 has its own config. This PR leaves gfx1101 at 32. On gfx1101 with bf16 inputs, measured on aitermain@b3ad6c46in three processes of 10 rounds each, 64 was faster for head dimension 64 (median ratio 1.061 to 1.103) and slower for all five head-dimension-128 shapes (median ratio 0.672 to 0.987), most with the causal mask.The largest losses line up with register spills in the compiled kernel.
waves_per_eu=6limits it to 240 VGPRs. At head dimension 128 with the causal mask,BLOCK_N=64spills 117 VGPRs (263 scratch instructions); at head dimension 64 with the causal mask it does not spill. Without the mask both head dimensions spill 21 VGPRs, and only head dimension 64 still gains. The same kernel compiled for gfx1100 has identical VGPR counts and spills, so this is not specific to gfx1101.Related
arch_info.is_sw_emulated_fp4_avail()for Triton MXFP4 on gfx11 GPUs without native FP4 #6685 proposes the same split for FP4 (is_sw_emulated_fp4_avail()).allowed_archs; this PR touches the same list.