Repository navigation
feat(sdpa): additive bias on the SM90 dedicated D128 forward (engine 20541) - #2882
Abhayrkhot wants to merge 6 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
Posted by Claude Code, an AI agent acting for @YangXu1990uiuc. Thanks for the D128 bias path. Two notes from running this branch (head 1. Automatic (A-mode) candidates for short-Q GQA over a long KV. Graph: b 4, H_q 16 / H_kv 4, S_q 32, S_kv 1024, unmasked, a BF16 bias of shape
2. Placement. The PR leaves moving the bias plans ahead of the backend out of scope, so we measured that separately.
Once this PR and #2872 merge, we plan a small follow-up that puts FROST first for that measured domain. Nothing is needed here. |
|
Thanks for extending the SM90 D128 path with additive bias and for documenting the validation and unsupported cases. I have added this PR to our contribution tracking, including its dependency on #2872, and supplied the labels and milestone. When you are ready for feedback, please click GitHub's Ready for review button to leave Draft. Our maintainer review bot skips Draft PRs and can pick this up once it is non-draft. A comment saying ready alone does not change Draft status. Review readiness does not require the PR to be ready to merge, and it is not an unconditional merge request; the dependency, review findings and final validation still need to be handled before landing. If you are still working on it, keeping it in Draft is fine. Once you want merge assistance, please say ready, and we can help with the remaining integration and validation. |
|
Thanks for running it. Fixed the A-mode gap in d43df75: on SM90, a bias graph's knob sets now drop the split and packed sets that the bias check refuses and always keep one unsplit, unpacked 20540 set. Your graph (b4, H_q 16 / H_kv 4, S_q 32, S_kv 1024) now gets that plan from A with an IO or FP32 bias. So do two neighbours that had the same gap, S_q 16 over S_kv 8192 and the D256 version of your shape. Bias-free lists are unchanged. Good to see the placement numbers. Thanks for taking that follow-up. |
|
Source and host checks found no confirmed blocking issue so far. I’m requesting SDPA FROST CI for the current head, including the Hopper bias numerical, replay and refill tests. Local host checks passed; native Hopper execution remains unverified here. Codex bot review — model |
|
@cudnn-ci-bot run python/sdpa/frost |
|
🏁 Pipeline finished SHA: 21 passed, 5 failed, 13 manual
|
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed d43df7560afd against base 2b98a25ddd06.
Thank you for your contribution! No blocking issue found in the full current contribution, including the stacked #2872 changes. The short-query A-mode gap is resolved by retaining an unsplit, unpacked candidate. Local host checks and four offline SM90 code-generation checks passed. Native Hopper numerics, determinism and refill stress remain pending in the requested SDPA FROST CI; the H200 results in the description are author-reported. Keep the existing dependency and CI requirements before merging.
Validation: Reviewed bias admission and dtype/storage limits, standalone and graph binding, both kernel implementations, partial-tile copies, scale/mask/Stats handling, persistent bias-slot phases and release ordering. D64 and unsupported FP32/split/paged/THD/claim combinations remain gated. 1317 host checks passed across the new bias admission suite, D128 routing, forward heuristics and heuristic geometry. 61 GPU-dependent checks skipped on the local SM100 GPU; 3 cases were deselected. 630 graph-analyzer checks passed on the exact PR Python source. Four independent compile-only SM90a checks passed for serial, overlap, persistent-dense and paired-causal D128 BF16 bias variants. Every generated dependent bias release consumed all 32 loaded words through the final kernel parameter; disassembly showed no local-memory loads/stores and retained register redistribution. No Hopper kernels were executed locally. Reviewed FP64 numerical references, poisoned outputs, changed-input capture/rebinding, batch reorder/duplication checks and runtime-scoped goldens. Precheck A03a was rejected after confirming initialization uses one elected lane in warp 0.
Limitations: No independent native Hopper numerical, warm-stress, sanitizer or performance run was available locally. Requested CI is pending, not a passing result. No independent bias-free PTX identity comparison or verification of the author's speedups. Compile checks cover the stated BF16 D128 variants only.
Approved: no P0 or high-risk P1 found. Remaining findings stay with the owner; merge timing stays with the owner.
|
Current-head CI has finished. Native Hopper validation remains open: SM90 failed during dependency setup before tests. SM100/SM103 were denied container access before tests, and SM120 timed out with no established cause. SM80 passed. SM107 reported 17,382 passed and five failures in unchanged MXFP8 graph plan/fallback assertions outside the Hopper change. This run does not validate the new Hopper bias path on hardware. The host and offline compilation checks in the review retain their stated scope. No failed job was retried. Codex bot review — model |
d43df75 to
738acd7
Compare
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed 738acd70db3e against base 73ce9b1298cf.
Thank you for your contribution! No new finding in this follow-up. Since the earlier review, only regression tests changed: they now cover short-query and decode bias graphs whose mode-A candidates must remain unsplit and unpacked. The runtime and kernel code are unchanged. The branch merges cleanly with current develop; keep the existing dependency and native validation requirements before merging.
Validation: 19 exact-head discovery checks passed, including all nine new FP32/IO-bias shape cases. The clean current-develop merge passed 1,190 host checks; 61 Hopper-only cases skipped and three higher-level cases were deselected. Reused the prior source audit and four offline SM90 code-generation checks because the runtime/kernel source is unchanged. Rechecked the precheck barrier candidate: initialization is guarded by warp 0 and one elected lane, so it is not a finding. Approved the current head's unchanged lint, security and docs-validation workflows under the standing check-workflow rule, and verified GitHub queued each run.
Limitations: Native Hopper numerical, determinism, refill-stress and performance validation remains incomplete. Earlier pipeline 84885992 failed during dependency setup on SM90 and container access on SM100/SM103, before tests. No failed-job retry or duplicate GPU pipeline was requested for this test-only update. The retained H200 measurements are author evidence. Local host and offline compilation checks do not establish native Hopper correctness or speed.
Comment only: this PR already has an active approval; preserving existing approvals.
Serve [1|B, 1|H_q, S_q, S_kv] additive bias (FP32 or the Q/K/V dtype) on the SM90 D512 body for dense, nonpaged, unsplit, unpacked graphs at D128/D256/D512 envelopes; FP32 bias is declined at D512, where its tile does not fit. - Each WG1 warp stages its 16 bias rows in shared memory with cp.async before QK (swizzled 16-byte chunks, zero-filled past S_q and S_kv). The softmax forms scale * Q.K + bias before masking and subtracts the row anchor before the base-2 conversion (SDPA Rule S17). - Bias plans bind through prepared_host.host_bias and the python dense frame. - The D64 and dedicated D128 rows decline bias; the D128 template lists it in D128_NOT_SERVED, so a biased (128, 128) graph runs on engine 20540. - The private SM90 policy row admits bias, so default discovery proposes 20540. - The SM90 adapter now refuses kv_mask and score side outputs instead of dropping them. Bias-free renderings are PTX-identical to develop.
…atus Record the 12 H200 goldens for the engine 20540 bias determinism suite (runtime key a6e0199439a0a182), add a warm stress test for the per-KV-tile bias refill, and document the coverage and the new SM90 status row.
The SM90 bias leg runs unsplit and unpacked, and mismatch's SM90 bias block refuses the split-KV and packed-GQA sets. A short-Q GQA graph over a long KV (B1, H_q 32 / H_kv 4, S_q 1, S_kv 512, or B4, H_q 16 / H_kv 4, S_q 32, S_kv 1024) got only split or packed sets from _knob_sets, so heuristic mode A returned no plan for it with an IO or FP32 bias while FALLBACK and explicit plans still offered one. On SM90 with a bias, _knob_sets now drops the split and packed sets and keeps one unsplit, unpacked set, so A offers the same 20540 plan as FALLBACK for these graphs. Bias-free lists are unchanged. The discovery test covers the short-Q shape, and a new mode-A test covers decode and short-Q GQA at D128, D256 and D512 over KV lengths up to 32768, with FP32 and IO-dtype biases.
…20541) The dedicated D128 template takes an additive [1|B, 1|H_q, S_q, S_kv] bias in the Q/K/V dtype on dense, nonpaged, unsplit, unpacked graphs, so a biased exact (128, 128) graph no longer has to run on engine 20540's 64 x 64 plans. WG0 loads each compute warpgroup's 64 x 128 bias tile per KV tile by TMA into that warpgroup's own SW128 slot, between the tile's K and V loads. Each compute thread loads its 32 bias words at the start of the tile's softmax and releases the slot through tile_dsl.consume (Rule 11). The logit is scale * QK + bias in natural units, formed before masking, and the row max is subtracted before the base-2 conversion (Rule S17). A slot's phase is the K ring's stage index. An FP32 bias tile does not fit beside the template's storage: the D128 row sets bias_io_dtype_only and D128_NOT_SERVED names bias_fp32, so an FP32 bias keeps engine 20540. A bias plan keeps the static persistent schedules (the claim counter binds through the native binder only). Bias-free specializations compile to identical PTX.
Adds 4 L0 determinism cells for the D128 template's bias leg (FP16/BF16, unmasked and top-left causal) with goldens under a6e0199439a0a182, and pins the D512-body cells to their 64 x 64 tile so their committed goldens keep applying. Adds warm stress on the per-KV-tile TMA refill of the bias slots for the persistent and one-tile records, and records the coverage and support status.
The A-mode fix for SM90 bias graphs lives in the parent PR. With the D128 template serving IO-dtype biases, the short-Q GQA shape from the review (B4, H_q 16 / H_kv 4, S_q 32, S_kv 1024) sits below D128_LEAD_MIN_SQ, so default discovery keeps engine 20540's unsplit, unpacked plan alone.
738acd7 to
58d7acb
Compare
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed 58d7acb3c3c8 against base bb786fe42a97.
Thank you for your contribution! No new finding in this rebase. The six contribution commits retain the previously reviewed runtime and test changes; only documentation insertion context changed. Rechecked compatibility with the newer base. The prior approval remains in place, with native Hopper validation still incomplete.
Validation: Current-head host admission, D128 routing, forward heuristic and geometry checks: 1,341 passed, 61 Hopper-only cases skipped and three cases deselected. Four offline SM90 code-generation checks passed against the current shared helper: serial, overlap, persistent and paired-causal D128 BF16 bias variants. Each dependent bias release still consumes all 32 loaded words through the final kernel parameter; disassembly shows no local-memory loads or stores. Confirmed the SM90 kernels, adapter, configuration and bias regression tests are byte-identical to the previously reviewed revision. Rechecked the precheck A03a candidate: barrier initialization remains under warp 0 and one elected lane. Approved the exact head's unchanged lint, security and docs-validation workflows under the standing rule and verified that GitHub queued or started each run.
Limitations: No native Hopper numerical, determinism, stress, sanitizer or performance validation was run here. Host and offline checks do not establish native GPU results. No new GPU pipeline was requested: the broad SDPA FROST target includes retained held tests, and the earlier runner/setup failures remain preserved. The rebase does not resolve those validation limits.
Comment only: this PR already has an active approval; preserving existing approvals.
Stacked on #2872. This branch is built on #2872's head (f8c9c25), so until #2872 merges the diff also shows its three commits. The changes in this PR are
7bd9e4b8,82257870and738acd70. I'll rebase onto develop once #2872 lands.Before submitting
pre-commit runand committed any formatting changes.AGENTS.mdfor each directory this PR touches (see root AGENTS.md § Reviewing a PR) and my changes comply, or I explain the exception below.cat-*, one or morearea:*/op:*, and oneorig-*(see label list).I don't have triage rights here, so I couldn't add labels. Suggested:
cat-feature,area:frost,area:global_attention,orig-external,mod-cutedsl,mod-frost.Affected area
FE OSS kernels or CuTeDSL
Summary
Adds an additive bias to the dedicated SM90 D128 forward template (engine 20541,
sdpa/fwd/kernels/sm90/d128_f16_multi_q). This is the follow-up to #2872, which added bias to the three-WG body (engine 20540). Builds on #2872 (stacked on its head, f8c9c25).[1|B, 1|H_q, S_q, S_kv]in the Q/K/V dtype, with contiguous keys and 16-byte aligned outer pitches (the contract feat(sdpa): additive bias on the SM90 three-WG forward (engine 20540) #2872 introduced). Noncausal and causal, every D128 record (v1, overlap, persistent stride and paired walk), Stats in either log base, any scale sign.bias_io_dtype_only, andconfig_sm90.D128_NOT_SERVEDnamesbias_fp32(it replaces feat(sdpa): additive bias on the SM90 three-WG forward (engine 20540) #2872'sbiasentry), so the picker and the template refusal agree.tile_dsl.consume.consume_then_arrive(Rule 11: the arrive's address depends on every loaded word), so WG0's refill overlaps the rest of that softmax and the next QK. The logit isscale * QK + biasin natural units, formed before masking, and the row max is subtracted before the base-2 conversion (Rule S17), as in feat(sdpa): additive bias on the SM90 three-WG forward (engine 20540) #2872. Each slot completes one phase per KV tile, so its parity is the K ring's stage index, carried across a persistent CTA's items.prepared_host.host_biasand appendsbiasto__call__, so it uses the same pointer ABI and the same Python dense frame as the three-WG body. A bias plan keeps the static persistent schedules: the claim counter binds through the native binder, which has no bias slots.check_supportkeeps it off andvalidate_paramsrefuses the combination.frost/support/sm90.md, the template README, the determinism status page and the coverage report are updated.Why
With #2872 a biased (128, 128) graph runs on engine 20540's 64 x 64 plans, which trail the backend's bias engine at every measured shape (0.64-0.83x). The dedicated D128 template without a bias runs at about 2x the backend's bias path, so it is the body to put the bias on. harshithkantamneni confirmed on #378 that this was open.
Related issues
Related to #378, follows #2872. #2687 (device lengths in the same D128 kernel, on merge hold) touches the same file; whichever lands second will need a rebase, with no overlap in behavior.
API and compatibility impact
SdpaFwdDslSm90(sample_bias=...)now takes the D128 template for an exact (128, 128) bias in the Q/K/V dtype (as it does for a bias-free graph); pinningtile_m=tile_n=64keeps engine 20540. An FP32 bias keeps engine 20540.D128_LEAD_MIN_SQquery rows, as for a bias-free graph. Moving 20541 ahead of the backend for biased graphs would be a placement change, which I left out of this PR.torch.profiler, a 256 MiB L2 scrub before each iteration, median of 30. The backend column is its heuristic choice with the FROST slots deselected. Every column comes from one job (d128_bias_bench.py; shapes fixed before the first run). Bias overhead is 20541 with a bias over 20541 without one. The bias column gives its broadcast form: shared(1,1), batch(B,1), head(1,H), full(B,H). The bias is in the Q/K/V dtype.20541 is 1.69 to 1.92 times as fast as the backend's bias engine at every measured shape, and 2.26 to 2.74 times as fast as 20540's 64 x 64 plans, which these graphs ran on before. Against the backend's output, the maximum relative error was 2.0e-3 to 3.5e-3 in BF16 and 2.2e-4 to 6.0e-4 in FP16, the same level as #2872. With an FP32 bias the same graphs keep running on 20540 at 0.61 to 0.86 times the backend's speed (same job), which is what a later FP32 path on this template would address.
Testing
Run on an NVIDIA H200 (cc 9.0, 132 SMs): driver 570.86.15 with the CUDA 13 forward compatibility libraries, PyTorch 2.15.0+cu132, cuDNN 9.28.1 (92801), CuTe DSL 4.8.1 (compiles with CUDA 13.4). Commands run from
test/python:test_sdpa_bias_sm90.py(engine 20541 cases added beside 20540's): an FP64 reference with partial Q and KV tiles and a bias pitch wider than S_kv, covering:-infrows;D128_LEAD_MIN_SQ. The one skip is the paired walk on a dense graph (causal only).a6e0199439a0a182). The 12 cells of 20540 now pin its 64 x 64 tile (the adapter takes 20541 for these graphs otherwise); their committed goldens matched the new record byte for byte.warm_stress.assert_release_dependence). A compile-only census also rendered 11 bias records with no local memory.Not covered:
fern checkwas not run.