Repository navigation
Return the dense result of a broadcast whose index type cannot address every entry - #1086
Merged
Merged
Conversation
…s every entry 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 #1086 +/- ##
==========================================
+ 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 3a97dbb.
No actionable findings. Checking the promoted sparse index type against the broadcast result shape before entering the fully stored sparse kernel addresses the narrow-index failure; the fallback preserves the dense result container.
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 broadcast whose function is not zero at the zeros returns a dense array, but it is computed by the sparse kernels, which store every entry in a sparse array with the index type of the arguments. When that index type cannot address every entry, the call throws although the dense result is representable.
Before
After
_densenonzeronow asks, from the promoted index type of the arguments and the shape of the result, whether that type addresses every entry, and otherwise hands the broadcast to_densebroadcast, as it already does for aBoolor non-concrete element type. The check is on a type and folds away, socos.(A)for anInt-indexed matrix stays inferred asMatrix{Float64}; at 10^6 entries its time (2.0 ms) and allocations (16.0 MB) are the same as onmain.Left out: the in-place forms on the same matrix (
S .= 1.0,map!), which fail for the same reason in a sparse destination and are a separate change.Split from #1022. A bug fix with no change of result type, so a candidate for backporting.
Written by Claude Code.
🤖 Generated with Claude Code