frost(sdpa): add more features like padded head dim, skv_tile=0, diagonal_band_right_bound to sm120 frost sdpa prefill kernel - #531
Conversation
…und to sm120 frost sdpa_fwd kernel Signed-off-by: Haobin Guo <haobing@nvidia.com>
📝 WalkthroughWalkthroughSM120 SDPA now accepts head dimensions divisible by 8, rounds them to compile-time envelopes with TMA zero-padding, supports causal ChangesSM120 SDPA forward support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DenseDSLGraphRunner
participant SM120FusedMultiHeadAttentionForward
participant TMA
participant CausalMask
DenseDSLGraphRunner->>SM120FusedMultiHeadAttentionForward: Compile rounded head tiles and window_size_right
SM120FusedMultiHeadAttentionForward->>TMA: Load exact or envelope-padded K/V tiles
SM120FusedMultiHeadAttentionForward->>CausalMask: Apply shifted diagonal and right_slack
CausalMask-->>SM120FusedMultiHeadAttentionForward: Valid column bounds
SM120FusedMultiHeadAttentionForward-->>DenseDSLGraphRunner: Execute attention output
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@cudnn-ci-bot run frost |
|
🚀 Running mirror pipeline Branch: cudnn-gh/pr-531-c084afb |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/python/sdpa/frost/test_sdpa_fwd_dsl_sm120.py (1)
129-134: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the reference reject the contradictory
is_causal+window_size_rightcombination.
_apply_mask_kwargstreats a non-Nonewindow_size_rightas a band and ignoresis_causal. The reference applies both bounds, soj > limwins overj > lim + R. If a future test passes both flags, the reference and the graph diverge silently and the test fails for the wrong reason.No current test hits this. Add an assertion so the trap surfaces immediately.
♻️ Proposed guard
+ assert not (is_causal and window_size_right is not None), "a right bound makes the mask a band; do not also pass is_causal (see _apply_mask_kwargs)" if is_causal: masked = masked | (j > lim) if window_size_right is not None: masked = masked | (j > lim + window_size_right)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/python/sdpa/frost/test_sdpa_fwd_dsl_sm120.py` around lines 129 - 134, Update the reference mask logic around is_causal and window_size_right to assert that both are not provided together, before applying either bound. Keep the existing masking behavior unchanged for valid argument combinations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/python/sdpa/frost/test_sdpa_fwd_dsl_sm120.py`:
- Around line 129-134: Update the reference mask logic around is_causal and
window_size_right to assert that both are not provided together, before applying
either bound. Keep the existing masking behavior unchanged for valid argument
combinations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 4be16fbe-155f-4160-9bfd-9e89e239df94
📒 Files selected for processing (6)
python/cudnn/sdpa/fwd/api_dsl.pypython/cudnn/sdpa/fwd/config_sm120.pypython/cudnn/sdpa/fwd/engines.pypython/cudnn/sdpa/fwd/kernels/prefill_f16_sm120.pytest/python/sdpa/frost/test_sdpa_fwd_dsl_sm120.pytest/python/sdpa/frost/test_sdpa_graph_analyzer.py
Before submitting
pre-commit runand committed any formatting changes.cat-*, one or moremod-*, and oneorig-*(see label list).Affected area
Summary
Support three features for the SM120 FROST SDPA forward engine:
skv_tile=0on the SM120 row: the sm120 prefill kernel's first (masked) KV step always covers the rightmost (and therefore any partial) tile, so no padding mask or synthesized lengths are needed.window_rightin the band model), for TOP_LEFT and BOTTOM_RIGHT alignments; composes with SWA / padding / stats / sink / THD / mixed head dims.Why
Narrow the functional gap between the sm120 frost sdpa kernels and the native ones.
Related issues
Related to #381.
API and compatibility impact
SdpaFwdDslSm120now accepts: any d_qk/d_v multiple of 8 ≤ 256 (was: multiples of 16), window_size_right (with is_causal), and dense unmasked graphs with S_kv not a multiple of the KV tilewindow_size_rightridesTemplateParams.window_right(band model)Testing
pytest sdpa/frost/test_sdpa_fwd_dsl_sm120.py -m "L0 or L1": 62 passed, 0 failedSummary by CodeRabbit
New Features
Bug Fixes