Skip to content

Simpler StridedView wrapping and Diagonal support#194

Merged
mtfishman merged 5 commits into
mainfrom
mf/inline-strided-permute
Jul 1, 2026
Merged

Simpler StridedView wrapping and Diagonal support#194
mtfishman merged 5 commits into
mainfrom
mf/inline-strided-permute

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Uses simpler and faster StridedView wrapping logic in bipermutedimsopadd!, removes the unnecessary CPU branch check, and adds Diagonal support so permutation, matricization, and matrix functions preserve a Diagonal instead of materializing it (isolated in src/diagonal.jl). Strided handles GPU StridedView parents since 2.6, so the compat floor moves there, with StridedViews at 0.5 to match.

This is breaking: structured array types that relied on the previous generic broadcast fallback now need their own bipermutedimsopadd! overload.

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

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.23%. Comparing base (679f479) to head (a3abc5c).

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     
Flag Coverage Δ
docs 27.84% <31.57%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@mtfishman mtfishman changed the title Permute StridedViews directly in bipermutedimsopadd! [WIP] Permute StridedViews directly in bipermutedimsopadd! Jun 30, 2026
@mtfishman mtfishman marked this pull request as draft June 30, 2026 17:22
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>
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 mtfishman changed the title [WIP] Simpler StridedView wrapping and Diagonal support Simpler StridedView wrapping and Diagonal support Jul 1, 2026
@mtfishman mtfishman marked this pull request as ready for review July 1, 2026 02:02
@mtfishman mtfishman enabled auto-merge (squash) July 1, 2026 02:02
@mtfishman mtfishman merged commit 5e7700e into main Jul 1, 2026
31 checks passed
@mtfishman mtfishman deleted the mf/inline-strided-permute branch July 1, 2026 02:25
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant