Repository navigation
[CK] [JIT] [bot revert] Revert e3931369c: Clamp FP8 per_Token/per_Tensor SiLU - #8294
gyohuangxin wants to merge 6 commits into
Conversation
🏷️ 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 |
…mped SiLU Drop the revert of e393136 and fix the stale assumption in the dispatch check instead. test_plain_fp8_swiglu_limit_dispatch assumed a swiglu_limit always resolves to a CK stage 1. On gfx942 per_Token FP8 it does not: when no tuned CK row carries the requested limit, get_2stage_cfgs falls back to the FlyDSL whole-graph backend, which applies the clamp itself and returns MOEMetadata(None, None, ..., full_impl=...). The check then dereferenced md.stage1 and died with AttributeError: 'NoneType' object has no attribute 'keywords' (run 44408312107, MI300X shard 5/8). The kernels are correct; only the test's expectation predates the gfx942 FlyDSL clamped-SiLU fallback. Accept the whole-graph result explicitly and assert what holds for it (no stage partials, no 1-stage, no ksplit), and assert that the 0.0 / +inf no-clamp sentinels keep CK calls on CK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ROCm#8178 sends a gfx942 per_Token FP8 SiLU with an active swiglu_limit and no tuned CK row to the FlyDSL whole-graph backend, which applies the clamp, and checks the CK limits only when no FlyDSL backend takes the call. test_plain_fp8_swiglu_limit_dispatch still assumed CK stage 1: it read md.stage1.keywords on a FlyDSL result (AttributeError on MI300X), and it expected NotImplementedError for per_Token at inter_dim 192, which FlyDSL now serves. The first two hunks are ROCm#8294's change. The inter_dim 192 expectation is the assertion that ROCm#8294's own MI300X run still fails on.
…raph clamped SiLU" This reverts commit 54a436c.
|
Please close this revert. Run 44408312107 crashes because Reverting it deletes that clamp and keeps the fallback. The route is fixed in #8353: keep FlyDSL only when CK cannot clamp ( |
|
Closing in favour of #8353. This revert would take out the CK per_Token / per_Tensor runtime clamp from #8353 fixes that at the dispatch: CK-capable FP8 shapes ( The underlying accuracy problem with the FlyDSL clamp is tracked separately in |
…rectly
gemm_moe_ck2stages_common_blockscale.cuh uses std::isfinite and
ck::MoeSilu::ValidRuntimeLimit at lines 45 and 50 but includes neither
<cmath> nor ck/tensor_operation/gpu/element/moe_silu.hpp. It compiled only
because the non-blockscale gemm_moe_ck2stages_common.cuh happens to pull
moe_silu.hpp in.
That is a latent build break: a generated instance includes exactly one
gemm_moe_ck2stages_common{quanttype}.cuh, so the blockscale TU never sees
the other header, and touching the includes of a sibling header takes the
per_1x128 blockscale instances down with:
gemm_moe_ck2stages_common_blockscale.cuh:50:25: error: no member named
'MoeSilu' in namespace 'ck'
Seen for real in #8294, where a revert dropped those two includes from the
non-blockscale header and broke module_moe_ck2stages_abi2_f8_f8_
preshuffle_on_b16_silu_per_1x128_mulWeightStage2_runtime_swiglu_limit.
Include what is used; no behavior change.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…rectly (#8305) gemm_moe_ck2stages_common_blockscale.cuh uses std::isfinite and ck::MoeSilu::ValidRuntimeLimit at lines 45 and 50 but includes neither <cmath> nor ck/tensor_operation/gpu/element/moe_silu.hpp. It compiled only because the non-blockscale gemm_moe_ck2stages_common.cuh happens to pull moe_silu.hpp in. That is a latent build break: a generated instance includes exactly one gemm_moe_ck2stages_common{quanttype}.cuh, so the blockscale TU never sees the other header, and touching the includes of a sibling header takes the per_1x128 blockscale instances down with: gemm_moe_ck2stages_common_blockscale.cuh:50:25: error: no member named 'MoeSilu' in namespace 'ck' Seen for real in #8294, where a revert dropped those two includes from the non-blockscale header and broke module_moe_ck2stages_abi2_f8_f8_ preshuffle_on_b16_silu_per_1x128_mulWeightStage2_runtime_swiglu_limit. Include what is used; no behavior change. Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…e/prefill kernels (#6277) * [ASM] [MLA] Fix and optimize the gfx942 MLA decode/prefill kernels Replace 20 gfx942 MLA code objects with fixed and optimized builds and add one new kernel (32 heads, qlen 1). Kernel names, kernargs and grids are unchanged, so every existing caller dispatches as before. Bugs fixed (stock behavior): - KV loads above 4 GiB: buffer_load offsets were page_id * stride in 32 bits (some kernels also took a 24-bit page id), so pools over 4 GiB read other tokens' KV. KV now loads with 64-bit global addresses in every kernel. - Other 32-bit offset overflows (output/split data, kv_indptr, LSE, Q). - Missing s_waitcnt before using load results (prologue KV tile, V transpose LDS reads, fp8 descales) -> stale data under memory pressure. - MFMA -> VALU read hazard in the softmax (nondeterministic results). - LDS races and missing barriers in the a8w8 qseqlen 1/2/4 kernels. - 32x1 / 64x1 kernels: S == 1 null split pointer fault; the 32-head kernel ran one token per workgroup and was not causal for qlen > 1. - qseqlen-2 a8w8 causal mask, PS empty work items, kv_scale handling in the paged qseqlen-4 PS kernel, reads of unwritten splits for qlen >= 9. Dispatch: gqa_ratio 32, bf16, non-persistent now selects the new MLA_A16W16_1TG_4W_32mx1_16nx1_Coex0_Msk1_QH16_Q1 kernel when max_seqlen_q == 1 (new mla_asm.csv row) and the causal any-qlen kernel otherwise. Performance matches or beats stock on most measured shapes (up to ~20% faster); the 64-bit KV addressing costs up to ~1.5% on a few memory-bound shapes of the a8w8 qseqlen-4 kernels. Tested on MI300X against an fp32/fp64 reference and a bit-exact oracle, including KV pools above 4 GiB, injected stalls and 1 h soak runs, and with op_tests (test_mla.py incl. the CI invocations, test_mla_persistent.py, test_mla_sparse.py and the other MLA op_tests): all pass. Signed-off-by: Jonah Bernard <[email protected]> * [MLA] Extend test_mla_ltx.py gfx942 coverage to every fixed kernel The gfx942 kv_address check now covers each MLA .co this PR fixes, except the page_size 64 ds32 kernel. GFX942_PRESETS maps each preset to the modes (nps / ps / prefill) that reach its kernels. The default gfx942 run sweeps all of them: 84 cases, 20 kernels. - FP8 and A16W8 configs, qlen 1-8, 8/16/32/64/128 heads - mla_prefill_fwd (causal prefill) mode - causal reference for qlen > 1; FP8-Q tolerance 6e-2 - persistent metadata uses the real Q/KV dtypes on gfx942 (gfx950 keeps BF16) gfx950 defaults and presets are unchanged. Signed-off-by: Jonah Bernard <[email protected]> * test_mla_ltx: cover the gfx942 page-64 ds32 MLA kernel at 4 GiB Add qh16_ds32_q1/q2/q4 presets (uint8 KV) for mla_a16w8_qh16_m16x4_n16x1_coex0_mask1_ps_page64_ds32. The harness packs fp8 nope, fp32 block scales and bf16 rope into 64-token pages and runs the kv_address cases on them: one page below, across and above the 4 GiB boundary (page 102,300), plus a 65-page context the metadata splits in two. Signed-off-by: Jonah Bernard <[email protected]> * [MLA] Pick the bf16 32-head qSeqLen 1 kernel only on gfx942 asm_mla.cu set config_max_seqlen_q = 1 for bf16 32-head non-persistent decode with max_seqlen_q == 1 on every arch, but only the gfx942 mla_asm.csv has a qSeqLen 1 row for that config. get_heuristic_kernel_mla needs an exact match, so gfx950 failed with "cannot get heuristic kernel". Gate it on arch_id == "gfx942"; other archs use qSeqLen 0 as before. Signed-off-by: Jonah Bernard <[email protected]> * [ASM] [MLA] Fix the gfx950 MLA kernels and test the fp8 msk0 kernel in CI Rebuild 12 gfx950 MLA .co files from the same sources as the gfx942 kernels in this PR (the .text matches the gfx942 builds). KV is read with 64-bit global loads, so pools above 4 GiB no longer wrap, and the nondeterminism, the non-causal 64-head kernel, the 1-split fault in the 64-head kernel and the bf16-Q/fp8-KV PS fault are fixed. mla_a8w8_qh128_m32x4_n16x2_msk0 has no gfx942 counterpart: it is the fp8 128-head msk1 source built with MASK = 0. Kernel names and mla_asm.csv rows are unchanged. aiter_test.sh: on gfx950, add a test_mla.py run of non-causal fp8 decode with qlen 2 and 4 (128 heads), which is the only path that reaches the msk0 kernel. Signed-off-by: Jonah Bernard <[email protected]> * [HIP] [MLA] Add the missing barrier in mla_reduce_v1's massive row loop In mla_reduce_v1_impl_massive (4 or more splits), warp 0 writes the LSE scales of a row to p_lds_lse_scale, and every warp then reads them to scale its part of the output. The row loop had no barrier after the output pass, so when a block reduces more than one row (qlen > 1, or folded heads), warp 0 could overwrite the scales with the next row's while warp 1 was still reading them. Warp 1's dims (256-511) of that row were then combined with the wrong row's weights. This is the remaining failure in #6731: with this PR's stage-1 kernels, the issue's repro (32 heads, qlen 4, 5 splits) gave 167 wrong calls in 400,000 on MI300X, each one token and one head in dims 256-511 only. With the barrier: 0 in 400,000. Signed-off-by: Jonah Bernard <[email protected]> * [MLA] Add a test_mla_reduce case for the row-loop barrier The previous commit's race needs many splits, many rows per workgroup and a full GPU; none of the existing cases has all three, so they pass with or without the barrier. The new case (16 heads, dv 512, 32 tiles x 64 splits x 32 rows) failed on every run without the barrier on MI300X (50 of 50, plus both dtypes of the full test on two GPUs) and passes with it. Signed-off-by: Jonah Bernard <[email protected]> * [ASM] [MLA] Apply the causal mask in bf16 128-head decode with qlen > 1 The non-persistent bf16 128-head decode always ran mla_dec_stage1_bf16_a16w16_subQ128_mqa128, which has no causal mask, so causal decode with qlen > 1 attended to future tokens (#6733). Run mla_pfl_bf16_a16w16_causal_subQ128_mqa128 for that case instead. It is the masked build of the same kernel and takes the decode arguments unchanged. It skips splits past a query's last token, so stage 2 now uses the per-query split count for it. gfx950 ships the same two kernels (identical .text), so the fix covers it too; it was only tested on gfx942. Signed-off-by: Jonah Bernard <[email protected]> * [Test] test_ar_norm_precedence: give the stand-in should_fly_allreduce_rmsnorm #5670 made fused_allreduce_rmsnorm ask each communicator should_fly_allreduce_rmsnorm() before the paths this test checks. The CustomAllreduce stand-in from #8022 binds only the other routing gates, so the custom_fused case past the Gluon limit raised AttributeError. #8022's last CI ran on a base without #5670. Bind the real gate with _fly_rms=None, which is its value on gfx1250, where the FlyDSL fused engine does not build. (cherry picked from commit 06ae37f) * [Test] test_moe_2stage: accept the gfx942 FlyDSL clamped SiLU route #8178 sends a gfx942 per_Token FP8 SiLU with an active swiglu_limit and no tuned CK row to the FlyDSL whole-graph backend, which applies the clamp, and checks the CK limits only when no FlyDSL backend takes the call. test_plain_fp8_swiglu_limit_dispatch still assumed CK stage 1: it read md.stage1.keywords on a FlyDSL result (AttributeError on MI300X), and it expected NotImplementedError for per_Token at inter_dim 192, which FlyDSL now serves. The first two hunks are #8294's change. The inter_dim 192 expectation is the assertion that #8294's own MI300X run still fails on. * Revert "[Test] test_moe_2stage: accept the gfx942 FlyDSL clamped SiLU route" This reverts commit fdcd7bd. * [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default The whole-graph batch-1 and decode kernels clamp BF16 activations, so a per-token call that CK can clamp was missing the per-token reference and crashing the dispatch test on stage1 being None. Co-authored-by: Cursor <[email protected]> (cherry picked from commit ca91b9f) * [MLA] Route gfx950 128-head bf16 causal qlen>1 decode to the masked prefill kernel too mla_asm_decode_remap only forced ps=0 (and thus the masked-prefill-kernel selection for causal qlen>1) on gfx942, so gfx950 kept running the plain persistent decode kernel for this case, which has no per-query causal mask. Meanwhile mla.py's masked_qh128_bf16 (which drives CAUSAL_PER_QUERY for the stage-2 reduction) was already set for both gfx942 and gfx950, so stage 2 believed splits past each query's causal horizon were skipped on gfx950 too, even though stage 1 never skipped them there. gfx950 already ships and dispatches mla_pfl_bf16_a16w16_causal_subQ128_mqa128.co (hsa/gfx950/mla/mla_asm.csv) with the 64-bit KV addressing fix from this PR, so extending the gate just routes to an existing, already-tested kernel. * Revert "[MLA] Route gfx950 128-head bf16 causal qlen>1 decode to the masked prefill kernel too" This reverts commit 2cd4f38. Forcing ps=0 for gfx950 128-head bf16 decode breaks every persistent 128-head bf16 decode on gfx950. The gfx950 block at the end of mla_asm_decode_remap still tests `persistent`, not `ps`, and remaps the shape to gqa 32 / qSeqLen 4. The lookup then asks for (gqa 32, ps 0, qSeqLen 4), which hsa/gfx950/mla/mla_asm.csv does not have, so test_mla_persistent.py, test_mla_persistent_round_robin.py and test_mla_sparse.py fail on MI35X with "cannot get heuristic kernel! ... gqa:32 ps:0 ... qseqlen:4". The CAUSAL_PER_QUERY concern does not need this change. masked_qh128_bf16 only feeds the stage-2 reduction in the non-persistent branch of mla_decode_fwd. That branch passes num_kv_splits_indptr, so persistent is false and ps is already 0 on gfx950: causal qlen > 1 already selects mla_pfl_bf16_a16w16_causal_subQ128_mqa128 there. Persistent decode reduces with mla_reduce_v1 and runs the qh32_qseqlen4 *_ps kernels, which have causal and msk0 variants. * [CI] [MLA] Gate the gfx950-only msk0 test on the live GPU arch get_gfx() returns the last GPU_ARCHS entry. With GPU_ARCHS="gfx950;gfx942" the gate read gfx942 on a gfx950 GPU and skipped the test; with "gfx942;gfx950" it would run the gfx950-only kernel on gfx942. get_gfx_runtime() reads the arch from rocminfo and ignores GPU_ARCHS. --------- Signed-off-by: Jonah Bernard <[email protected]> Co-authored-by: amd-bartgips <[email protected]> Co-authored-by: Jin Pan <[email protected]> Co-authored-by: jatseng-ai <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Jin Pan <[email protected]>
Summary
e3931369cea0d71e968ffea3d3d4002a00de6290aiter/fused_moe.pyContext
This was the high-confidence culprit from the Aiter failure report, but automatic revert could not create a PR because
git revert --no-edit e3931369...conflicted.Validation
python3 -m py_compile aiter/fused_moe.py aiter/ops/moe_op.py csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.pyrg '<<<<<<<|=======|>>>>>>>' aiter/fused_moe.pygit diff --check HEAD~1..HEAD