Skip to content

[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

Merged
brunomazzottiamd merged 3 commits into
ROCm:mainfrom
Ragua1:gfx11-sw-emulated-fp8
Oct 27, 2026

Conversation

@Ragua1

@Ragua1 Ragua1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

utils/types.py treats gfx1100, gfx1101, gfx1102, gfx1150 and gfx1151 as fp8-capable since #5217: get_fp8_dtypes() returns float8_e4m3fn and float8_e5m2 there. arch_info.is_fp8_avail() and FP8_ARCHS in flash_attn_triton_amd/utils.py do not list these archs, so on gfx11 the mha_v3 entry 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() and FP8_ARCHS as 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: add is_sw_emulated_fp8_avail() for gfx1100, gfx1101, gfx1102, gfx1150 and gfx1151, the gfx11 archs get_fp8_dtypes() already lists.
  • flash_attn_triton_amd/utils.py: add SW_EMULATED_FP8_ARCHS and GpuArch.supports_sw_emulated_fp8; the fp8 checks in fwd_prefill.py, fwd_decode.py and bwd.py accept either property.
  • Tests: test_mha_fp8.py, test_mha_v3.py and test_quant_mxfp8.py run on the emulated archs. The DeepSeek-V4 fused quant tests added to test_quant_mxfp8.py in [Triton/Gluon] [GFX12] Gluon a8w8 Sparse MLA #6116 keep their own is_fp8_avail() check. test_mha_v3.py gets test_flash_attn_kvcache_fp8: fp8 decode through flash_attn_with_kvcache with pre-quantized e4m3 q, k_cache and v_cache, per-(batch, kv head) descale factors and cache_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.py and test_fused_bmm_rope_kv_cache.py keep is_fp8_avail(): they are not validated on gfx11, and several gemm_afp8wfp8 variants assert gfx950. Each family can opt in separately once it is validated.
  • csrc/cpp_itfs/utils.py: add gfx1101 to allowed_archs in validate_and_update_archs(). With GPU_ARCHS unset, get_gfx_runtime() returns gfx1101 and the assertion fails; only GPU_ARCHS=native passes, because the check runs before native is resolved. This affects the Linux JIT build of the cpp_itfs modules 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, because get_fp8_dtypes() does not list it. allowed_archs gets 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, aiter main @ adfafd1d without and with this change. A sample of 96 evenly spaced tests per file.

  • Instructions: a 64x64x64 tl.dot on float8_e4m3fn and on float8_e5m2 operands, amdgcn inspected, output compared with an fp32 matmul of the same inputs.
  • fp8 tests: test_quant_mxfp8.py, test_mha_fp8.py, test_mha_v3.py -k fp8, and all 32 cases of the new test_mha_v3.py -k kvcache_fp8.
  • allowed_archs: validate_and_update_archs() with GPU_ARCHS unset, gfx1101 and native. op_tests/test_sampling.py on Linux (WSL2, same torch and ROCm build), run before the rebase on main @ 53efe606 with this change, AITER_TRITON_ONLY=1 and GPU_ARCHS unset, so the kernels are built through the new allowed_archs entry. CK_DIR pointed 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 sets HSA_OVERRIDE_GFX_VERSION=11.0.1; the generated Makefiles use --offload-arch=gfx1101.

Test Result

Both fp8 dtypes compile to v_wmma_f32_16x16x16_f16 with no fp8 conversion instruction; maximum absolute difference to the fp32 reference 1.9e-6.

Test file Before After
test_quant_mxfp8.py 96 skipped 61 passed, 35 skipped (31 DeepSeek-V4 fused quant tests that keep is_fp8_avail(), 4 Gluon, gfx950/gfx1250 only)
test_mha_fp8.py 96 skipped 66 passed, 28 skipped (existing FP8/FUSED + CAUSAL skips), 2 failed (out of memory)
test_mha_v3.py -k fp8 96 skipped 94 passed, 2 failed (out of memory)
test_mha_v3.py -k kvcache_fp8 (new, 32 cases) n/a 32 passed

None of the sampled tests failed on a numerical check or on compilation. With this change -k fp8 collects 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 change validate_and_update_archs() fails its assertion with GPU_ARCHS unset or gfx1101; after it, it returns ['gfx1101'] in all three cases.

op_tests/test_sampling.py on Linux: 270 passed, 4 skipped, 88 failed. All 88 failures are the JIT build of module_top_k_per_row, used by the top-k fast path; that module is not gated by allowed_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_VOCAB in aiter/ops/sampling.py raised above any vocabulary size), all 48 degenerate-row cases, 24 of which had failed through it, run through sampling.cuh and pass. No test of the cpp_itfs/sampling kernels failed.

