test(st): Add Mat slice to Left matmul pattern system test#1225
test(st): Add Mat slice to Left matmul pattern system test#1225Crystal-wzy wants to merge 1 commit intohw-native-sys:mainfrom
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new runtime test that validates Mat → slice → move-to-Left → matmul(+matmul_acc) codegen, and updates the call-direction derivation pass to avoid promoting certain Out args to InOut when writes are disjoint-store patterns (with a per-callee/arg cache). Also adds a unit test for the R-seq exception case. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 13 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/st/runtime/test_mat_slice_to_left.py (1)
131-138: Assert codegen pattern explicitly, not onlyresult.passed.This test currently proves correctness/compilability, but it doesn’t explicitly lock the regression target (
pl.slice(Mat) -> pto.subview, thenpl.move(subview, Left) -> pto.tmov). Adding codegen-text assertions here would make the test much more robust against future lowering drift.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/st/runtime/test_mat_slice_to_left.py` around lines 131 - 138, The test should not only assert result.passed but also verify the generated IR/text contains the expected lowering patterns: check that the lowering of TestMatSliceToLeft includes a pl.slice(Mat) -> pto.subview sequence and a pl.move(subview, Left) -> pto.tmov sequence; after calling test_runner.run(TestMatSliceToLeft) use the runner's returned artifact that exposes generated code (e.g., result.codegen or result.ir) and add assertions that those exact substrings/patterns appear (or use regexes) to lock the regression target in the TestMatSliceToLeft test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/st/runtime/test_mat_slice_to_left.py`:
- Line 18: Docstring text contains the Unicode multiplication sign "×" which
triggers Ruff RUF002; update the docstring line containing the phrase "K-chunks
into one wider GM load (row = 2 × 128 × 2 = 512 B) and splitting" in
tests/st/runtime/test_mat_slice_to_left.py to use the ASCII letter "x" (e.g.,
"row = 2 x 128 x 2 = 512 B") so the comment no longer contains ambiguous Unicode
characters.
---
Nitpick comments:
In `@tests/st/runtime/test_mat_slice_to_left.py`:
- Around line 131-138: The test should not only assert result.passed but also
verify the generated IR/text contains the expected lowering patterns: check that
the lowering of TestMatSliceToLeft includes a pl.slice(Mat) -> pto.subview
sequence and a pl.move(subview, Left) -> pto.tmov sequence; after calling
test_runner.run(TestMatSliceToLeft) use the runner's returned artifact that
exposes generated code (e.g., result.codegen or result.ir) and add assertions
that those exact substrings/patterns appear (or use regexes) to lock the
regression target in the TestMatSliceToLeft test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5b292123-43d0-45ab-99fe-5b4291d8f8b9
📒 Files selected for processing (1)
tests/st/runtime/test_mat_slice_to_left.py
There was a problem hiding this comment.
Code Review
This pull request introduces a new system test, test_mat_slice_to_left.py, which validates a specific memory access pattern: loading a wide BF16 tile into Mat memory to meet alignment requirements, slicing it into subviews, and moving those subviews to Left memory for matmul operations. This test specifically targets scenarios encountered in Qwen3 decode kernels. I have no feedback to provide.
ee59324 to
70dd9e9
Compare
## Summary - Add TestMatSliceToLeft PTOTestCase validating the wide Mat load → slice → Left matmul pattern for issue hw-native-sys#1198, where a single [M, 2K] BF16 tile is loaded into Mat to satisfy the 512 B GM row-alignment constraint, sliced into two [M, K] subviews, moved to Left, and used in K-split matmul + matmul_acc accumulation - Add TestMatSliceToLeftSuite pytest suite parametrized over PLATFORMS with PyTorch golden reference (A[:,:K]@b0 + A[:,K:]@b1) - Codegen expectation: pl.slice on Mat tile → pto.subview (zero-copy), pl.move from subview → pto.tmov (Mat subview → Left) ## Testing - [x] Parametrized test passes on 910B PTO hardware - [x] PyTorch golden reference validated - [x] Pre-commit hooks pass (ruff, pyright) Closes hw-native-sys#1198
17bdc62 to
3aa67fd
Compare
Summary
Testing
Closes #1198