Repository navigation
[Triton/Gluon] [JIT] gfx1250-strict enablment fixes - #7767
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
On an MI450 A0, ROCr reports gfx1250-strict while images commonly set GPU_ARCHS=gfx1250. _needs_arch_rebuild() then rebuilds the prebuilt module "for gfx1250-strict", but build_module() took --offload-arch only from GPU_ARCHS, so the rebuilt .so again held only gfx1250 code and loading it raised ModuleNotFoundError. Every HIP JIT op failed this way on A0. Append get_gfx_runtime() to the offload-arch list when it is not already covered (and GPU_ARCHS is not "native"). The target stays the exact arch identity, as build_targets.base_gfx_arch() requires for build targets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tables Two problems kept every config-driven Triton/Gluon kernel off MI450 A0, which reports gfx1250-strict: * _ARCH_OVERRIDE_RE rejected the hyphen, so callers that pass arch=<device arch> (unified attention, mHC, MLA, sparse MLA) asserted before any kernel ran. Allow hyphen-separated suffixes. * resolve_config_dir() built configs/<exact arch>/... and only configs/gfx1250/ ships, so DEFAULT.json lookups failed. When the running arch has no tree of its own, read the base family tree (build_targets.base_gfx_arch()) with a one-time warning. Exact-arch trees still win when present, and explicit tuning scopes (a cu_num argument) never take the fallback, so tuners creating configs/gfx1250-strict/ are not redirected onto the gfx1250 tables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
get_fp8_dtypes() listed gfx1250 but not its MI450 A0 variant
gfx1250-strict, so A0 fell through to float8_e4m3fnuz / e5m2fnuz (the
gfx942 formats). gfx1250 has no fnuz WMMA, so fp8 kernels failed to compile
("no matching matrix core intrinsic ... f8E4M3FNUZ") or rejected OCP fp8
inputs. aiter/utility/dtypes.py already maps gfx1250-strict to e4m3fn.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
_LDS_CAP_BYTES had no gfx1250-strict entry, so pa_decode_sparse computed None // int on MI450 A0. A0 has the same 320 KiB LDS as gfx1250 (chip_info already lists it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kernels that are gfx1250-family code asserted or branched on the exact string "gfx1250" and so rejected MI450 A0 (gfx1250-strict) or silently took a non-gfx1250 path: Gluon mha_fp8 / mha_mxfp8, fused_compress_attn_fp4, the 4-rank Gluon all_reduce, mega_mhc (C++), FlyDSL fmha / conv dispatch and FlashKDA (whose TDM path is already gated by is_tdm_avail(), which includes strict). Accept both ids at those sites. Opus MXFP4 MQA logits is deliberately left alone: it relies on F4 WMMA, which A0 cannot use. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test gates compared the arch to the exact string "gfx1250", so on MI450 A0 (gfx1250-strict) these suites skipped every case and the kernels were never exercised. Accept the strict id in those gates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mori.jit detects the arch with rocm_agent_enumerator without -name, which
reports the base ISA (gfx1250) on MI450 A0. The EP dispatch kernel was built
for gfx1250 and hipModuleLoad rejected it on A0 ("device kernel image is
invalid"). Set MORI_GPU_ARCHS from gcnArchName when the user has not.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
flydsl.runtime.device.get_rocm_arch() prefers HSA_OVERRIDE_GFX_VERSION over the hardware, so images exporting HSA_OVERRIDE_GFX_VERSION=12.5.0 made FlyDSL emit gfx1250 (B0) code objects on MI450 A0. Set FLYDSL_GPU_ARCH (which takes priority) from gcnArchName when the user has not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Completes the previous commit (only mha_fp8.py was staged there). Same change at the other sites that asserted or branched on the exact string "gfx1250" and so rejected MI450 A0 (gfx1250-strict) or silently took a non-gfx1250 path: Gluon mha_mxfp8, fused_compress_attn_fp4, the 4-rank Gluon all_reduce, mega_mhc (C++), FlyDSL fmha / conv dispatch and FlashKDA (whose TDM path is already gated by is_tdm_avail(), which includes strict). Opus MXFP4 MQA logits is deliberately left alone: it relies on F4 WMMA, which A0 cannot use. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two more gfx1250-family sites rejected MI450 A0 (gfx1250-strict): chunk_kda's Gluon prepare/walk asserted the exact arch, and mega_mhc compared get_gfx_runtime() against "gfx1250" both in its support check and in its gfx1250 dispatch branches. Accept strict in chunk_kda and map the runtime arch through base_gfx_arch() in mega_mhc (its C++ side already accepts gfx1250-strict). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The worker initialised mori's Communicator before importing anything from
aiter, so the package's MORI_GPU_ARCHS pin ran after mori had already JIT-
compiled for the base ISA, and on MI450 A0 hipModuleLoad still rejected the
gfx1250 kernel ("device kernel image is invalid"). Import the package first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the whole-tree fallback to configs/gfx1250 with an explicit configs/gfx1250-strict/ tree. Each M-bucketed family's DEFAULT.json holds only a generic "any" entry (copied from the gfx1250 table's "any"), with no per-M buckets and no N/K-specialized files, so loaders report the config as untuned and nobody mistakes it for A0 tuning. A README in the directory says so. Families keyed by kernel variant or shape (attention, KDA, grouped GEMM, block_cat, MoE a8w4/a4w4) have no generic entry; resolve_config_dir() now falls back per family, only where configs/gfx1250-strict lacks one, and warns that the gfx1250 table is NOT tuned for gfx1250-strict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
get_quant_config() derives the bucket axes from composite keys such as M_LEQ_1.K_LEQ_1024 and raised "bucket keys must share one axis order, found []" for a table with only a generic "any" entry, as the untuned configs/gfx1250-strict tables are. Return a copy of "any" when the table has no composite bucket keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tighten three earlier changes so they cannot alter behaviour on any GPU other than MI450 A0: * jit: only add the running arch to --offload-arch when GPU_ARCHS names its base family (gfx1250 on gfx1250-strict). Previously any arch missing from GPU_ARCHS was added, which changed deliberate cross-builds on other GPUs. * flydsl / mega_moe: only pin FLYDSL_GPU_ARCH / MORI_GPU_ARCHS when the GPU is gfx1250-strict, so other GPUs (and deliberate HSA_OVERRIDE_GFX_VERSION use) keep the libraries' own detection. Detect the arch with chip_info.get_gfx_runtime() (rocminfo) instead of torch.cuda, so importing these packages no longer initialises HIP in the importing process. Co-Authored-By: Claude Opus 5.5 <[email protected]>
black (26.10.1) and ruff 0.16.0 (the version pinned in pre-checks.yaml) over the Python files this branch touches. Formatting and ruff autofixes only; no behaviour change.
Scope this branch to Triton / Gluon. Restore to d67fc6d the FlyDSL arch pin and FlyDSL fmha / conv arch checks, the MegaMoE mori arch pin and its test import-order change, the mega_mhc Python and C++ arch handling, and the arch gates in the non-Triton op_tests (mega_mhc, mla_decode_pagesize64, opus a16w16 GEMM, mla_sparse_prefill, a8w8 mxfp8 bpreshuffle). The JIT change in aiter/jit/core.py stays: Triton tests check results against aiter HIP ops whose modules must load on gfx1250-strict.
The quant config loader requires two bucket axes, so the any-only mxfp4/mxfp8 tables broke op_tests/triton_tests/quant/test_quant_configs.py. Restore quant_config_utils.py and let quant fall back to the gfx1250 tables.
fused_sigmoid_mul looks up a "strided" config for strided inputs; the any-only strict table dropped it, so 60 cases of op_tests/triton_tests/fusions/test_fused_sigmoid_mul.py raised KeyError on A0. Copy the gfx1250 strided entry.
…uant tests on gfx1250-strict These gates listed gfx1250 but not gfx1250-strict, so the files skipped every test on A0. conv2d and conv3d now pass on A0 (86/86, 152/152).
The NVFP4 skip listed only gfx1250, so A0 skipped the 24 cases that B0 runs. On A0 they now fail the same way as on B0 (GluonSemantic.full() missing layout).
…ache gates The no-rope skip and the FP4/FP8 cache-dtype skips listed only gfx1250, so A0 ran 288 cases the gfx1250 kernel rejects and skipped 240 FP4/FP8 cases B0 runs. A0 now matches B0: 512 passed, 24 failed (NVFP4), 288 skipped.
kT_mask and v_mask compare offs_n (0..BLOCK_N) against the cache length, so they only bound the first tile. Tiles past the split end read keys and values out of range; the masked scores are -inf, but garbage V still reaches p @ v, giving NaN or an illegal memory access depending on memory contents. Seen in test_mha_v3 test_flash_attn_kvcache_sliding_window on MI450 A0 and B0. Mask the loads with (start_n + offs_n) < hi, as the paged path already does.
remap_workgroup_spatial assumes the heads (and, for GQA with fewer KV heads than XCDs, the per-KV-head work) split evenly across XCDs. On a 6-XCD part (MI450 A0) the test shapes do not, so some tiles were computed twice and others never (test_mha_spatial_swizzle, 22 failures). Fall back to the default mapping for such shapes; 8-XCD parts keep the spatial mapping for every tested shape.
The compile target and options["arch"] came from get_gfx(), which follows GPU_ARCHS. With GPU_ARCHS=gfx1250 on a gfx1250-strict (MI450 A0) device the kernel was built for gfx1250, emitted v_wmma_f32_16x16x128_fp8_fp8 (not supported on gfx1250-strict) and returned wrong logits. Use the runtime arch when it is the strict variant of get_gfx(); other devices are unchanged.
…d quant_mxfp4 gates pa_prefill_sparse ran its Triton-only single-source tests on A0 (the gfx1250 dispatch then dereferenced kv=None) and skipped the gfx1250 ones; quant_mxfp4 backend_validation expected A0 to reject fp16 Gluon, and the Gluon-vs-Triton cases skipped. A0 now selects the same tests as B0.
…eshuffled tables The preshuffled afp4wfp4 kernels assert BLOCK_SIZE_M <= 16 for M < 32 (x_scale is un-shuffled there). The gfx1250-strict GEMM-AFP4WFP4_PRESHUFFLED and FUSED-GEMM-AFP4WFP4_PRESHUFFLED-A16W16 tables had only an "any" entry (BLOCK_SIZE_M 128 / 32), so every small-M call failed the assertion. Copy the gfx1250 small-M buckets (M_LEQ_8 + M_LEQ_31, and M_LEQ_8 + M_LEQ_16) into the strict tables; the untuned "any" entry is unchanged. test_fused_gemm_afp4wfp4_mul_add: 2048 passed, test_fused_gemm_afp4wfp4_a16w16: 1152 passed on gfx1250-strict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
_GLUON_ARCH_OK and _GLUON_K2C_ARCH_OK still listed only gfx950 and gfx1250, so on MI450 A0 (gfx1250-strict) flash_kda_fwd never routed K1/K2 to Gluon and silently fell back to Triton, while the TDM and scan-prefetch flags (3303bd3) already treat gfx1250-strict as gfx1250. Add gfx1250-strict to both flags so the strict part runs the same kernels. On gfx1250-strict the Gluon K2 now fails to compile on v_wmma_f32_16x16x32_bf16, which Triton 3.9 rejects for gfx1250-strict; that is a compiler issue and is not worked around here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Current-head CI has a real MI300X Triton shard-1 failure: test_triton_unified_attn_prefill_head_sizes (BF16, head_size=320) raises OutOfResources because the kernel requests 131072 bytes of shared memory on a 65536-byte device. Job: https://github.com/ROCm/aiter/actions/runs/44778210409/job/136434768434. This test was added to main by #5409 (9e1d318); this PR only broadens the gfx1250-family branch in unified_attention.py and does not change the gfx942 kernel/config. Could you coordinate a base fix for this MI300X case, then sync main and rerun the shard? I will keep the A0 patch PRs separate. |
|
I pushed a fix here: #8400 , will merge if CI passes there then sync with main here |
|
Current-head MI35X Triton shard 7 hit the 60-minute Triton Tests step timeout while tests were still passing (the last logged GEMM case passed); the job log shows no pytest assertion failure. Job: https://github.com/ROCm/aiter/actions/runs/44962740542/job/137025412234. Please split/shorten this shard or adjust its step timeout when addressing the WMMA review, then rerun CI on the updated head. |
…allback Replace gl.amd.gfx1250.wmma and gl.amd.cdna5.wmma in common/utils.py with the gfx1250-strict fp8 fallback, so the kernels keep their original wmma calls. Remove wmma_compat from the kernels. mha_fp8, gemm_a8w8_blockscale and pa_mqa_logits import utils so the patch is applied before they compile.
|
The new WMMA patch takes effect only after common/utils.py is imported. On a fresh import, attention/unified_attention.py and attention/fp8_mqa_logits.py load their gfx1250 Gluon kernels without importing that module, while the kernels now call gl.amd.gfx1250.wmma directly. Strict FP8 16x16x128 can therefore reach the unsupported native WMMA depending on import order. Please import the patch module from these entry points (or otherwise guarantee initialization before compilation) and add a fresh-process strict FP8 compile smoke for both paths. I am holding re-approval of head bd75de9 until this is addressed. |
…ogits unified_attention_2d, unified_attention_3d and fp8_mqa_logits call gl.amd.gfx1250.wmma with fp8 operands, but did not import common/utils.py. On a fresh import the gfx1250-strict fp8 patch was not applied, so strict fp8 16x16x128 could reach the native WMMA. Import utils in these kernels so the patch is applied before they compile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zufayu
left a comment
There was a problem hiding this comment.
Reviewed the changes since my previous approval at 5249225. The WMMA compatibility wrapper selects scaled FP8 only for gfx1250-strict 16x16x128 and otherwise calls the captured native function; gfx1250 and cdna5 originally export the same native implementation. The updated attention entry points import common/utils before compilation, addressing the fresh-import concern. No unresolved review thread remains. Approving this head; the separate CI failures and main sync still need attention.
|
Latest CI has a separate MI35X Standard shard-1 failure in op_tests/test_flydsl_hgemm.py: changed-input graph replay differs by one BF16 ULP in 1/2,280 outputs (max delta 0.015625), then raises graph replay mismatch. Job: https://github.com/ROCm/aiter/actions/runs/44990449408/job/137134217015. This is the pre-existing atomic split-K test issue tracked by #8351; this PR does not change that file. Please rerun the failed job once, or sync main after #8351 merges and rerun CI. Maintainer branch updates remain disabled. |
vgokhale
left a comment
There was a problem hiding this comment.
1. Move the patch to a guaranteed-early init
Comment on aiter/ops/triton/_gluon_kernels/common/utils.py:49.
Now: the rebind runs only when common/utils.py is imported. Each fp8 kernel
imports it for the side effect, for example
fp8_mqa_logits.py:7: from ...common import utils # noqa: F401.
Not covered: a kernel that calls gl.amd.gfx1250.wmma with fp8 operands and
forgets this import compiles against the native WMMA and fails on
gfx1250-strict. Commit 051544a already fixed three kernels that forgot it, so
the trap is live.
Fix: run the rebind from a package __init__.py that always loads before any
gfx1250 kernel compiles (for example _gluon_kernels/common/__init__.py). Then
delete the per-kernel # noqa: F401 imports. A new fp8 kernel then cannot miss
the patch.
2. Confirm the unit-scale numerics
Comment on aiter/ops/triton/_gluon_kernels/common/utils.py:43.
Now: the fallback calls wmma_scaled(a, None, ..., b, None, ..., acc) with
None scales.
Not covered: the result must equal the unscaled wmma, or gfx1250-strict
gives different numbers than gfx1250.
Fix: confirm None is exactly a scale of 1 and the scaled path is
bit-identical to unscaled wmma. State it in the PR.
…nits Import common/utils.py in _gluon_kernels/__init__.py and gluon/__init__.py, so the gfx1250-strict fp8 wmma patch is applied before any Gluon kernel module loads. Remove the per-kernel utils imports.
|
@vgokhale Updated the PR, tested the scale vs non scale. The results are bit identical |
Resolve the conflict in unified_attention_2d.py by taking main's _GATHER_TAKES_COL check (b4f12e2, #7767), which fixes the same tdm.async_gather signature change as c4af91f. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Lets aiter's Triton and Gluon kernels and their unit tests run on MI450
gfx1250-strict.All changes apply only when the GPU is
gfx1250-strict, except four bug fixes that also help other archs: MHA decode, MHA spatial swizzle, NVFP4 quant and MXFP8 quant.Needs a Triton that includes triton-lang/triton#12474. Tested with Triton
46eccb199b.Changes
aiter/jit/core.pyGPU_ARCHS=gfx1250but the device isgfx1250-strict, so test reference modules load.aiter/ops/triton/utils/config_utils.pygfx1250-strict) in_ARCH_OVERRIDE_RE. Ifconfigs/gfx1250-strict/<family>is missing, use thegfx1250table and log a one-time "not tuned" warning.aiter/ops/triton/configs/gfx1250-strict/DEFAULT.jsontables with only ananyentry, plus a README. Gluon quant tables are left out, so quant uses thegfx1250tables. The afp4wfp4 preshuffled tables also get the gfx1250 small-M entries, which fixes fused_gemm_afp4wfp4_a16w16 (1,152 / 0) and fused_gemm_afp4wfp4_mul_add (2,048 / 0).aiter/ops/triton/utils/types.pygfx1250-strictuses OCP fp8, notfloat8_e4m3fnuz.aiter/ops/triton/utils/_triton/arch_info.pygfx1250-strict: 327680.mha_fp8.py,mha_mxfp8.py,chunk_kda.py,unified_attention.py,fused_compress_attn.py,comms/all_reduce.py"gfx1250". The unified_attention 3D split rebalance now also runs ongfx1250-strict._triton_kernels/kimi_delta_attn/flash_kda.pygfx1250-stricttakes the gfx1250 Gluon paths instead of silently falling back to Triton.attention/pa_mqa_logits.pyGPU_ARCHS. It used to return garbage logits ongfx1250-strict.attention/mha.py_triton_kernels/attention/dao_ai/fwd_decode.py_gluon_kernels/common/utils.py,gemm_a8w8_blockscale.py,fp8_mqa_logits.py,mha_fp8.py,unified_attention_2d.py,unified_attention_3d.py,gluon/pa_mqa_logits.py,moe_op_gemm_a4w4.pygfx1250-strict, use the scaled 16x16x128 instruction instead (with unit scales for fp8). gemm_a8w8_blockscale 233 / 240 → 473 / 0, pa_mqa_logits_2d_context_lens 1 / 0, and every moe_gemm_a4w4 Gluon case now passes.unified_attention_2d.pytdm.async_gathercorrectly on newer Triton. Fixes 15 cases in a 240-case sample._triton_kernels/quant/quant.py_nvfp4_quant_op. Fixes the 24 fused_kv_cache NVFP4 cases, on gfx1250 too._gluon_kernels/gfx1250/quant/quant.pyop_tests/triton_tests/...,op_tests/multigpu_tests/triton_test/test_all_reduce.py,test_all_reduce_rmsnorm_quant.pygfx1250-stricttoo. quant_mxfp4 now matches gfx1250 (106 / 13), and pa_prefill_sparse runs all 29 tests.46eccb199b, gemm_afp8wfp8 (650 / 0), rope, fused_qkv_split_qk_rope and mla_decode_rope pass with no aiter change.Test results (A0, all 165 Triton test files)
All files in
op_tests/triton_tests, brancha0-enablment-fixesrebased onto aiter75a36b847. The full run used Triton 3.9. Every file that failed was re-run on Triton46eccb199b, which these results use. Files that passed were not re-run.gfx1250-strict:gfx1250-strict, although A0 runs them correctly (checked on A0). [AMD] Enable Remaining GFX1250-strict WMMA Instructions triton-lang/triton#12474 unblocked only the scaled 16x16x128 pair. With the block removed in a local Triton build, all of these failures go away (Triton issue: ):v_wmma_f32_16x16x32_bf16andv_wmma_f32_16x16x32_f16: gemm_a16w16, ff_a16w16, batched_gemm_bf16, batched_gemm_a16w8, batched a8w8 per-token-group prequant, pa_decode_sparse, pa_prefill_sparse, chunk_kda, mla_v4_triton, mla, unified_attention, flash_kdav_wmma_f32_16x16x64_fp8_fp8(and the bf8 variants): mla, fp8_mqa_logits, mha_fp8_gfx1250, unified_attention, fused_kv_cachev_wmma_i32_16x16x64_iu8: nothing fails; fav3_sage falls back (see below)tl.dotdoesn't fail. It silently falls back tov_wmma_f32_16x16x4_f32, or tov_dot4_i32_iu8for int8: performance drops a lot and accumulation order changes. gmm's 8 TGMM mismatches come from this; gmm passes 118 / 0 with the block removed.gfx1250-strictwithout the scheduler that goes with it, which gives wrong results in mha_mxfp8 (4 of 35), moe_gemm_a8w4 (1 in a 90-case sample) and moe_gemm_a4w4's Triton backend (4 SwiGLU cases). All pass withTRITON_HIP_USE_COEXEC_SCHEDULER=1, and as a gfx1250 build (Triton issue: ).v_wmma_f32_16x16x32_bf16(gluon and default backends; pass with the block removed)hbm_swizzling=True: the Triton backend readsGFX1250_SCALE-swizzled scales as unswizzled (110 over tolerance, 53 inf/NaN positions differ, 23 crash with an abort, 6 hang). Same failure and abort on gfx1250 at8c964fa61.apply_swiglu=Trueandhbm_swizzling=False(larger shapes): about 20–30% of elements over tolerance. All 60 fail the same way on gfx1250.rmsnorm_large_m_small_nconfig ships for gfx950 only. gfx1250 also has 4 extra numerical mismatches on very large tensors (919 of 537M elements).mhc_post/mhc_fused_sinkhornconfigs ship for gfx950 onlyaiter/utility/fp4_utils.py_dynamic_mxfp4_quant_kernel_asm_layoutindexes the scalarbs_offs_n = pid_nas[None, :], which Triton rejects.MXFP4 is not supported on gfx1250-strict. The MXFP4 wrapper is gfx950-only, but the test only checksis_fp4_avail(), which is true on gfx1250.