Add sliding-window attention validation checks#2438
Conversation
Reject invalid window configurations before generating IR and cover the corresponding Rock verifier diagnostics. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR strengthens sliding-window attention validation by rejecting invalid rocmlir-gen CLI configurations early and adding negative lit coverage for Rock dialect verifier diagnostics related to sliding-window attention.
Changes:
- Add
rocmlir-genargument validation forsliding_window_size(non-negative, fits i32, requirescurrent_seq_len, and must not exceedseq_len_k). - Add
rocmlir-genlit tests covering the new sliding-window CLI error paths. - Add Rock dialect verifier negative tests for
rock.attentionandrock.gridwise_attention_accelsliding-window diagnostics (including use when not in attention mode).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mlir/tools/rocmlir-gen/rocmlir-gen.cpp | Adds early validation checks for sliding-window attention CLI options to prevent invalid IR/materialization. |
| mlir/test/rocmlir-gen/options.mlir | Adds lit coverage ensuring rocmlir-gen emits the expected diagnostics for invalid sliding-window configurations. |
| mlir/test/Dialect/Rock/ops_error.mlir | Adds -verify-diagnostics coverage for Rock op verifier errors related to sliding-window usage and constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Verdict: APPROVE -- submitted as COMMENT (automated reviews are advisory) · Findings: 0 (0 Critical, 0 Major, 0 Minor)
Scope
Adds input validation for sliding-window attention in rocmlir-gen (rejects negative, oversized/non-i32, and missing-current_seq_len configurations) and extends lit coverage: options.mlir for the generator diagnostics and ops_error.mlir for the pre-existing rock.attention / rock.gridwise_attention_accel verifier diagnostics. Touches only 3 files (one .cpp, two .mlir tests).
Findings
No blocking issues found.
Notes
mlir/tools/rocmlir-gen/rocmlir-gen.cpp:1343-1362: validation logic is correct.slidingWindowSizeiscl::opt<int64_t>, so the> INT32_MAXguard is meaningful (a smaller type would make it dead code). The-sliding_window_size=2147483648test fits inint64_tand correctly trips the i32 guard. Check ordering (non-negative -> i32-fit -> requires-current_seq_len -> not-exceed-seq_len_k) is consistent with the fouroptions.mlirFileCheck prefixes, and all four error strings match verbatim.- Semantics are coherent:
init(0)= disabled, negative = rejected, positive = enabled (matches the test comments). #include <limits>(line 173) is correctly placed in the stdlib group and lexicographically sorted (limits<tuple<unordered_map) per the include-order Minor bullet.- No new files, so no license-header/CMake concerns; no new deps, so
librockcompiler_deps.cmakeis untouched appropriately. Both edited.mlirfiles are already-registered test files, so noCMakeLists.txtregistration is required. - Spot-check limitation: the
ops_error.mlirverifier diagnostic strings are asserted against pre-existing verifier code (not modified by this diff); the in-progress premerge lit run is the authoritative check of exact-string matching.
CI status
No non-self checks report fail or cancel. C/C++ premerge checks is still in progress; the auto-review pipeline's own review check being in-progress is expected and not a CI failure.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2438 +/- ##
===========================================
+ Coverage 82.57% 83.60% +1.03%
===========================================
Files 120 120
Lines 42852 42952 +100
Branches 7110 7144 +34
===========================================
+ Hits 35381 35906 +525
+ Misses 4815 4483 -332
+ Partials 2656 2563 -93
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
rocmlir-gen, including negative, missing sequence length, oversized, and non-i32 valuesrock.attentionandrock.gridwise_attention_accel, including use on non-attention operationsTest plan
ninja rocmlir-gen rocmlir-optgit clang-format --diff origin/developMade with Cursor