Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
JinHe-102
force-pushed
the
users/JinHe-102/ck/fmha-batch-prefill-gfx11
branch
from
September 17, 2026 02:50
a97c1e4 to
66469c3
Compare
|
🎉 All checks passed! This PR is ready for review. |
TileFmhaBatchPrefillTraits and fmha_fwd_batch_prefill_traits_ both take kHasSink_ between kSkipMinSeqlenQ_ and kPageBlockSize_, but the batch prefill codegen never emitted it. Every argument after that slot shifted by one, so a generated instance expanded to kSkipMinSeqlenQ_ = false, kHasSink_ = 16, // page size kPageBlockSize_ = LINEAR_LAYOUT, // memory layout enum kKVMemoryLayout_ = VLLM_BLOCK_TABLE_2D // lookup table enum which is ill-formed: int to bool is a narrowing conversion, and two scoped enums bind to parameters of unrelated types. The dispatcher batch_prefill path therefore did not compile on any architecture. Emit the flag in both traits lists. The added test parses the generated argument list and pins each trailing parameter to its slot; it fails before this change with 15 arguments instead of 16. Signed-off-by: He Jin <Jin.He@amd.com>
gfx1100 had no batch_prefill pipeline: the arch supported qr, qr_pagedkv, qr_nwarp_sshuffle, appendkv and bwd only. qr_async cannot be reused because gfx11 has no parent async dwordx2 K copy, and the fallback gemm1 (ARegBSmem) cannot consume a gfx11 WMMA P tile. Add BlockFmhaBatchPrefillPipelineQRKSVSAsyncGfx11Policy: - synchronous K staging (kUseSyncKLoad) instead of async copy - vec4 K packing on N0=32 / K0=32 linear tiles - Independent-V gemm1 (ARegBReg plus a tiled V LDS layout) - P permuted from WMMA C layout to A layout before gemm1 Enabled surface is deliberately narrow: block size 256, tile 128x32x32, hdim 128, linear page KV and no dropout. All other tiles, head dims, dtypes and architectures stay on the existing pipeline, unchanged. Codegen emits exactly that set (192 instances), validation rejects anything outside it with a named error, and the pipeline carries a device-side static_assert so the two gates cannot drift apart. The tile engine harness needed three fixes to exercise the path: the ctypes runner zeroed the paged K/V buffers instead of copying the host pages, it hardcoded window_size_right=-1 so causal masks did not mask, and the Python side passed dense BHSD without the linear page pack or the Q/O transpose. fmha_benchmark.py now also exits non-zero when kernels fail to build or verification fails; previously both printed the failure and exited 0. Signed-off-by: He Jin <Jin.He@amd.com>
JinHe-102
force-pushed
the
users/JinHe-102/ck/fmha-batch-prefill-gfx11
branch
from
September 18, 2026 04:09
66469c3 to
a715f9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ISSUE ID : #12100
Summary
gfx1100 has no batch prefill pipeline it can run. Emission hands it the gfx9 rule set, so all 277,120 configs select
qr_async— which gfx1100 cannot compile — and every one is rejected downstream. Today the architecture has zero working batch prefill kernels.BlockFmhaBatchPrefillPipelineQRKSVSAsyncGfx11Policy, derived from the existing default policy128x32x32, hdim 128, linear page KV, no dropoutqr_async, untouchedEmission for gfx1100 goes from 277,120 configs that cannot compile to 192 that all build. CDNA is unchanged, config for config.
Partially addresses #12100: gfx1100 gets a pipeline it can run, but
get_pipelines_for_configis not changed andfwdis not touched.Why the existing pipeline cannot be reused
Two independent blockers, both in device code.
K staging needs a CDNA3 instruction.
qr_asyncmoves K to LDS viaasync_load_tile_raw→async_global_load_lds_dwordxn, which is guarded#if !defined(__gfx94__) && !defined(__gfx950__)with "global_load_ldsrequires CDNA3+" (
amd_buffer_addressing_builtins.hpp:1503).gemm1 cannot consume a gfx11 P tile.
BlockGemmARegBSmemCRegV2expects a thread buffer of 16; gfx11 WMMA produces 32.So this is not a tuning gap: the pipeline is unbuildable on gfx1100 by construction, and
supported_pipelinesis right to exclude it.What the new policy does
kUseSyncKLoad = true— K staged with ordinary loads plus LDS storesBlockGemmARegBRegCRegV2over a tiled V LDS layoutThe permutation reuses the existing
PermuteWarpGemmCToAhelper thatblock_fmha_pipeline_qr_ks_vs.hppand four other pipelines already use.How CDNA is kept out
instance_gen.pyvalidation.pystatic_assertkeyed onkUseSyncKLoadThe assert keys on
kUseSyncKLoad, not on the architecture. No CDNA instance sets that flag, so none can reach the new path — a structural guarantee, not a measurement that happens to come out clean.It sits inside
#if defined(__gfx11__)for a separate reason:amdgcn_target_wave_size_id::HOSTis 64, so in the host compilation passProblem::kBlockSizeevaluates to 512 for an 8-warp block and a class-scope assert would fire on every instance, CDNA included.Emission
expand_sweeponbatch_prefill.json:qr_asyncqr_asyncbatch_prefill_gfx11Resource usage
From the code objects of all 144 built kernels, not a sample (
llvm-objdump --offloading, thenllvm-readelf --notes):27,648 B is 42% of the 65,536 B per-workgroup LDS limit, so two workgroups fit concurrently.
Harness fixes
The tile engine runner could not exercise this path at all:
fmha_ctypes_lib.cppzeroed the paged K/V buffers and never copied the host pages — every verification compared against zeroswindow_size_right = -1, a full row, sotop_leftandbottom_rightdid not maskfmha_utils.pypassed dense BHSD without the linear page pack or the[B,H,S,D] <-> [B,S,H,D]transpose the kernel expectsfmha_benchmark.pynow exits non-zero when kernels fail to build or any verification reports FAIL; previously it printed the failure and exited 0. This is a global tile engine change, not gfx11 only.Test Plan
Test Result
Host: 33 tests, all pass.
Device: gfx1100 / W7900, ROCm 10.0.0, HIP 7.15.26333:
Problems
1,8,128,128,1,8,2048,128,1,8,8,8,1024,128, all D128.Extended shapes on the same kernels — 32 PASS / 0 FAIL: batch 4 and 8, 4096 context, seqlen 130 straddling the 128 tile, 1000 and 777, GQA hq=4 / hk=2 with q=17 against k=2048, and q=k=1. Across four seeds: 1728 measurements, 0 FAIL. Also reproduced in
rocm/composable_kernel:ck_ub24.04_rocm10.0.Scope and follow-up
Submission Checklist
clang-format/ruff-formatclean; all 8 pre-commit hooks passorigin/develop4606f83174