fix(hip-kernel-provider): close ASM SDPA forward gaps left by #16302 #16450
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16450"
general
weight: 0.35
BrianHarrisonAMD
Summary
Follows #16302 (merged as
30b361c538e). This PR makes the ASM SDPA forward engine decline graph layouts it cannot run correctly, and runs its applicability tests on CPU CI:B S_q.IsApplicableSdpaVariations,IsApplicableRaggedVariations,IsApplicableRaggedOffsetContract,IsApplicableCuSeqLenContract,IsApplicableStatsLayoutFollowsBatchMode, the head-dim truncation test and the 32-bit limit tests moved toTestSdpaFwdPlanBuilderOnArchand now run on CPU CI for gfx942 and gfx950, alongside the newIsApplicableDeclinesUnaddressableIoLayouts. The other forward applicability tests and the engine ranking test still need a matching GPU.JIRA ID : ALMIOPEN-3366
Also addresses ALMIOPEN-3378, ALMIOPEN-3041, ALMIOPEN-3042, ALMIOPEN-3182, ALMIOPEN-3329 (forward half) and ALMIOPEN-3361 (gap 1).
Not in this PR:
S_q > 256on gfx942 (ALMIOPEN-3392, ROCm/aiter#7593): handled in a separate change by its assignee.Risk Assessment
Risk 2 of 5. The engine only declines more graphs; no graph it still accepts changes kernel, arguments or launch. A declined graph falls through to the next engine when one serves it; on gfx942 and gfx950 a declined group-mode stats graph may have none, because FlyDSL declines head-major stats for
H > 1and the dense and unified engines decline ragged operands. Each new decline covers a graph the engine computed wrongly or wrote to the wrong place, or a graph the same rule cannot tell apart from one:H > 1and a head stride belowB S_q, including 0.S_qis only a necessary lower bound: the frontend's default ragged stats strides[H S_q, S_q, 1, 1]meet it, yet withB > 1a batch at offsetS_qor later writes the next head's LSE (B = 2,H = 8,S_q = 256, offsets[0, 256, 512]: batch 1 / head 0 and batch 0 / head 1 both write rows 256..511).B S_qis the Q token capacity of a packed table. It declines AITER's packed[H, total_q]layout whenevertotal_q < B S_q, and such a graph is not guaranteed a fallback (see above). A table whose rows reach pastB S_qstays a caller precondition.Sx sequence stride.Every in-tree bundle and integration test builds packed layouts, which none of these rules decline. The only unit tests that met a rule are the 32-bit dimension-limit tests, whose O shared one stride set across batch and head and so overlapped itself; they now keep every non-limit axis at 1, so O stays non-overlapping. Each limit case still turns on its one dimension. The head-dim truncation rows are also declined by the sequence-stride rule, so that test pins the decline rather than the 32-bit gate. The
TestContainertest checks that the ASM engine still ranks first for the forward graphs it serves.ASIC Coverage
Scoped to gfx942 and gfx950, the only archs the forward ASM engine serves. Device runs on MI300X (gfx942,
MI300/objects) and MI355X (gfx950) are in the checklist. The applicability rules for both archs also run on any host throughTestSdpaFwdPlanBuilderOnArch. The change adds declines only, so it moves no other arch. MI308X (MI308/objects) was not run: no kernel object or launch changed, and the declines run before any object is selected.Testing Summary
SdpaFwdPlanBuilderreads the device arch through a virtualdeviceArchhook, likemaxThreadsPerBlock.TestSdpaFwdPlanBuilderOnArchoverrides it and runs over gfx942 and gfx950. The tests listed in the Summary moved onto it, so thecu_seq_len,padding_mask, top-left and stats acceptance from #16302 now fails on CPU CI if a later change declines it again.IsApplicableDeclinesUnaddressableIoLayoutscovers each IO layout rule and its accepted neighbours (padded rows, broadcast Q/K/V, group-mode O batch stride). The denseseq_len_q/kvdecline gains rows.IsApplicableStatsLayoutFollowsBatchModegains:- batch-mode stats rows: an isolating row at
B = 4,H = 1with strides{255, 255, 1, 1}, and boundary rows where head stride 34636824 is accepted and 34636825 declined;- group-mode head stride rows: at
B = 4,H = 8, a head stride ofS_qand ofB S_q - 1is declined and the head-majorB S_qbaseline is accepted; a one-batch row atS_q, a row belowS_qand a zero stride cover the rest.TestContainer.RanksTheAsmEngineFirstForTheSdpaForwardGraphsItServes.-
StandardGroupCoverageinstance ofIntegrationGpuSdpaFwdBf16: on every group row that serves GQA, group-mode GQA (Hq = 4,Hkv = 2) with stats,cu_seq_lenover edge lengths, and top-left for causal rows, and MQA (Hkv = 1) with stats. Every group row also runs with stats atB = 1, and every causal group row runs top-left with stats through one sharedcu_seq_lentable.#15353bundle cases (12 from the standard and comprehensive tiers, 4 added from the full tier) that ASM accepted and computed wrongly on MI300X: each has a head-dim stride other than 1, or a sequence stride below the head dim or 0, on Q, K, V or O. On MI300X atd00b76b2f53, with #15353's bundle directories (headca1c7168838) copied into the checkout and no skip entries for them, ASM declined all 16, each for the expected reason: Q sequence stride 64 below head dim 128 (4 cases), K head-dim stride 8 or 32 (4), K sequence stride 0 (4), and V head-dim stride 8 or 32 in the ragged bundle (4).Testing Checklist
d00b76b2f53:pre-commit run --from-ref 30b361c538e --to-ref HEAD- Status: Passedd00b76b2f53:clang-tidy-20 -p <build> SdpaFwdPlanBuilder.cpp TestSdpaFwdPlanBuilder.cpp TestContainer.cpp IntegrationGpuSdpaForward.cpp AsmSdpaConfigHelpers.cpp- Status: Passedd00b76b2f53:hip_kernel_provider_tests --gtest_filter='TestSdpaFwd:TestContainer.'- Status: Passed (130 passed). With the #16302 unit filter at073532e3fad: 377 run, 305 passed, 72 skipped.3024ee6556a(comment changes plus one accepted group-stats row):hip_kernel_provider_tests --gtest_filter='TestSdpaFwd:TestContainer.'- Status: Passed (130 passed, 31 skipped); pre-commit and clang-tidy on the two changed files passedda7b45e82cc(comment-only change to the head-dim truncation test):pre-commit run --files TestSdpaFwdPlanBuilder.cpp- Status: Passed073532e3fad, kernel ingestor ON:-
hip_kernel_provider_testswith the #16302 filter - 405 run, 403 passed, 1 skipped, 1 failed (IsApplicableDeclinesHeadDimsThatTruncateToASupportedValue; fixed ind00b76b2f53, see below)-
hip_kernel_provider_integration_tests --gtest_filter='IntegrationGpuSdpaFwd:IntegrationGpuAsmSdpaForwardRagged'- Status: Passed (199 run, 101 passed, 98 skipped for gfx950;StandardGroupCoverage20 passed)-
ASM_SDPA_ENGINESdpaFwd bundles, quick / standard / comprehensive - Status: Passed (13 / 45 / 50 passed, 0 broken claims, 0 unclaimed), the same counts as #16302-
ctest -R hip_kernel_provider_integration_tests_quick_suite- Status: Passed (228.1 s of its 300 s timeout, after #15484's backward cases)073532e3fad, kernel ingestor ON, the same commands:- unit - 405 run, 399 passed, 5 skipped, 1 failed (the same test, same cause)
- integration - Status: Passed (199 run, 102 passed, 97 skipped for gfx942;
StandardGroupCoverage23 passed)- bundles - Status: Passed (6 / 15 / 18 passed, no claim failures; the batch-mode
unclaimed_supportcases #16302 reported are still unclaimed)- quick suite - Status: Passed (204.1 s of 300 s)
d00b76b2f53: the 16 #15353 cases from the #16302 comment (12 standard/comprehensive, 4 full),hipdnn_integration_tests --test-engine ASM_SDPA_ENGINEone case at a time with #15353's bundles overlaid - Status: Passed (16 of 16 declined byareFwdIoLayoutsAddressable, none run)f21f442a9e9(develop merged):hip_kernel_provider_tests- Status: Passed (1102 passed, 99 skipped; all 18TestSdpaFwdPlanBuilderOnArchcases pass for gfx942 and gfx950). Mutating theB S_qrule, the IO layout check or thedeviceArchcall each fails its tests. pre-commit and clang-tidy on the resolved files passed.The one device failure was a test bug:
IsApplicableDeclinesHeadDimsThatTruncateToASupportedValuebuilt its control graph with one stride set shared by 4 batches and 8 heads, so its O overlapped itself and the new O-overlap decline rejected it.d00b76b2f53gives each case one batch and one head and moves the test ontoTestSdpaFwdPlanBuilderOnArch, where it passes for gfx942 and gfx950 on the host. That commit changes only this test; the device runs above cover the engine at the same source.Technical Changes
SdpaFwdArgsBuilder.hpp,SdpaFwdLaunchParams.hpp): comments state what the caller must keep that the host cannot check, because only the device holds the offset and length tables: the group-mode LSE base (seqstart_q[b] + len_b <= head stride), each KV length at mostS_kv(restoringmax_b(kvOffset[b+1] - kvOffset[b])), and which tableptr_qseqreads whencu_seq_lenis present.checkStatsTensor): withH > 1the head stride must be at leastB S_q, computed asheadStride / B < S_qto avoid forming the product. It also declines a zero head stride.checkFwdIoLayouts,isNonOverlappingView): head-dim stride 1, and sequence stride at least the tensor's own head dim. O must not overlap itself, with overflow checks; group mode skips O's batch axis. Rank-4 strides are checked once, in the Q/K/V/O rank-4 loop, before the ragged-addressing and layout checks read them.SdpaFwdPlanBuilder::deviceArch): virtual, returnsstd::optional<std::string>throughplan_utils::tryGetDeviceString. Tests override it.AsmSdpaConfigHelpers.{hpp,cpp}): support for the new integration instances.cu_seq_lencumulative lengths rather than offsets. In thehipdnn-aiter-asm-sdpa-fwd-syncskill,new-values.mdcites the v0.1.29 forward pin and records the layout declines a new kernel row must pass;validation.mdlistsStandardGroupCoverageand the host-runnable applicability tests.Merge with #15148
#15148 merged first and rewrote
isApplicableasRejectionchecks. Mergef21f442a9e9ports this PR onto it:checkFwdIoLayouts, theB S_qrule incheckStatsTensor, anddeviceArch()incheckFwdApplicability. Rejection messages are unchanged.Still open
B S_q: offset-dependent, so a caller precondition.