Repository navigation
Fix bsr_get_diag zero fill for missing blocks - #1170
Conversation
Signed-off-by: Cucchi01 <cucchi01centr@gmail.com>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)warp/tests/test_sparse.py (2)
🪛 Ruff (0.14.10)warp/tests/test_sparse.py247-247: (F405) 🔇 Additional comments (2)
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. Comment |
Greptile OverviewGreptile SummaryThis PR fixes a bug in The Fix:
The Test:
The kernel Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant bsr_get_diag
participant out array
participant _bsr_get_diag_kernel
User->>bsr_get_diag: Call with BSR matrix A and out buffer
alt out is None
bsr_get_diag->>out array: Create zeros(dim)
else out is provided
bsr_get_diag->>bsr_get_diag: Validate dtype, device, shape
bsr_get_diag->>out array: out.zero_() [NEW FIX]
end
bsr_get_diag->>_bsr_get_diag_kernel: Launch kernel(scale, offsets, columns, values, out)
loop For each row
_bsr_get_diag_kernel->>_bsr_get_diag_kernel: diag = bsr_block_index(row, row, ...)
alt diag != -1 (diagonal block exists)
_bsr_get_diag_kernel->>out array: out[row] = scale * A_values[diag]
else diag == -1 (no diagonal block)
Note over _bsr_get_diag_kernel,out array: out[row] remains zero (from zero_() call)
end
end
bsr_get_diag-->>User: Return out array
|
gdaviet
left a comment
There was a problem hiding this comment.
Good catch, thanks for the PR!
|
Thanks @Cucchi01, this is now merged and will be a part of the next Warp release. |
Description
To my understanding,
bsr_get_diagshould produce the same result whether or not anoutarray is provided. Previously, whenoutwas passed, it was not zero-initialized, causing missing diagonal blocks to retain whatever values were already inoutinstead of being set to 0.0. This PR fixes that and adds a regression test.Before your PR is "Ready for review"
__init__.pyi,docs/api_reference/,docs/language_reference/)pre-commit run -aSummary by CodeRabbit
Bug Fixes
bsr_get_diag()to properly initialize output buffers when provided by users, ensuring correct results when writing diagonal blocks to an external buffer.Tests
✏️ Tip: You can customize this high-level summary in your review settings.