Skip to content

Replace the blocked-tuple types with a single BiTuple and drop the BlockArrays extension#181

Merged
mtfishman merged 9 commits into
mainfrom
mf/v0.11
Jun 24, 2026
Merged

Replace the blocked-tuple types with a single BiTuple and drop the BlockArrays extension#181
mtfishman merged 9 commits into
mainfrom
mf/v0.11

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Replaces TensorAlgebra's blocked-tuple type family with a single concrete BiTuple, and removes the BlockArrays extension.

Matricization, contraction, and factorizations only ever split a tensor's indices into two groups, a codomain and a domain, so the general N-block machinery and its BlockArrays-style apparatus were more than that use needs. Internally the two groups are carried by a BiTuple, a two-field tuple that still iterates and indexes as the flat tuple (t1..., t2...). The user-facing surface collapses to two plain-tuple helpers: bipartition splits a tuple into its two groups, and biperm locates two partitioning groups within a collection. Both return the groups as an ordinary pair of tuples, so callers pass two tuples rather than a dedicated bundle type.

With the BlockArrays-style apparatus gone, the TensorAlgebraBlockArraysExt extension and the BlockArrays weak-dependency are dropped, and the BlockReshapeFusion matricization style it defined moves to its only consumer, GradedArrays (ITensor/GradedArrays.jl#181).

This is a breaking release.

…ockArrays extension

Replaces TensorAlgebra's blocked-tuple type family with a single concrete `BiTuple`, and removes the BlockArrays extension.

Matricization, contraction, and factorizations only ever split a tensor's indices into two groups, a codomain and a domain, so the general N-block machinery (a family of `AbstractBlockTuple` / `BlockedTuple` / blocked-permutation types plus a BlockArrays-style `Block` / `mortar` / broadcast apparatus) was more than that use needs. It is all replaced by one two-field type:

```julia
struct BiTuple{N1, N2, T1 <: NTuple{N1, Any}, T2 <: NTuple{N2, Any}}
    t1::T1
    t2::T2
end
```

The builder names are unchanged (`tuplemortar`, `permmortar`, `blockedperm`, `blockedpermvcat`, `blockedperm_indexin`, `trivialbiperm`, `blockpermute`), backed by a small accessor surface (`blocks`, `firstblock`, `lastblock`, `blocklengths`). A biperm is a `BiTuple` of `Int`s whose permutation property the perm builders validate at construction, the way `permutedims(a, perm)` validates its `perm`, rather than encoding it in a dedicated type.

Removing the BlockArrays-style apparatus leaves `TensorAlgebraBlockArraysExt` with nothing to provide, so the extension and the `BlockArrays` weak-dependency are dropped. The `BlockReshapeFusion` matricization style it defined for block-structured arrays moves to GradedArrays, its only consumer.

This is a breaking release: the removed blocked-tuple and blocked-permutation types, the `Block*` family, the N-block and ellipsis `blockedpermvcat` forms, and the BlockArrays extension are all gone. Downstream packages that only build and destructure biperms keep working through the unchanged builder names.
…ple_indexin

Collapses the remaining blocked-tuple interface to direct BiTuple field access plus a small set of plain-tuple helpers. bipartition splits a tuple into its two groups (optionally permuting), biindexin locates two label groups in a collection, and tuple_indexin is the tuple-preserving indexin. Drops trivialbiperm, tupleoneto, blockedperm_indexin, and the BaseExtensions submodule, whose remaining contents were either dead code or folded into tuple_indexin.
…jects

The subproject manifests still pinned 0.10, which fails resolution and CheckCompatBounds now that the package is 0.11.0.
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.80460% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.59%. Comparing base (8175959) to head (5bbd197).

Files with missing lines Patch % Lines
src/bituple.jl 85.71% 3 Missing ⚠️
src/factorizations.jl 89.47% 2 Missing ⚠️
src/matrixfunctions.jl 60.00% 2 Missing ⚠️
src/contract/contract.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
- Coverage   81.56%   78.59%   -2.97%     
==========================================
  Files          27       20       -7     
  Lines         987      654     -333     
==========================================
- Hits          805      514     -291     
+ Misses        182      140      -42     
Flag Coverage Δ
docs 31.07% <58.53%> (+3.01%) ⬆️

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.

The function returns the codomain/domain biperms for a contraction, so the name now matches what it produces, in line with the BiTuple vocabulary. Renames the file to match.
Renames the stale BlockPermutation comment, the biperm helper's blocklength1 argument, and the unmatricize biaxes parameter to the BiTuple group vocabulary.
biperm(t, t1, t2) locates two partitioning groups within t and returns their position tuples (p1, p2), replacing the internal biindexin. Unlike the general indexin it asserts that the groups partition t, checking the lengths add up, so the result is always a valid bipartitioned permutation. The old split-builder biperm(perm, ::Val) folds into the existing BiTuple constructor and bipartition, and biperms returns plain 2-tuples since its results were always split. biperm, bipartition, and BiTuple are now marked public.
BiTuple, biperm, and bipartition are now marked public, so they appear in names(TensorAlgebra) on Julia 1.11+.
mtfishman added a commit to ITensor/SparseArraysBase.jl that referenced this pull request Jun 24, 2026
Adds the in-flight sources pin for TensorAlgebra 0.11 (ITensor/TensorAlgebra.jl#181) so CI can resolve the unregistered version, and bumps the test project TensorAlgebra compat to 0.11 to match the root.
mtfishman and others added 2 commits June 24, 2026 14:11
No downstream package names BiTuple, and biperm and bipartition return plain tuples, so BiTuple drops out of the public declaration and stays an internal implementation detail. Adds a docstring for the public bipartition and tightens its index-group method to take a Tuple, matching the split-by-length method and every caller.
Every contract, factorization, matrix-function, and matricize/unmatricize method that took a bundled BiTuple did nothing but splat its two groups into the method that takes them as separate tuple arguments, so the BiTuple form was a redundant public entry point. Drop those overloads, leaving the labels and two-tuple forms, and rewrite the few internal factorization call sites that built a BiTuple just to feed unmatricize so they pass the two axis tuples directly. BiTuple stays as an internal bundle for the allocation and permutation helpers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mtfishman mtfishman enabled auto-merge (squash) June 24, 2026 20:54
@mtfishman mtfishman merged commit 3b34611 into main Jun 24, 2026
25 of 26 checks passed
@mtfishman mtfishman deleted the mf/v0.11 branch June 24, 2026 21:08
mtfishman added a commit to ITensor/SparseArraysBase.jl that referenced this pull request Jun 24, 2026
## Summary

Requires TensorAlgebra 0.11, where the blocked-permutation types this
extension imported but never used are removed
(ITensor/TensorAlgebra.jl#181).

`SparseArraysBaseTensorAlgebraExt` imported `BlockedTrivialPermutation`
and `BlockedTuple` without using them, so they are dropped from the
import. The extension uses only the core `ReshapeFusion` style and
`matricize` / `unmatricize`, which TensorAlgebra 0.11 keeps unchanged.
mtfishman added a commit to ITensor/ITensorBase.jl that referenced this pull request Jun 24, 2026
## Summary

Moves ITensorBase onto TensorAlgebra 0.11
(ITensor/TensorAlgebra.jl#181) and requires
distinct dimension names when constructing an ITensor.

`matricize_nameddims` resolves its codomain and domain permutations
through `TensorAlgebra.biperm`, the public group-locating helper from
that release, in place of the removed blocked-permutation builders. The
dead partial-fusion branch in `matricize_nameddims`, which only ever
worked when every dimension was assigned to a group, is dropped.

The ITensor inner constructor now collects the dimension names into a
`Vector{DimName}` and requires them to be distinct, throwing otherwise.
Duplicate dimension names leave contraction and matricization ambiguous,
so rejecting them at construction surfaces the problem at the source
rather than deep in a later operation. This behavior change is breaking,
hence the minor bump to 0.8.0.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 24, 2026
…rAlgebra extension (#181)

## Summary

Defines the `BlockReshapeFusion` matricization style directly in
`src/fusion.jl` instead of borrowing it from TensorAlgebra's BlockArrays
extension, which is removed in
ITensor/TensorAlgebra.jl#181.

`src/fusion.jl` now declares `struct BlockReshapeFusion <: FusionStyle`,
where it previously aliased the type the extension exposed. GradedArrays
already owned the graded `matricize` / `unmatricize` /
`tensor_product_axis` methods on this style, so nothing else moves. One
spot that previously destructured a biperm through the extension's
`blocks` bridge now splits the axes with `bipartition`.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
mtfishman added a commit to ITensor/ITensorNetworksNext.jl that referenced this pull request Jun 24, 2026
## Summary

Moves ITensorNetworksNext onto the TensorAlgebra 0.11 stack: bumps the
TensorAlgebra compat bound to 0.11
(ITensor/TensorAlgebra.jl#181) and the
ITensorBase compat bound to 0.8
(ITensor/ITensorBase.jl#184), the release that
moves onto it. ITensorNetworksNext uses none of the removed
blocked-tuple types and constructs no duplicate-named tensors, so no
code changes are needed. This also supersedes
#120, the
CompatHelper bump for ITensorBase.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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