From 1d67cad5e7ca09080a52949834c9267797ce05fd Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:33:14 -0500 Subject: [PATCH 01/16] remove factorization struct deprecations --- src/auxiliary/deprecate.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/auxiliary/deprecate.jl b/src/auxiliary/deprecate.jl index 81fbe9a50..1c6c4fb55 100644 --- a/src/auxiliary/deprecate.jl +++ b/src/auxiliary/deprecate.jl @@ -35,24 +35,6 @@ Base.@deprecate EuclideanProduct() EuclideanInnerProduct() Base.@deprecate insertunit(P::ProductSpace, args...; kwargs...) insertleftunit(args...; kwargs...) -# Factorization structs -@deprecate QR() MatrixAlgebraKit.LAPACK_HouseholderQR() -@deprecate QRpos() MatrixAlgebraKit.LAPACK_HouseholderQR(; positive=true) - -@deprecate QL() MatrixAlgebraKit.LAPACK_HouseholderQL() -@deprecate QLpos() MatrixAlgebraKit.LAPACK_HouseholderQL(; positive=true) - -@deprecate LQ() MatrixAlgebraKit.LAPACK_HouseholderLQ() -@deprecate LQpos() MatrixAlgebraKit.LAPACK_HouseholderLQ(; positive=true) - -@deprecate RQ() MatrixAlgebraKit.LAPACK_HouseholderRQ() -@deprecate RQpos() MatrixAlgebraKit.LAPACK_HouseholderRQ(; positive=true) - -@deprecate SDD() MatrixAlgebraKit.LAPACK_DivideAndConquer() -@deprecate SVD() MatrixAlgebraKit.LAPACK_QRIteration() - -@deprecate Polar() MatrixAlgebraKit.PolarViaSVD(MatrixAlgebraKit.LAPACK_DivideAndConquer()) - # truncations const TruncationScheme = MatrixAlgebraKit.TruncationStrategy @deprecate truncdim(d::Int) truncrank(d) From 753ca033457df272574240cd201572e2715f6589 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:33:38 -0500 Subject: [PATCH 02/16] remove truncation deprecations --- src/TensorKit.jl | 1 - src/auxiliary/deprecate.jl | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/TensorKit.jl b/src/TensorKit.jl index 32e7ae577..2269e8f67 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -28,7 +28,6 @@ export FusionTree export IndexSpace, HomSpace, TensorSpace, TensorMapSpace export AbstractTensorMap, AbstractTensor, TensorMap, Tensor # tensors and tensor properties export DiagonalTensorMap, BraidingTensor -export TruncationScheme export SpaceMismatch, SectorMismatch, IndexError # error types # Export general vector space methods diff --git a/src/auxiliary/deprecate.jl b/src/auxiliary/deprecate.jl index 1c6c4fb55..c3c3a0949 100644 --- a/src/auxiliary/deprecate.jl +++ b/src/auxiliary/deprecate.jl @@ -35,12 +35,6 @@ Base.@deprecate EuclideanProduct() EuclideanInnerProduct() Base.@deprecate insertunit(P::ProductSpace, args...; kwargs...) insertleftunit(args...; kwargs...) -# truncations -const TruncationScheme = MatrixAlgebraKit.TruncationStrategy -@deprecate truncdim(d::Int) truncrank(d) -@deprecate truncbelow(ϵ::Real) trunctol(; atol = ϵ) -@deprecate truncerr(ϵ::Real) truncerror(ϵ) - # factorizations # -------------- _kindof(::MatrixAlgebraKit.LAPACK_HouseholderQR) = :qr From 8c976fc6e1e76366588623d3ec0ce7b5e138b080 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:39:42 -0500 Subject: [PATCH 03/16] remove factorization deprecations --- src/auxiliary/deprecate.jl | 138 --------------------------- src/factorizations/factorizations.jl | 4 +- 2 files changed, 2 insertions(+), 140 deletions(-) diff --git a/src/auxiliary/deprecate.jl b/src/auxiliary/deprecate.jl index c3c3a0949..f7f044c38 100644 --- a/src/auxiliary/deprecate.jl +++ b/src/auxiliary/deprecate.jl @@ -35,142 +35,4 @@ Base.@deprecate EuclideanProduct() EuclideanInnerProduct() Base.@deprecate insertunit(P::ProductSpace, args...; kwargs...) insertleftunit(args...; kwargs...) -# factorizations -# -------------- -_kindof(::MatrixAlgebraKit.LAPACK_HouseholderQR) = :qr -_kindof(::MatrixAlgebraKit.LAPACK_HouseholderLQ) = :lq -_kindof(::MatrixAlgebraKit.LAPACK_SVDAlgorithm) = :svd -_kindof(::MatrixAlgebraKit.PolarViaSVD) = :polar -_kindof(::DiagonalAlgorithm) = :svd # shouldn't really matter - -_drop_alg(; alg=nothing, kwargs...) = kwargs -_drop_p(; p=nothing, kwargs...) = kwargs - -function permutedcopy_oftype(t::AbstractTensorMap, T::Type{<:Number}, p::Index2Tuple) - return permute!(similar(t, T, permute(space(t), p)), t, p) -end - -# orthogonalization -export leftorth, leftorth!, rightorth, rightorth! -function leftorth(t::AbstractTensorMap, p::Index2Tuple; kwargs...) - Base.depwarn("`leftorth` is deprecated, use `left_orth` instead", :leftorth) - return leftorth!(permutedcopy_oftype(t, factorisation_scalartype(leftorth, t), p); kwargs...) -end -function rightorth(t::AbstractTensorMap, p::Index2Tuple; kwargs...) - Base.depwarn("`rightorth` is deprecated, use `right_orth` instead", :rightorth) - return rightorth!(permutedcopy_oftype(t, factorisation_scalartype(rightorth, t), p); kwargs...) -end -function leftorth(t::AbstractTensorMap; kwargs...) - Base.depwarn("`leftorth` is deprecated, use `left_orth` instead", :leftorth) - return leftorth!(copy_oftype(t, factorisation_scalartype(leftorth, t)); kwargs...) -end -function rightorth(t::AbstractTensorMap; kwargs...) - Base.depwarn("`rightorth` is deprecated, use `right_orth` instead", :rightorth) - return rightorth!(copy_oftype(t, factorisation_scalartype(rightorth, t)); kwargs...) -end -function leftorth!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`leftorth!` is deprecated, use `left_orth!` instead", :leftorth!) - haskey(kwargs, :alg) || return left_orth!(t; kwargs...) - alg = kwargs[:alg] - kind = _kindof(alg) - kind === :svd && return left_orth!(t; kind, alg_svd=alg, _drop_alg(; kwargs...)...) - kind === :qr && return left_orth!(t; kind, alg_qr=alg, _drop_alg(; kwargs...)...) - kind === :polar && return left_orth!(t; kind, alg_polar=alg, _drop_alg(; kwargs...)...) - throw(ArgumentError("invalid leftorth kind")) -end -function rightorth!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`rightorth!` is deprecated, use `right_orth!` instead", :rightorth!) - haskey(kwargs, :alg) || return right_orth!(t; kwargs...) - alg = kwargs[:alg] - kind = _kindof(alg) - kind === :svd && return right_orth!(t; kind, alg_svd=alg, _drop_alg(; kwargs...)...) - kind === :lq && return right_orth!(t; kind, alg_lq=alg, _drop_alg(; kwargs...)...) - kind === :polar && return right_orth!(t; kind, alg_polar=alg, _drop_alg(; kwargs...)...) - throw(ArgumentError("invalid rightorth kind")) -end - -# nullspaces -export leftnull, leftnull!, rightnull, rightnull! -function leftnull(t::AbstractTensorMap; kwargs...) - Base.depwarn("`leftnull` is deprecated, use `left_null` instead", :leftnull) - return leftnull!(copy_oftype(t, factorisation_scalartype(leftnull, t)); kwargs...) -end -function leftnull(t::AbstractTensorMap, p::Index2Tuple; kwargs...) - Base.depwarn("`leftnull` is deprecated, use `left_null` instead", :leftnull) - return leftnull!(permutedcopy_oftype(t, factorisation_scalartype(leftnull, t), p); kwargs...) -end -function rightnull(t::AbstractTensorMap; kwargs...) - Base.depwarn("`rightnull` is deprecated, use `right_null` instead", :rightnull) - return rightnull!(copy_oftype(t, factorisation_scalartype(rightnull, t)); kwargs...) -end -function rightnull(t::AbstractTensorMap, p::Index2Tuple; kwargs...) - Base.depwarn("`rightnull` is deprecated, use `right_null` instead", :rightnull) - return rightnull!(permutedcopy_oftype(t, factorisation_scalartype(rightnull, t), p); kwargs...) -end -function leftnull!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`leftnull!` is deprecated, use `left_null!` instead", :leftnull!) - haskey(kwargs, :alg) || return left_null!(t; kwargs...) - alg = kwargs[:alg] - kind = _kindof(alg) - kind === :svd && return left_null!(t; kind, alg_svd=alg, _drop_alg(; kwargs...)...) - kind === :qr && return left_null!(t; kind, alg_qr=alg, _drop_alg(; kwargs...)...) - throw(ArgumentError("invalid leftnull kind")) -end -function rightnull!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`rightnull!` is deprecated, use `right_null!` instead", :rightnull!) - haskey(kwargs, :alg) || return right_null!(t; kwargs...) - alg = kwargs[:alg] - kind = _kindof(alg) - kind === :svd && return right_null!(t; kind, alg_svd=alg, _drop_alg(; kwargs...)...) - kind === :lq && return right_null!(t; kind, alg_lq=alg, _drop_alg(; kwargs...)...) - throw(ArgumentError("invalid rightnull kind")) -end - -# eigen values -export eig!, eigh!, eigen, eigen! -@deprecate(eig(t::AbstractTensorMap, p::Index2Tuple; kwargs...), - eig!(permutedcopy_oftype(t, factorisation_scalartype(eig, t), p); kwargs...)) -@deprecate(eigh(t::AbstractTensorMap, p::Index2Tuple; kwargs...), - eigh!(permutedcopy_oftype(t, factorisation_scalartype(eigen, t), p); kwargs...)) -@deprecate(LinearAlgebra.eigen(t::AbstractTensorMap, p::Index2Tuple; kwargs...), - eigen!(permutedcopy_oftype(t, factorisation_scalartype(eigen, t), p); kwargs...), - false) -function eig(t::AbstractTensorMap; kwargs...) - Base.depwarn("`eig` is deprecated, use `eig_full` or `eig_trunc` instead", :eig) - return haskey(kwargs, :trunc) ? eig_trunc(t; kwargs...) : eig_full(t; kwargs...) -end -function eig!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`eig!` is deprecated, use `eig_full!` or `eig_trunc!` instead", :eig!) - return haskey(kwargs, :trunc) ? eig_trunc!(t; kwargs...) : eig_full!(t; kwargs...) -end -function eigh(t::AbstractTensorMap; kwargs...) - Base.depwarn("`eigh` is deprecated, use `eigh_full` or `eigh_trunc` instead", :eigh) - return haskey(kwargs, :trunc) ? eigh_trunc(t; kwargs...) : eigh_full(t; kwargs...) -end -function eigh!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`eigh!` is deprecated, use `eigh_full!` or `eigh_trunc!` instead", :eigh!) - return haskey(kwargs, :trunc) ? eigh_trunc!(t; kwargs...) : eigh_full!(t; kwargs...) -end - -# singular values -export tsvd, tsvd! -@deprecate(tsvd(t::AbstractTensorMap, p::Index2Tuple; kwargs...), - tsvd!(permutedcopy_oftype(t, factorisation_scalartype(tsvd, t), p); kwargs...)) -function tsvd(t::AbstractTensorMap; kwargs...) - Base.depwarn("`tsvd` is deprecated, use `svd_compact`, `svd_full` or `svd_trunc` instead", :tsvd) - if haskey(kwargs, :p) - Base.depwarn("p is a deprecated kwarg, and should be specified through the truncation strategy", :tsvd) - kwargs = _drop_p(; kwargs...) - end - return haskey(kwargs, :trunc) ? svd_trunc(t; kwargs...) : (svd_compact(t; kwargs...)..., abs(zero(scalartype(t)))) -end -function tsvd!(t::AbstractTensorMap; kwargs...) - Base.depwarn("`tsvd!` is deprecated, use `svd_compact!`, `svd_full!` or `svd_trunc!` instead", :tsvd!) - if haskey(kwargs, :p) - Base.depwarn("p is a deprecated kwarg, and should be specified through the truncation strategy", :tsvd!) - kwargs = _drop_p(; kwargs...) - end - return haskey(kwargs, :trunc) ? svd_trunc!(t; kwargs...) : svd_compact!(t; kwargs...) -end - #! format: on diff --git a/src/factorizations/factorizations.jl b/src/factorizations/factorizations.jl index 44d7e2315..dce2067ee 100644 --- a/src/factorizations/factorizations.jl +++ b/src/factorizations/factorizations.jl @@ -41,13 +41,13 @@ function LinearAlgebra.eigen!(t::AbstractTensorMap; kwargs...) end function LinearAlgebra.eigvals(t::AbstractTensorMap; kwargs...) - tcopy = copy_oftype(t, factorisation_scalartype(eigen, t)) + tcopy = copy_oftype(t, factorisation_scalartype(LinearAlgebra.eigen, t)) return LinearAlgebra.eigvals!(tcopy; kwargs...) end LinearAlgebra.eigvals!(t::AbstractTensorMap; kwargs...) = diagview(eig_vals!(t)) function LinearAlgebra.svdvals(t::AbstractTensorMap) - tcopy = copy_oftype(t, factorisation_scalartype(tsvd, t)) + tcopy = copy_oftype(t, factorisation_scalartype(svd_vals!, t)) return LinearAlgebra.svdvals!(tcopy) end LinearAlgebra.svdvals!(t::AbstractTensorMap) = diagview(svd_vals!(t)) From 9da0aa9f1c56e6e189700efa53dd93a2d7420de3 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:41:35 -0500 Subject: [PATCH 04/16] remove deprecate.jl file --- src/TensorKit.jl | 3 --- src/auxiliary/deprecate.jl | 38 -------------------------------------- 2 files changed, 41 deletions(-) delete mode 100644 src/auxiliary/deprecate.jl diff --git a/src/TensorKit.jl b/src/TensorKit.jl index 2269e8f67..f99d55b6e 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -247,9 +247,6 @@ include("planar/macros.jl") @specialize include("planar/planaroperations.jl") -# deprecations: to be removed in version 1.0 or sooner -include("auxiliary/deprecate.jl") - # Extensions # ---------- function __init__() diff --git a/src/auxiliary/deprecate.jl b/src/auxiliary/deprecate.jl deleted file mode 100644 index f7f044c38..000000000 --- a/src/auxiliary/deprecate.jl +++ /dev/null @@ -1,38 +0,0 @@ -import Base: transpose - -#! format: off - -for f in (:rand, :randn, :zeros, :ones) - @eval begin - Base.@deprecate TensorMap(::typeof($f), T::Type, P::HomSpace) $f(T, P) - Base.@deprecate TensorMap(::typeof($f), P::HomSpace) $f(P) - Base.@deprecate TensorMap(::typeof($f), T::Type, cod::TensorSpace, dom::TensorSpace) $f(T, cod, dom) - Base.@deprecate TensorMap(::typeof($f), cod::TensorSpace, dom::TensorSpace) $f(cod, dom) - Base.@deprecate Tensor(::typeof($f), T::Type, space::TensorSpace) $f(T, space) - Base.@deprecate Tensor(::typeof($f), space::TensorSpace) $f(space) - end -end - -Base.@deprecate(randuniform(dims::Base.Dims), rand(dims)) -Base.@deprecate(randuniform(T::Type{<:Number}, dims::Base.Dims), rand(T, dims)) -Base.@deprecate(randnormal(dims::Base.Dims), randn(dims)) -Base.@deprecate(randnormal(T::Type{<:Number}, dims::Base.Dims), randn(T, dims)) -Base.@deprecate(randhaar(dims::Base.Dims), randisometry(dims)) -Base.@deprecate(randhaar(T::Type{<:Number}, dims::Base.Dims), randisometry(T, dims)) - -for (f1, f2) in ((:randuniform, :rand), (:randnormal, :randn), (:randisometry, :randisometry), (:randhaar, :randisometry)) - @eval begin - Base.@deprecate TensorMap(::typeof($f1), T::Type, P::HomSpace) $f2(T, P) - Base.@deprecate TensorMap(::typeof($f1), P::HomSpace) $f2(P) - Base.@deprecate TensorMap(::typeof($f1), T::Type, cod::TensorSpace, dom::TensorSpace) $f2(T, P, cod, dom) - Base.@deprecate TensorMap(::typeof($f1), cod::TensorSpace, dom::TensorSpace) $f2(cod, dom) - Base.@deprecate Tensor(::typeof($f1), T::Type, space::TensorSpace) $f2(T, space) - Base.@deprecate Tensor(::typeof($f1), space::TensorSpace) $f2(space) - end -end - -Base.@deprecate EuclideanProduct() EuclideanInnerProduct() - -Base.@deprecate insertunit(P::ProductSpace, args...; kwargs...) insertleftunit(args...; kwargs...) - -#! format: on From aab1d348885edf8851811295a8281940d1811f60 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:42:04 -0500 Subject: [PATCH 05/16] bump v0.16 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5f3ffb4f2..a32ae8c10 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TensorKit" uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec" authors = ["Jutho Haegeman"] -version = "0.15.3" +version = "0.16.0" [deps] LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637" From ed93ce5372175f140719b9f04e0c00313d47c865 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:42:09 -0500 Subject: [PATCH 06/16] Add author --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a32ae8c10..94dd5fce8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "TensorKit" uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec" -authors = ["Jutho Haegeman"] +authors = ["Jutho Haegeman, Lukas Devos"] version = "0.16.0" [deps] From 7cc1596307f819269953e78fdfa91c4339fddfd6 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:43:19 -0500 Subject: [PATCH 07/16] remove PackageExtensionCompat --- Project.toml | 2 -- src/TensorKit.jl | 8 -------- 2 files changed, 10 deletions(-) diff --git a/Project.toml b/Project.toml index 94dd5fce8..6c22acc60 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,6 @@ LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4" OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5" -PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63" @@ -37,7 +36,6 @@ LRUCache = "1.0.2" LinearAlgebra = "1" MatrixAlgebraKit = "0.6.0" OhMyThreads = "0.8.0" -PackageExtensionCompat = "1" Printf = "1" Random = "1" SafeTestsets = "0.1" diff --git a/src/TensorKit.jl b/src/TensorKit.jl index f99d55b6e..0a2b70835 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -147,8 +147,6 @@ import Base.Meta using Random: Random, rand!, randn! -using PackageExtensionCompat - # Auxiliary files #----------------- include("auxiliary/auxiliary.jl") @@ -247,10 +245,4 @@ include("planar/macros.jl") @specialize include("planar/planaroperations.jl") -# Extensions -# ---------- -function __init__() - return @require_extensions -end - end From 5be3cb8b2801cc5c04285f8a9ab199e1c64f5119 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:52:44 -0500 Subject: [PATCH 08/16] remove empty file --- ext/TensorKitChainRulesCoreExt/factorizations.jl | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 ext/TensorKitChainRulesCoreExt/factorizations.jl diff --git a/ext/TensorKitChainRulesCoreExt/factorizations.jl b/ext/TensorKitChainRulesCoreExt/factorizations.jl deleted file mode 100644 index a104f408a..000000000 --- a/ext/TensorKitChainRulesCoreExt/factorizations.jl +++ /dev/null @@ -1,2 +0,0 @@ -# Factorizations rules -# -------------------- From 35ca3ebf54e5299af930126b9806c65e83a68773 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 1 Dec 2025 11:53:50 -0500 Subject: [PATCH 09/16] remove unused chainrule --- ext/TensorKitChainRulesCoreExt/constructors.jl | 12 ------------ test/autodiff/ad.jl | 2 -- 2 files changed, 14 deletions(-) diff --git a/ext/TensorKitChainRulesCoreExt/constructors.jl b/ext/TensorKitChainRulesCoreExt/constructors.jl index 100c255d2..81cd2dbe9 100644 --- a/ext/TensorKitChainRulesCoreExt/constructors.jl +++ b/ext/TensorKitChainRulesCoreExt/constructors.jl @@ -106,18 +106,6 @@ function ChainRulesCore.rrule( return TensorKit.copy_oftype(t, T), copy_oftype_pullback end -function ChainRulesCore.rrule( - ::typeof(TensorKit.permutedcopy_oftype), t::AbstractTensorMap, T::Type{<:Number}, p::Index2Tuple - ) - project = ProjectTo(t) - function permutedcopy_oftype_pullback(Δt) - invp = TensorKit._canonicalize(TupleTools.invperm(linearize(p)), t) - return NoTangent(), project(TensorKit.permute(unthunk(Δt), invp)), NoTangent(), - NoTangent() - end - return TensorKit.permutedcopy_oftype(t, T, p), permutedcopy_oftype_pullback -end - function ChainRulesCore.rrule(::typeof(Base.convert), T::Type{<:Array}, t::AbstractTensorMap) A = convert(T, t) function convert_pullback(ΔA) diff --git a/test/autodiff/ad.jl b/test/autodiff/ad.jl index 53f007b21..557cca3cb 100644 --- a/test/autodiff/ad.jl +++ b/test/autodiff/ad.jl @@ -220,8 +220,6 @@ for V in spacelist test_rrule(copy, T2) test_rrule(TensorKit.copy_oftype, T1, ComplexF64) if symmetricbraiding - test_rrule(TensorKit.permutedcopy_oftype, T1, ComplexF64, ((3, 1), (2, 4))) - test_rrule(convert, Array, T1) test_rrule( TensorMap, convert(Array, T1), codomain(T1), domain(T1); From 186a3752935bb35fb4f15eade0af20462826d7d3 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Tue, 2 Dec 2025 09:01:31 -0500 Subject: [PATCH 10/16] re-export `eigen(!)` again --- src/TensorKit.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TensorKit.jl b/src/TensorKit.jl index 0a2b70835..580052ec7 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -83,6 +83,7 @@ export left_orth, right_orth, left_null, right_null, exp, exp!, eigh_full!, eigh_full, eigh_trunc!, eigh_trunc, eigh_vals!, eigh_vals, eig_full!, eig_full, eig_trunc!, eig_trunc, eig_vals!, eig_vals, + eigen, eigen!, ishermitian, project_hermitian, project_hermitian!, isantihermitian, project_antihermitian, project_antihermitian!, isisometric, isunitary, project_isometric, project_isometric!, From be629767bf5461c45caf262309e238295d65b706 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Wed, 3 Dec 2025 10:24:18 -0500 Subject: [PATCH 11/16] Update Changelog and add to the docs --- Changelog.md | 122 ----------------------------------- docs/make.jl | 1 + docs/src/Changelog.md | 146 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 122 deletions(-) delete mode 100644 Changelog.md create mode 100644 docs/src/Changelog.md diff --git a/Changelog.md b/Changelog.md deleted file mode 100644 index 52d0d5873..000000000 --- a/Changelog.md +++ /dev/null @@ -1,122 +0,0 @@ -# Planned changes for v1.0 - -Features that are planned to be implemented before the release of v1.0.0, in no particular order. - -- [x] Separate `Sectors` module -- [x] Make `TrivialTensorMap` and `TensorMap` be the same -- [x] Simplify `TensorMap` type to hide `rowr` and `colr` -- [x] Change block order in `rowr` / `colr` to speed up particular contractions -- [x] Make `AdjointTensorMap` generic -- [ ] Rewrite planar operations in order to be AD-compatible -- [x] Fix rrules for fermionic tensors -- [ ] Fix GPU support -- [ ] Proper threading support -- [ ] Rewrite documentation - -# Changelog - -## v0.15 - -### MatrixAlgebraKit backend for factorizations - -This version introduces [MatrixAlgebraKit](https://github.com/QuantumKitHub/MatrixAlgebraKit.jl) as the new backend for tensor factorizations, replacing the previous internal `TensorKit.MatrixAlgebra` implementation. See [#230](https://github.com/QuantumKitHub/TensorKit.jl/pull/230) for details. - -#### Added -- `foreachblock(f, t::AbstractTensorMap...)` - uniform interface to iterate through tensor blocks (prepares for future multithreading support) -- `eig_trunc` and `eigh_trunc` - truncated eigenvalue decompositions -- `ominus` (and unicode `⊖`) - compute orthogonal complement of a space -- Backend selection for factorizations - swap algorithms or implementations - -#### Changed -- Factorization functions `leftorth`, `rightorth`, `tsvd`, `eig`, `eigh` deprecated in favor of MatrixAlgebraKit variants (`left_orth`, `right_orth`, `svd_compact`, `eig_full`, `eigh_full`) -- Truncation strategies now use MatrixAlgebraKit names: `truncrank` (replaces `truncdim`) and `trunctol` (replaces `truncbelow`) -- `left_orth` and `right_orth` now always output tensors with a single connecting space -- `left_orth` and `right_orth` now always have connecting space with `isdual=false` -- code formatter is now [Runic.jl](https://github.com/fredrikekre/Runic.jl) - -#### Removed -- `OrthogonalFactorization` structs (constructors deprecated to return equivalent MatrixAlgebraKit algorithm structs) -- Direct permute-and-factorize operations (incompatible with `permute` vs `braid` distinction) -- `Polar` decomposition behavior for `left_orth`/`right_orth` (use `left_polar`/`right_polar` instead for `isposdef` R factors) - -## v0.14 - -### Use `DiagonalTensorMap` for singular values and eigenvalues - -The diagonal (1,1) tensor that contains the singular values or eigenvalues of a tensor -are now explicitly represented as `DiagonalTensorMap` instances. - -### New index functionality -There are is new functionality for manipulating the spaces associated with a tensor: -* `flip(t, i)` changes the duality flag of the `i`th index of `t`, in such a way that flipping - a pair of contracted indices in an `@tensor` contraction does not affect the result. -* `insertleftunit(t, i)` and `insertrightunit(t, i)` insert a trivial unit space to the left - or to right of index `i`, whereas `removeunit(t, i)` removes such a trivial unit space. - -### SVD truncation change (breaking) -There is a subtle but breaking change in the truncation mechanism in SVD, where now it is -guaranteed that smaller singular values are removed first, irrespective of the (quantum) -dimension of the sector to which they belong - -### `DiagonalTensorMap` and `reduceddim` - -This adds a `DiagonalTensorMap` type for representing tensor maps in which all of the -blocks are diagonal. This only makes sense for maps between a single index in the domain and -the codomain (which are furthermore required to be the same), as otherwise the fusion and -splitting trees from the domain and codomain to the blocked sectors would itself be -nondiagonal. This new type will be used to capture the singular values and eigenvalues as -tensor maps in the corresponding decompositions. The number of free parameters in a -`DiagonalTensorMap` instance on vector space `V` is equal to `reduceddim(V)`, a new function -that sums up the degeneracy dimension `dim(V, c)` for each of the sectors `c` in `V`. This -function can be useful by itself and is also exported from the `TensorKit` module. An -instance of `DiagonalTensorMap` can then be created as `DiagonalTensorMap(data, V)` where -`data` is a vector of length `reduceddim(V)`. - -## v0.13 - -### `AbstractTensorMap{E,S,N₁,N₂}` - -This adds the scalar type as a parameter to the `AbstractTensorMap` type. This is useful in -the contexts where different types of tensors are used (`AdjointTensor`, `BraidingTensor`, -...), which still have the same scalartype. Additionally, this removes many specializations -for methods in order to reduce ambiguity errors. - -### `copy(BraidingTensor)` - -This PR changes the behaviour of `copy` as an instantiator for creating a `TensorMap` from a -`BraidingTensor`. The rationale is that while this does sometimes happen in Julia `Base`, -this is always in the context of lazy wrapper types, for which it makes sense to not copy -the parent and then create a new wrapper. `BraidingTensor` does not wrap anything, so this -definition makes less sense. - -### Refactor tensormap constructors - -This PR refactors the constructors for `TensorMap` to be more in line with `Array` -constructors in Julia. In particular, this means that the default way to create -uninitialized tensors is now `TensorMap{E}(undef, codomain ← domain)`, reminiscent of -`Array{E}(undef, dims)`. Several convenience constructors are also added: `ones`, `zeros`, -`rand` and `randn` construct tensors when `dims` is replaced by `domain ← codomain`. - -### TensorOperations v5 - -This PR bumps the compatibility of `TensorOperations` to v5. This is a breaking change -as there are some changes in the API. - -### TensorKitSectors - -This promotes TensorKitSectors to its own package, in order to make the dependencies -lighter and to separate the concerns of the two packages. - -### FusionTree vertices - -In order to simplify the `FusionTree` struct, we removed the usage of anything other than -`Int` as a vertex-label when working with `GenericFusion` sectors. - -### TensorStructure - -This PR changed the data structure of `TensorMap` to consist of a single vector of data, -where all blocks and subblocks are various views into this object. This entails major -simplifications for the outwards-facing interface, as now the `TensorMap` type requires less -parameters, and the fusion-tree structure is more clearly considered as an implementation -detail that can be left hidden to the user. Various other improvements and documentation -work was also carried out. diff --git a/docs/make.jl b/docs/make.jl index e6be96992..3fffae9eb 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -22,6 +22,7 @@ pages = [ ], "Index" => ["index/index.md"], "Appendix" => ["appendix/symmetric_tutorial.md", "appendix/categories.md"], + "Changelog" => "Changelog.md", ] mathengine = MathJax3( diff --git a/docs/src/Changelog.md b/docs/src/Changelog.md new file mode 100644 index 000000000..df9350954 --- /dev/null +++ b/docs/src/Changelog.md @@ -0,0 +1,146 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Guidelines for updating this changelog + +When making changes to this project, please update the "Unreleased" section with your changes under the appropriate category: + +- **Added** for new features. +- **Changed** for changes in existing functionality. +- **Deprecated** for soon-to-be removed features. +- **Removed** for now removed features. +- **Fixed** for any bug fixes. +- **Performance** for performance improvements. + +When releasing a new version, move the "Unreleased" changes to a new version section with the release date. + +## [Unreleased](https://github.com/QuantumKitHub/TensorKit.jl/compare/v0.16.0...HEAD) + +## [0.16.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.16.0) - 2025-12-03 + +### Added + +- `rrule` for `transpose` operation ([#319](https://github.com/QuantumKitHub/TensorKit.jl/pull/319)) +- New functions for multifusion support: `unitspace`, `zerospace`, `leftunitspace`, `rightunitspace`, `isunitspace` ([#291](https://github.com/QuantumKitHub/TensorKit.jl/pull/291)) +- Support for projections and orthogonal complements ([#312](https://github.com/QuantumKitHub/TensorKit.jl/pull/312)) + +### Changed + +- Tensors now no longer print their data by default, only their spaces. Use `blocks(t)` or `subblocks(t)` to inspect data ([#304](https://github.com/QuantumKitHub/TensorKit.jl/pull/304)) +- Updated `left_orth`, `right_orth`, `left_null` and `right_null` interfaces for MatrixAlgebraKit v0.6 ([#312](https://github.com/QuantumKitHub/TensorKit.jl/pull/312)) +- Updated `ishermitian` and `isisometric` implementations ([#312](https://github.com/QuantumKitHub/TensorKit.jl/pull/312)) +- Sector functions now by default use `unit` instead of `one`, `isunit` instead of `isone`, and `dual` instead of `conj` ([#291](https://github.com/QuantumKitHub/TensorKit.jl/pull/291)) +- Reworked TensorOperations implementation to use backend and allocator system ([#311](https://github.com/QuantumKitHub/TensorKit.jl/pull/311)) +- Major documentation update/overhaul ([#289](https://github.com/QuantumKitHub/TensorKit.jl/pull/289)) +- Added symmetric tensor tutorial as appendix ([#316](https://github.com/QuantumKitHub/TensorKit.jl/pull/316)) +- Improved error messages throughout codebase ([#309](https://github.com/QuantumKitHub/TensorKit.jl/pull/309)) + +### Deprecated + +### Removed + +- All deprecations from v0.15: old factorization function names (`leftorth`, `rightorth`, `tsvd`, `eig`, `eigh`) +- Old truncation strategy names (`truncdim`, `truncbelow`) +- Old factorization struct types (`OrthogonalFactorization`) +- Old constructor syntaxes and deprecated `rand*` function names + +### Fixed + +- Avoid unnecessary copy in `twist` for tensors with bosonic braiding ([#305](https://github.com/QuantumKitHub/TensorKit.jl/pull/305)) +- Small fixes and typos ([#295](https://github.com/QuantumKitHub/TensorKit.jl/pull/295)) + +## [0.15.3](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.15.3) - 2025-10-30 + +### Fixed + +- Fixed typo in `show(::GradedSpace)` ([#308](https://github.com/QuantumKitHub/TensorKit.jl/pull/308)) +- Updated printing of `ProductSpace{<:Any,0}` +- Added tests for show methods + +## [0.15.2](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.15.2) - 2025-10-28 + +### Added + +- `subblocks` iterator for easier inspection of tensor data ([#304](https://github.com/QuantumKitHub/TensorKit.jl/pull/304)) + +### Changed + +- Tensors no longer print their data by default, only their spaces. Use `blocks(t)` or `subblocks(t)` to inspect data ([#304](https://github.com/QuantumKitHub/TensorKit.jl/pull/304)) +- Updated compatibility to TensorKitSectors v0.3 ([#290](https://github.com/QuantumKitHub/TensorKit.jl/pull/290)) +- Refactored test suite and split into groups ([#298](https://github.com/QuantumKitHub/TensorKit.jl/pull/298)) + +### Fixed + +- Fixed `TruncationIntersection` implementation and test ([#300](https://github.com/QuantumKitHub/TensorKit.jl/pull/300)) +- Avoided unnecessary allocations in rrules for contractions and tensor products ([#306](https://github.com/QuantumKitHub/TensorKit.jl/pull/306)) + +## [0.15.1](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.15.1) - 2025-10-09 + +### Fixed + +- Small fixes and typo corrections ([#295](https://github.com/QuantumKitHub/TensorKit.jl/pull/295)) + +## [0.15.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.15.0) - 2025-10-03 + +### Added + +- [MatrixAlgebraKit](https://github.com/QuantumKitHub/MatrixAlgebraKit.jl) as new backend for tensor factorizations ([#230](https://github.com/QuantumKitHub/TensorKit.jl/pull/230)) +- `foreachblock(f, t::AbstractTensorMap...)` - uniform interface to iterate through tensor blocks +- `eig_trunc` and `eigh_trunc` - truncated eigenvalue decompositions +- `ominus` (and unicode `⊖`) - compute orthogonal complement of a space +- Backend selection for factorizations - swap algorithms or implementations + +### Changed + +- `left_orth` and `right_orth` now always output tensors with a single connecting space +- `left_orth` and `right_orth` now always have connecting space with `isdual=false` +- Code formatter is now [Runic.jl](https://github.com/fredrikekre/Runic.jl) + +### Deprecated + +- Factorization functions `leftorth`, `rightorth`, `tsvd`, `eig`, `eigh` in favor of MatrixAlgebraKit variants (`left_orth`, `right_orth`, `svd_compact`, `eig_full`, `eigh_full`) +- Truncation strategies: `truncdim` (use `truncrank`) and `truncbelow` (use `trunctol`) +- `OrthogonalFactorization` structs (constructors deprecated to return equivalent MatrixAlgebraKit algorithm structs) + +### Removed + +- Direct permute-and-factorize operations (incompatible with `permute` vs `braid` distinction) +- `Polar` decomposition behavior for `left_orth`/`right_orth` (use `left_polar`/`right_polar` instead for `isposdef` R factors) + +## [0.14.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.14.0) - 2024-12-19 + +### Added + +- `DiagonalTensorMap` type for representing tensor maps with diagonal blocks +- `reduceddim(V)` function that sums up degeneracy dimensions for each sector +- New index manipulation functions: + - `flip(t, i)` + - `insertleftunit(t, i)` + - `insertrightunit(t, i)` + - `removeunit(t, i)` + +### Changed + +- Singular values and eigenvalues now explicitly represented as `DiagonalTensorMap` instances +- SVD truncation now guarantees smaller singular values are removed first, irrespective of sector quantum dimension + +## [0.13.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.13.0) - 2024-11-24 + +### Added + +- Refactored `TensorMap` constructors to align with Julia `Array` constructors +- Convenience constructors: `ones`, `zeros`, `rand`, `randn` for tensors +- TensorOperations v5 support + +### Changed + +- Scalar type as parameter to `AbstractTensorMap` type: `AbstractTensorMap{E, S, N₁, N₂}` +- Default way to create uninitialized tensors is now `TensorMap{E}(undef, codomain ← domain)` +- Behavior of `copy` for `BraidingTensor` to properly instantiate a `TensorMap` +- TensorKitSectors promoted to separate package +- `TensorMap` data structure now consists of single vector with blocks as views +- `FusionTree` vertices now only use `Int` labels for `GenericFusion` sectors From abfa999b37420afd6a07b381347f6c15a8b4c413 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Wed, 3 Dec 2025 13:10:39 -0500 Subject: [PATCH 12/16] attempt to stabilize some AD tests --- test/autodiff/ad.jl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/autodiff/ad.jl b/test/autodiff/ad.jl index 557cca3cb..2d50c2a2b 100644 --- a/test/autodiff/ad.jl +++ b/test/autodiff/ad.jl @@ -303,22 +303,26 @@ for V in spacelist end @timedtestset "Linear Algebra part II with scalartype $T" for T in eltypes + atol = precision(T) + rtol = precision(T) for i in 1:3 E = randn(T, ⊗(V[1:i]...) ← ⊗(V[1:i]...)) - test_rrule(LinearAlgebra.tr, E) - test_rrule(exp, E; check_inferred = false) - test_rrule(inv, E) + test_rrule(LinearAlgebra.tr, E; atol, rtol) + test_rrule(exp, E; check_inferred = false, atol, rtol) + test_rrule(inv, E; atol, rtol) end A = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]) - test_rrule(LinearAlgebra.adjoint, A) - test_rrule(LinearAlgebra.norm, A, 2) + test_rrule(LinearAlgebra.adjoint, A; atol, rtol) + test_rrule(LinearAlgebra.norm, A, 2; atol, rtol) B = randn(T, space(A)) - test_rrule(LinearAlgebra.dot, A, B) + test_rrule(LinearAlgebra.dot, A, B; atol, rtol) end @timedtestset "Matrix functions ($T)" for T in eltypes + atol = precision(T) + rtol = precision(T) for f in (sqrt, exp) check_inferred = false # !(T <: Real) # not type-stable for real functions t1 = randn(T, V[1] ← V[1]) @@ -340,9 +344,9 @@ for V in spacelist randn!(d3.data) end - test_rrule(f, t1; rrule_f = Zygote.rrule_via_ad, check_inferred) - test_rrule(f, t2; rrule_f = Zygote.rrule_via_ad, check_inferred) - test_rrule(f, d ⊢ d2; check_inferred, output_tangent = d3) + test_rrule(f, t1; rrule_f = Zygote.rrule_via_ad, check_inferred, atol, rtol) + test_rrule(f, t2; rrule_f = Zygote.rrule_via_ad, check_inferred, atol, rtol) + test_rrule(f, d ⊢ d2; check_inferred, output_tangent = d3, atol, rtol) end end From b4a88cc85060cd7028ac7946f00cf62bc6a774e3 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Wed, 3 Dec 2025 15:37:29 -0500 Subject: [PATCH 13/16] update CITATION file --- CITATION.cff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CITATION.cff b/CITATION.cff index 8eb3682f4..f4b1a5724 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -8,7 +8,7 @@ authors: given-names: "Jutho" orcid: "https://orcid.org/0000-0002-0858-291X" title: "TensorKit.jl" -version: "0.15.0" +version: "0.16.0" doi: "10.5281/zenodo.8421339" date-released: "2025-10-03" url: "https://github.com/QuantumKitHub/TensorKit.jl" From d0200c63f7a23452c0117572c66fb94f6f515179 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Wed, 3 Dec 2025 15:39:51 -0500 Subject: [PATCH 14/16] further relax tests --- test/autodiff/ad.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autodiff/ad.jl b/test/autodiff/ad.jl index 2d50c2a2b..c73c23a26 100644 --- a/test/autodiff/ad.jl +++ b/test/autodiff/ad.jl @@ -61,7 +61,7 @@ end # Float32 and finite differences don't mix well precision(::Type{<:Union{Float32, Complex{Float32}}}) = 1.0e-2 -precision(::Type{<:Union{Float64, Complex{Float64}}}) = 1.0e-6 +precision(::Type{<:Union{Float64, Complex{Float64}}}) = 1.0e-5 function randindextuple(N::Int, k::Int = rand(0:N)) @assert 0 ≤ k ≤ N From 2f9403e35c6d0e4f5252ccb39134fad097cb8aa9 Mon Sep 17 00:00:00 2001 From: Jutho Haegeman Date: Thu, 4 Dec 2025 21:53:11 +0100 Subject: [PATCH 15/16] change seed --- test/autodiff/ad.jl | 2 +- test/setup.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/autodiff/ad.jl b/test/autodiff/ad.jl index c73c23a26..0625ee46c 100644 --- a/test/autodiff/ad.jl +++ b/test/autodiff/ad.jl @@ -133,7 +133,7 @@ function remove_eighgauge_dependence!( abs(Dc[i] - Dc[j]) >= degeneracy_atol && (b[i, j] = 0) end end - mul!(ΔV, V / (V' * V), gaugepart, -1, 1) + mul!(ΔV, V, gaugepart, -1, 1) return ΔV end function remove_svdgauge_dependence!( diff --git a/test/setup.jl b/test/setup.jl index 719f3ad36..6cde01d28 100644 --- a/test/setup.jl +++ b/test/setup.jl @@ -10,7 +10,7 @@ using TensorKit using TensorKit: ℙ, PlanarTrivial using Base.Iterators: take, product -Random.seed!(1234) +Random.seed!(123456) smallset(::Type{I}) where {I <: Sector} = take(values(I), 5) function smallset(::Type{ProductSector{Tuple{I1, I2}}}) where {I1, I2} From 2c44fbc9e1ebcbb04005c13be23467dce87ca9c9 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Thu, 4 Dec 2025 21:09:24 -0500 Subject: [PATCH 16/16] update dates --- CITATION.cff | 2 +- docs/src/Changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index f4b1a5724..9b2157f3e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -10,7 +10,7 @@ authors: title: "TensorKit.jl" version: "0.16.0" doi: "10.5281/zenodo.8421339" -date-released: "2025-10-03" +date-released: "2025-12-05" url: "https://github.com/QuantumKitHub/TensorKit.jl" preferred-citation: type: article diff --git a/docs/src/Changelog.md b/docs/src/Changelog.md index df9350954..d33f34e39 100644 --- a/docs/src/Changelog.md +++ b/docs/src/Changelog.md @@ -20,7 +20,7 @@ When releasing a new version, move the "Unreleased" changes to a new version sec ## [Unreleased](https://github.com/QuantumKitHub/TensorKit.jl/compare/v0.16.0...HEAD) -## [0.16.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.16.0) - 2025-12-03 +## [0.16.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.16.0) - 2025-12-05 ### Added