Not included

types._is_fp8(), the fp8 check of the attention.mha entry points (mha.py, mha_fused_bwd.py, mha_onekernel_bwd.py), is unchanged, with a comment pointing here. flash_attn_func with backend="triton" does not pass q_descale, k_descale and v_descale on 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 at tl.load(descale_q_ptr + ...) with descale_q_ptr=None, for the forward and for both backward modes; flash_attn_fused_backward and flash_attn_onekernel_backward also read descale_q.stride(0) with descale_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_N is 64 for gfx1100 only; gfx1151 has its own config. This PR leaves gfx1101 at 32. On gfx1101 with bf16 inputs, measured on aiter main @ b3ad6c46 in 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=6 limits it to 240 VGPRs. At head dimension 128 with the causal mask, BLOCK_N=64 spills 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

@Ragua1
Ragua1 requested a review from a team October 21, 2026 19:02
@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 6782 --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.

@github-actions github-actions Bot changed the title [Triton] Add arch_info.is_sw_emulated_fp8_avail() for gfx11 and enable the Triton MHA fp8 path and the MXFP8 quant tests on it [Triton/Gluon] [HIP] Add arch_info.is_sw_emulated_fp8_avail() for gfx11 and enable the Triton MHA fp8 path and the MXFP8 quant tests on it Oct 21, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 21, 2026 21:33

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 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 gfx1101 in 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

Comment thread aiter/ops/triton/utils/types.py Resolved
@zufayu
zufayu requested review from a team and azaidy October 22, 2026 01:15
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]>

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

Thanks for you PR! Please take a look at my comments.

Comment thread csrc/cpp_itfs/utils.py Resolved
Comment thread aiter/ops/triton/utils/types.py Resolved
@brunomazzottiamd

Copy link
Copy Markdown
Contributor

Added ci:triton-300x label so we can trigger test execution on gfx942. I want to be sure nothing breaks in gfx942.

… 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]>
@github-actions github-actions Bot changed the title [Triton/Gluon] [HIP] Add arch_info.is_sw_emulated_fp8_avail() for gfx11 and enable the Triton MHA fp8 path and the MXFP8 quant tests on it [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 Oct 24, 2026
@github-actions github-actions Bot removed the HIP label Oct 24, 2026
@Ragua1

Ragua1 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

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

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.

@Ragua1

Ragua1 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

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.

fwd_prefill, gfx1101 Time vs fp16
fp16, current RDNA config 0.409 ms 1x
fp8 e4m3fn, current RDNA config 8.99 ms 22x
fp8 e4m3fn, BLOCK_N=16, fastest of 270 configs searched 5.19 ms 12.7x

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 v_wmma_f32_16x16x16_f16. The fp8 build has 21,121 instructions against about 870 for fp16. Most of the extra instructions are the fp8-to-fp16 conversion (5,328 v_cmp_ne_u16, 5,611 v_cndmask) and spill code (164 VGPR spills, none in fp16).

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 (FP8_P_DESCALE=False). How much of the gap each part explains is not measured yet.

@brunomazzottiamd

Copy link
Copy Markdown
Contributor

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.

@brunomazzottiamd
brunomazzottiamd merged commit e83832f into ROCm:main Oct 27, 2026
86 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.

4 participants