From 9d96a7fc576595157d6ac5af8745a0765d64449f Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Mon, 28 Sep 2026 17:28:04 -0400 Subject: [PATCH 1/4] Bump compat to TensorAlgebra 0.22 and GradedArrays 0.16.6 TensorAlgebra 0.22 removes `MatricizeStyle`, which ITensorBase never used, so this is compat only. Co-Authored-By: Claude Fable 5.1 --- Project.toml | 6 +++--- docs/Project.toml | 2 +- test/Project.toml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 8989a4a..9a97b80 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ITensorBase" uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7" -version = "0.15.0" +version = "0.15.1" authors = ["ITensor developers and contributors"] [workspace] @@ -44,14 +44,14 @@ Adapt = "4.1.1" ArrayLayouts = "1.11" Combinatorics = "1" ConstructionBase = "1.6" -GradedArrays = "0.16.5" +GradedArrays = "0.16.6" LinearAlgebra = "1.10" MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5, 0.6" Mooncake = "0.4.202, 0.5" OMEinsumContractionOrders = "1.3" Random = "1.10" SimpleTraits = "0.9.4" -TensorAlgebra = "0.21.1" +TensorAlgebra = "0.22" TensorKit = "0.17" TensorKitSectors = "0.3.9" TermInterface = "2" diff --git a/docs/Project.toml b/docs/Project.toml index 132948e..453db62 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -16,5 +16,5 @@ ITensorBase = "0.15" ITensorFormatter = "0.2.27" Literate = "2" MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5, 0.6" -TensorAlgebra = "0.21.1" +TensorAlgebra = "0.22" Test = "1.10" diff --git a/test/Project.toml b/test/Project.toml index df91a54..f4a39e2 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -32,7 +32,7 @@ AbstractTrees = "0.4.5" Adapt = "4" Aqua = "0.8.9" Combinatorics = "1" -GradedArrays = "0.16.5" +GradedArrays = "0.16.6" ITensorBase = "0.15" ITensorPkgSkeleton = "0.3.42" JLArrays = "0.2, 0.3" @@ -44,7 +44,7 @@ Random = "1.10" SafeTestsets = "0.1" StableRNGs = "1" Suppressor = "0.2" -TensorAlgebra = "0.21.1" +TensorAlgebra = "0.22" TensorKit = "0.17" TensorKitSectors = "0.3.9" TermInterface = "2" From 42568d180a6db0d84897f1bf711a2629adb1d391 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Mon, 28 Sep 2026 18:58:46 -0400 Subject: [PATCH 2/4] Resolve unmatricize ambiguity with GradedArrays fused matrices GradedArrays 0.16.6 dispatches unmatricize on its fused matrix types, which ties with the named-axes methods here. Restate those in the extension for each fused type. Co-Authored-By: Claude Fable 5.1 --- ext/ITensorBaseGradedArraysExt.jl | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/ext/ITensorBaseGradedArraysExt.jl b/ext/ITensorBaseGradedArraysExt.jl index 008806f..4515332 100644 --- a/ext/ITensorBaseGradedArraysExt.jl +++ b/ext/ITensorBaseGradedArraysExt.jl @@ -1,12 +1,42 @@ module ITensorBaseGradedArraysExt -using GradedArrays: SectorRange +using GradedArrays: FusedGradedDiagonal, FusedGradedMatrix, SectorRange using ITensorBase: ITensorBase, NamedTensor, name, uniquename, unnamed using Random: AbstractRNG, default_rng +using TensorAlgebra: TensorAlgebra as TA using TensorKitSectors: Sector const NamedUnitRange = ITensorBase.NamedUnitRange +# GradedArrays defines `unmatricize` for its fused matrices with untyped axes, which ties with +# ITensorBase's methods on named axes. Restate those for each fused matrix type so the named +# unmatricize of a graded matrix has a unique most-specific method. +for M in (:FusedGradedMatrix, :FusedGradedDiagonal) + @eval begin + function TA.unmatricize( + m::$M, + codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, + domain::Tuple{Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) + end + function TA.unmatricize( + m::$M, + codomain::Tuple{Vararg{NamedUnitRange}}, + domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) + end + function TA.unmatricize( + m::$M, + codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, + domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) + end + end +end + # Flux-canceling constructors at the `Index` level: delegate to the GradedArrays flux backend on # the unnamed axes, then reattach names, so the flux convention lives only in the backend. The # sector may be a bare `TensorKitSectors.Sector` or a `SectorRange`; this is an extension because From d2449859ecdbb7cf953caf02f3982756b6d8b677 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Mon, 28 Sep 2026 19:25:55 -0400 Subject: [PATCH 3/4] Type the matrix in the named unmatricize methods TensorAlgebra 0.22 defines the dense fallback on AbstractMatrix with untyped axes, which tied with the named-axes methods here for a plain matrix. Typing the matrix makes these strictly more specific. Co-Authored-By: Claude Fable 5.1 --- src/tensoralgebra.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tensoralgebra.jl b/src/tensoralgebra.jl index 1380cc7..d40c6c9 100644 --- a/src/tensoralgebra.jl +++ b/src/tensoralgebra.jl @@ -108,23 +108,24 @@ end # Unmatricize an unnamed matrix into the named `codomain`/`domain` axes, giving a named tensor. # `Tuple{Vararg{NamedUnitRange}}` also matches an empty tuple, so demanding at least one named # axis across the two groups takes three methods: one per group, plus the both-nonempty case -# that resolves the ambiguity between them. +# that resolves the ambiguity between them. `m::AbstractMatrix` keeps these more specific than +# TensorAlgebra's `unmatricize(::AbstractMatrix, axes_codomain, axes_domain)`. function TA.unmatricize( - m, + m::AbstractMatrix, codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, domain::Tuple{Vararg{NamedUnitRange}} ) return unmatricize_namedtensor(m, codomain, domain) end function TA.unmatricize( - m, + m::AbstractMatrix, codomain::Tuple{Vararg{NamedUnitRange}}, domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} ) return unmatricize_namedtensor(m, codomain, domain) end function TA.unmatricize( - m, + m::AbstractMatrix, codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} ) From 76a9c0abb2e8d5868f7cfcee90e0127f10245fa7 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Mon, 28 Sep 2026 19:54:42 -0400 Subject: [PATCH 4/4] Named unmatricize for TensorKit tensor maps A TensorMap is not an AbstractMatrix, so the typed named-axes methods miss it and it fell through to the untyped-axes TensorKit method. Restate the named-axes methods for AbstractTensorMap. Co-Authored-By: Claude Fable 5.1 --- ext/ITensorBaseTensorKitExt.jl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ext/ITensorBaseTensorKitExt.jl b/ext/ITensorBaseTensorKitExt.jl index 8f15e6c..04dc5e1 100644 --- a/ext/ITensorBaseTensorKitExt.jl +++ b/ext/ITensorBaseTensorKitExt.jl @@ -1,7 +1,33 @@ module ITensorBaseTensorKitExt using ITensorBase: ITensorBase, NamedUnitRange -using TensorKit: ElementarySpace, dim +using TensorAlgebra: TensorAlgebra as TA +using TensorKit: AbstractTensorMap, ElementarySpace, dim + +# TensorAlgebra's TensorKit extension defines `unmatricize` for `AbstractTensorMap` with untyped +# axes, and a `TensorMap` is not an `AbstractMatrix`, so ITensorBase's named-axes methods do not +# reach it. Restate them for `AbstractTensorMap`. +function TA.unmatricize( + m::AbstractTensorMap, + codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, + domain::Tuple{Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) +end +function TA.unmatricize( + m::AbstractTensorMap, + codomain::Tuple{Vararg{NamedUnitRange}}, + domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) +end +function TA.unmatricize( + m::AbstractTensorMap, + codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}, + domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}} + ) + return ITensorBase.unmatricize_namedtensor(m, codomain, domain) +end # ================================ Index over a native space ============================== # A native TensorKit space is stored directly as the axis value of a `NamedUnitRange`, so