Skip to content

Shed registry-blocking deps, add per-position fusion styles, switch to explicit factorization names#180

Merged
mtfishman merged 4 commits into
mainfrom
mf/v0.10
Jun 23, 2026
Merged

Shed registry-blocking deps, add per-position fusion styles, switch to explicit factorization names#180
mtfishman merged 4 commits into
mainfrom
mf/v0.10

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Bumps TensorAlgebra to 0.10.0, a breaking release that prepares it for the General registry and reworks two pieces of the interface.

Drops the FunctionImplementations and TypeParameterAccessors dependencies, the only two things keeping TensorAlgebra out of the General registry. TensorAlgebra now owns the shared in-place extension points zero! and scale! and the lazy permuteddims hook, declared public so downstream array types can overload them directly. The two small TypeParameterAccessors helpers used internally are inlined as thin Base wrappers. Also removes the over-broad getindex(::AbstractArray, ::AbstractBlockPermutation) shorthand, which was type piracy and an ambiguity trap with no external users, in favor of the existing blockpermute.

Gives the Matricize contraction algorithm three fusion styles (left_fusion_style, right_fusion_style, output_fusion_style), one for each reshape position, instead of a single shared one. A single-style constructor copies to all three, so the symmetric common case and existing callers are unchanged. This lets a backend that needs one position to behave differently (the fermionic contraction twist on the second operand in GradedArrays) pick a distinct style at algorithm selection without re-overloading the whole routine.

Switches the tensor-level factorizations from the catch-all names (svd, qr, lq, eigen, eigvals, svdvals, polar, orth, factorize) to the explicit names MatrixAlgebraKit uses (svd_compact, svd_full, svd_trunc, qr_compact, qr_full, eigh_full, eig_full, and the rest), so the variant lives in the name rather than behind a full, trunc, or ishermitian keyword. These are TensorAlgebra-owned functions taking the codomain/domain partition signature, out-of-place only. The MatrixAlgebra submodule sheds the matrix-level wrappers that re-exposed those catch-alls and keeps only what MatrixAlgebraKit does not provide (gram_eigh_full, the safe-clamping helpers, the degenerate-truncation strategy).

Drops the `FunctionImplementations` and `TypeParameterAccessors` dependencies. TensorAlgebra now owns the shared in-place extension points `zero!` and `scale!` (new `src/inplace.jl`) and the lazy `permuteddims` hook, all declared `public` so downstream array types can overload them without TensorAlgebra depending on a separate package for them. The two small `TypeParameterAccessors` helpers used internally are inlined as thin `Base` wrappers.

Also deletes the over-broad `getindex(::AbstractArray, ::AbstractBlockPermutation)` shorthand, which was type piracy and an ambiguity trap with no external users, and rewrites the internal `axes(x)[biperm]` call sites to `blockpermute(...)`.

Bumps to 0.10.0.
The matricize contraction does three reshapes: matricize each operand, multiply, then unmatricize the result. These shared a single `fusion_style` field on `Matricize`. Split it into `left_fusion_style` / `right_fusion_style` / `output_fusion_style`, one per reshape position, and route each step through its own style. A single-style constructor copies to all three, so the common symmetric case and existing callers are unchanged.

This lets a backend that needs one position to behave differently (the fermionic contraction twist on the second operand in GradedArrays) pick a distinct style at algorithm selection without re-overloading the whole `contractopadd!` routine.
Replaces the catch-all factorization names (`svd`, `svdvals`, `qr`, `lq`, `eigen`, `eigvals`, `polar`, `orth`, `factorize`) at the tensor level with the explicit names MatrixAlgebraKit uses (`svd_compact` / `svd_full` / `svd_trunc` / `svd_vals`, `qr_compact` / `qr_full`, `lq_compact` / `lq_full`, `eigh_full` / `eig_full` / `eigh_trunc` / `eig_trunc` / `eigh_vals` / `eig_vals`). The variant is now in the name rather than behind a `full` / `trunc` / `ishermitian` keyword. These are TensorAlgebra-owned functions taking the codomain/domain partition signature, so they do not pirate MatrixAlgebraKit, and only out-of-place versions are provided. The existing `left_polar` / `right_polar` / `left_orth` / `right_orth` / `left_null` / `right_null` already follow this convention and are unchanged.

The `MatrixAlgebra` submodule no longer carries the thin matrix-level wrappers that re-exposed MatrixAlgebraKit under those catch-all names. It keeps only the functionality MatrixAlgebraKit does not provide: `gram_eigh_full` / `gram_eigh_full_with_pinv`, the safe-clamping helpers, and the degenerate-truncation strategy.
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.56%. Comparing base (2783b56) to head (fa29830).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/inplace.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
+ Coverage   81.37%   81.56%   +0.18%     
==========================================
  Files          26       27       +1     
  Lines        1047      987      -60     
==========================================
- Hits          852      805      -47     
+ Misses        195      182      -13     
Flag Coverage Δ
docs 28.06% <27.08%> (+1.86%) ⬆️

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.

@mtfishman mtfishman marked this pull request as ready for review June 23, 2026 14:20
@mtfishman mtfishman changed the title [WIP] Shed registry-blocking deps, add per-position fusion styles, switch to explicit factorization names Shed registry-blocking deps, add per-position fusion styles, switch to explicit factorization names Jun 23, 2026
@mtfishman mtfishman enabled auto-merge (squash) June 23, 2026 14:29
@mtfishman mtfishman merged commit 8175959 into main Jun 23, 2026
26 checks passed
@mtfishman mtfishman deleted the mf/v0.10 branch June 23, 2026 14:51
mtfishman added a commit to ITensor/ITensorBase.jl that referenced this pull request Jun 23, 2026
## Summary

Adapts ITensorBase to TensorAlgebra v0.10 and tightens the named-array
surface, as one breaking release.

Defines ITensorBase's `AbstractITensor` factorizations as overloads of
`MatrixAlgebraKit`'s functions (`qr_compact`, `svd_compact`,
`left_orth`, and the rest), each forwarding to the matching
`TensorAlgebra` array-level method on the unnamed data. This mirrors how
`*` on `AbstractITensor` forwards to `TensorAlgebra.contract`: a
factorization of a named tensor acts as that factorization on its
matricized form, with `TensorAlgebra` handling the matricization. It
replaces the previous `LinearAlgebra`-style `svd` / `qr` / `lq` /
`eigen` catch-alls, which overloaded `LinearAlgebra` for a type that is
not an `AbstractArray`, and adopts the explicit factorization names
TensorAlgebra v0.10 exposes
(ITensor/TensorAlgebra.jl#180). For
`gram_eigh_full` and `gram_eigh_full_with_pinv`, which have no
`MatrixAlgebraKit` counterpart, the overloads target
`TensorAlgebra.MatrixAlgebra`. Adds `MatrixAlgebraKit` as a direct
dependency.

Renames the unnamed-array accessors `dename` / `denamed` to `unname` /
`unnamed` throughout, including the `Unnamed` type, the `unnamedtype`
and `unnamed_prototype` helpers, and internal locals.

Makes `length` and `size` of a named array or named unit range return a
plain `Int`, and `axes` / `eachindex` return plain unnamed ranges, so
the count and positional-index layer match Base and the `AbstractArray`
contract that `axes` are `AbstractUnitRange{Int}`. The name stays on the
elements (`a[i]`, `first`, `last`, iteration) and on a tensor's named
indices via `inds` / `axes(::AbstractITensor)`. This lets
`length(::AbstractITensor)` be the plain element count (the product of
its size), which previously errored.

Bumps to 0.7.0 and requires TensorAlgebra 0.10.
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