From 90777ee9d39561b0698a6c9ce36fceafc3a8b5a4 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 4 Feb 2026 16:46:19 -0500 Subject: [PATCH 1/5] Upgrade to TensorAlgebra.jl v0.7 --- Project.toml | 4 ++-- test/Project.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 1908d7b2..70fcbc9a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockSparseArrays" uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" authors = ["ITensor developers and contributors"] -version = "0.10.18" +version = "0.10.19" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -41,7 +41,7 @@ MapBroadcast = "0.1.5" MatrixAlgebraKit = "0.6" SparseArraysBase = "0.9" SplitApplyCombine = "1.2.3" -TensorAlgebra = "0.6.2" +TensorAlgebra = "0.6.2, 0.7" TypeParameterAccessors = "0.4.1" julia = "1.10" diff --git a/test/Project.toml b/test/Project.toml index 7c002dae..33feb929 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -40,7 +40,7 @@ SafeTestsets = "0.1" SparseArraysBase = "0.9" StableRNGs = "1" Suppressor = "0.2" -TensorAlgebra = "0.6" +TensorAlgebra = "0.6, 0.7" Test = "1.10" TestExtras = "0.3" TypeParameterAccessors = "0.4" From e2e209e1c45c6ca38c0fa748df7606ba13a6d95f Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 4 Feb 2026 17:10:35 -0500 Subject: [PATCH 2/5] Try fixing tests --- .../BlockSparseArraysTensorAlgebraExt.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl index 3a71e90e..b2e411aa 100644 --- a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl +++ b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl @@ -1,11 +1,13 @@ module BlockSparseArraysTensorAlgebraExt -using BlockArrays: Block, blocklength, blocks, eachblockaxes1 +using BlockArrays: AbstractBlockArray, Block, blocklength, blocks, eachblockaxes1 using BlockSparseArrays: AbstractBlockSparseArray, AbstractBlockSparseMatrix, BlockUnitRange, blockrange, blocksparse using SparseArraysBase: eachstoredindex -using TensorAlgebra: TensorAlgebra, BlockReshapeFusion, BlockedTuple, matricize, - matricize_axes, tensor_product_axis, unmatricize +using TensorAlgebra: TensorAlgebra, BlockedTuple, FusionStyle, matricize, matricize_axes, + tensor_product_axis, unmatricize + +const BlockReshapeFusion = typeof(FusionStyle(AbstractBlockArray)) function TensorAlgebra.tensor_product_axis( style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange From 74c77e66c11573011c70d43b16c7e191a4b36a33 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 4 Feb 2026 17:32:05 -0500 Subject: [PATCH 3/5] Fix tests --- .../BlockSparseArraysTensorAlgebraExt.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl index b2e411aa..e416e012 100644 --- a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl +++ b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl @@ -4,13 +4,21 @@ using BlockArrays: AbstractBlockArray, Block, blocklength, blocks, eachblockaxes using BlockSparseArrays: AbstractBlockSparseArray, AbstractBlockSparseMatrix, BlockUnitRange, blockrange, blocksparse using SparseArraysBase: eachstoredindex -using TensorAlgebra: TensorAlgebra, BlockedTuple, FusionStyle, matricize, matricize_axes, +using TensorAlgebra: TensorAlgebra, BlockedTuple, matricize, matricize_axes, tensor_product_axis, unmatricize -const BlockReshapeFusion = typeof(FusionStyle(AbstractBlockArray)) +# TODO: Ideally we would use: +# ```julia +# const BlockReshapeFusion = typeof(TensorAlgebra.FusionStyle(AbstractBlockArray)) +# ``` +# but that doesn't seem to work, i.e. it sometimes returns `ReshapeFusion`. Maybe it is +# a world age issue, though note that `@invokelatest` doesn't seem to fix it. +# For now we just use `Base.get_extension`. +const BlockReshapeFusion = + Base.get_extension(TensorAlgebra, :TensorAlgebraBlockArraysExt).BlockReshapeFusion function TensorAlgebra.tensor_product_axis( - style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange + style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange, ) return tensor_product_blockrange(style, side, r1, r2) end From 86d64309a2eecc4dd04d2acf4fe478444402502c Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 4 Feb 2026 18:02:22 -0500 Subject: [PATCH 4/5] Try fixing TensorAlgebraExt --- Project.toml | 2 +- .../BlockSparseArraysTensorAlgebraExt.jl | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 70fcbc9a..f85f1539 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,7 @@ TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a" [extensions] -BlockSparseArraysTensorAlgebraExt = "TensorAlgebra" +BlockSparseArraysTensorAlgebraExt = ["TensorAlgebra", "BlockArrays", "SparseArraysBase"] [compat] Adapt = "4.1.1" diff --git a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl index e416e012..04bbc12f 100644 --- a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl +++ b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl @@ -4,18 +4,10 @@ using BlockArrays: AbstractBlockArray, Block, blocklength, blocks, eachblockaxes using BlockSparseArrays: AbstractBlockSparseArray, AbstractBlockSparseMatrix, BlockUnitRange, blockrange, blocksparse using SparseArraysBase: eachstoredindex -using TensorAlgebra: TensorAlgebra, BlockedTuple, matricize, matricize_axes, +using TensorAlgebra: TensorAlgebra, BlockedTuple, FusionStyle, matricize, matricize_axes, tensor_product_axis, unmatricize -# TODO: Ideally we would use: -# ```julia -# const BlockReshapeFusion = typeof(TensorAlgebra.FusionStyle(AbstractBlockArray)) -# ``` -# but that doesn't seem to work, i.e. it sometimes returns `ReshapeFusion`. Maybe it is -# a world age issue, though note that `@invokelatest` doesn't seem to fix it. -# For now we just use `Base.get_extension`. -const BlockReshapeFusion = - Base.get_extension(TensorAlgebra, :TensorAlgebraBlockArraysExt).BlockReshapeFusion +const BlockReshapeFusion = typeof(FusionStyle(AbstractBlockArray)) function TensorAlgebra.tensor_product_axis( style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange, From 60daa933eea8f0c9a1b512f2d61056f853679027 Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Wed, 4 Feb 2026 18:28:16 -0500 Subject: [PATCH 5/5] Apply suggestion from @mtfishman --- .../BlockSparseArraysTensorAlgebraExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl index 04bbc12f..b2e411aa 100644 --- a/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl +++ b/ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl @@ -10,7 +10,7 @@ using TensorAlgebra: TensorAlgebra, BlockedTuple, FusionStyle, matricize, matric const BlockReshapeFusion = typeof(FusionStyle(AbstractBlockArray)) function TensorAlgebra.tensor_product_axis( - style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange, + style::BlockReshapeFusion, side::Val{:codomain}, r1::BlockUnitRange, r2::BlockUnitRange ) return tensor_product_blockrange(style, side, r1, r2) end