can_setindex must be false for CUSPARSE arrays#495
Merged
ChrisRackauckas merged 1 commit intoJul 14, 2026
Conversation
CuSparseVector and the CuSparseMatrix formats implement no setindex! at all, but can_setindex fell back to the `true` default for them, so callers guarding mutation with it (e.g. NonlinearSolveBase's safe_similar) hit a CanonicalIndexError instead of taking their non-mutating path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e6274c6 to
d1a1cc6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #495 +/- ##
==========================================
- Coverage 60.00% 59.89% -0.11%
==========================================
Files 15 15
Lines 590 591 +1
==========================================
Hits 354 354
- Misses 236 237 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5 tasks
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.
cuSPARSE arrays implement no
setindex!at all, butcan_setindexfalls back totruefor them, so callers that guard mutation with it crash instead of taking their
non-mutating path:
This declares
can_setindex = falsefor the cuSPARSE types in the CUDA extension, with atest in
test/gpu/cuda.jl. The AMDGPU/Metal sparse types might need the same; I left themalone as I can't test them.