Repository navigation
Keep the sign of a zero on a Diagonal argument of a sparse broadcast - #1085
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1085 +/- ##
==========================================
+ Coverage 94.75% 94.79% +0.03%
==========================================
Files 16 16
Lines 9885 9886 +1
==========================================
+ Hits 9367 9371 +4
+ Misses 518 515 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ViralBShah
commented
Oct 13, 2026
ViralBShah
left a comment
Member
Author
There was a problem hiding this comment.
Reviewed by Codex at 6129598.
No actionable findings. Materializing the complete diagonal preserves stored signed zeros for the broadcast kernel while leaving implicit off-diagonal zeros implicit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
Diagonalargument of a sparse broadcast loses the sign of a-0.0on its diagonal, so the result differs from the dense one.Before
After
Broadcast and
mapconvert a structured argument with_sparsifystructured. For aDiagonalthat went throughSparseMatrixCSC(D), which drops the zeros of the diagonal, and the kernel then read the dropped-0.0as a structural+0.0.Bidiagonal,TridiagonalandSymTridiagonalarguments already convert with their whole band stored, zeros included, so they were not affected._sparsifystructured(::Diagonal)now stores the whole diagonal as well.SparseMatrixCSC(D)andsparse(D)are unchanged.The stored pattern of a zero-preserving result does not change: the kernels store only the nonzero values they compute, so
S .* D,S .+ D,S .- D,map(+, S, D)andbroadcast!(*, Z, S, D)with zeros (of either sign) on the diagonal have the samennzand pattern as onmain.Touches dispatch: adds the internal method
_sparsifystructured(::Diagonal).Split from #1022. A bug fix with no change of result type, so a backport candidate.
Written by Claude Code.
🤖 Generated with Claude Code