Simpler StridedView wrapping and Diagonal support#194
Merged
Conversation
Wraps each operand in a StridedView and permutes the source view directly in bipermutedimsopadd!, instead of routing through maybestrided and a lazy PermutedDimsArray. Co-authored-by: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
- Coverage 83.25% 83.23% -0.03%
==========================================
Files 22 22
Lines 645 650 +5
==========================================
+ Hits 537 541 +4
- Misses 108 109 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Removing the `maybestrided` strided fallback is breaking for downstream array types that relied on the generic broadcast path. Co-authored-by: Claude <noreply@anthropic.com>
Specializes the low-level interface primitives (`bipermutedimsopadd!`, `similar` on a `BiTuple`, `matricize`, `unmatricize`) for `Diagonal`, so permutation, matricization, and matrix functions preserve the `Diagonal` instead of materializing it through the `StridedView`-based generic path. New code is isolated in `src/diagonal.jl`. Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Jun 30, 2026
The bipermutation of a square `Diagonal` is structurally a square `Diagonal` of the same size, so overload `allocate_output(::typeof(permutedimsop), ...)` for `Diagonal` rather than `similar(::Diagonal, ::BiTuple)`. The squareness invariant comes from the source, which row/column axes alone cannot encode, so the axis-based `similar` was the wrong hook. `contract` still densifies a `Diagonal` result through Base's dense `similar`, since it allocates from a flat axis tuple rather than a `BiTuple`.
Cover the `Diagonal` specializations: structure preservation through `bipermutedims`, `add!`, `matricize`/`unmatricize`, and the matrix functions, the `allocate_output` hook, and that `contract` still densifies a `Diagonal` result.
mtfishman
added a commit
to ITensor/SparseArraysBase.jl
that referenced
this pull request
Jul 1, 2026
## Summary Adds a `bipermutedimsopadd!` method for sparse destinations, so permutation and accumulation keep working after TensorAlgebra's `bipermutedimsopadd!` switched to a `StridedView`-based permute path that a sparse array cannot wrap (ITensor/TensorAlgebra.jl#194). The accumulation reuses TensorAlgebra's logic over a lazily permuted source. --------- Co-authored-by: Claude <noreply@anthropic.com>
mtfishman
added a commit
to ITensor/ITensorBase.jl
that referenced
this pull request
Jul 1, 2026
## Summary Removes the `BlockArrays` extension along with its tests, since there is no current need to wrap `BlockArrays` types directly. This drops functionality downstream code may rely on, so it is a breaking release. It also raises the `TensorAlgebra` compat bound to 0.14 (ITensor/TensorAlgebra.jl#194).
mtfishman
added a commit
to ITensor/GradedArrays.jl
that referenced
this pull request
Jul 1, 2026
## Summary Fixes graded contraction and `add!` under TensorAlgebra 0.14's `StridedView`-based permute path (ITensor/TensorAlgebra.jl#194). `unmatricize(::SectorFusion, ::FusedGradedMatrix, …)` now returns a graded rank-0 array for the scalar case, matching the graded result it returns at every other rank, so the permute-add back into the destination dispatches to the graded `bipermutedimsopadd!` overload rather than the generic strided one. It also defines `StridedViews.StridedView(::AbelianSectorArray)` as a view of its data block, so adding an `AbelianSectorArray` into a plain dense array works.
mtfishman
added a commit
to ITensor/ITensorNetworksNext.jl
that referenced
this pull request
Jul 1, 2026
## Summary Raises the compat bounds so ITensorNetworksNext builds against the TensorAlgebra 0.14 release train (ITensor/TensorAlgebra.jl#194): `TensorAlgebra` to 0.14, `ITensorBase` to 0.10, and `GradedArrays` to 0.13.2 in the tests. The fixes for the new `StridedView`-based permute path all live in those dependencies, so this is a compat-only bump.
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.
Summary
Uses simpler and faster
StridedViewwrapping logic inbipermutedimsopadd!, removes the unnecessary CPU branch check, and addsDiagonalsupport so permutation, matricization, and matrix functions preserve aDiagonalinstead of materializing it (isolated insrc/diagonal.jl). Strided handles GPUStridedViewparents since 2.6, so the compat floor moves there, withStridedViewsat0.5to match.This is breaking: structured array types that relied on the previous generic broadcast fallback now need their own
bipermutedimsopadd!overload.