From 319e96f56eb72bffb74ad3c202e8be107139e0cd Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Thu, 23 Apr 2026 14:39:32 -0400 Subject: [PATCH 1/2] Remove EinExprs dependency Delete the ITensorNetworksEinExprsExt extension and its tests. The `alg = "einexpr"` contraction sequence optimizer is no longer supported; use `alg = "optimal"`, `"greedy"`, `"tree_sa"`, `"sa_bipartite"`, or `"kahypar_bipartite"` via OMEinsumContractionOrders instead. Co-Authored-By: Claude Opus 4.7 (1M context) --- Project.toml | 5 +- .../ITensorNetworksEinExprsExt.jl | 53 ------------------- test/Project.toml | 2 - test/test_contraction_sequence.jl | 14 ----- 4 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 ext/ITensorNetworksEinExprsExt/ITensorNetworksEinExprsExt.jl diff --git a/Project.toml b/Project.toml index 6a3e077b..b067c254 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ITensorNetworks" uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7" -version = "0.15.26" +version = "0.15.27" authors = ["Matthew Fishman , Joseph Tindall and contributors"] [workspace] @@ -39,14 +39,12 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" [weakdeps] -EinExprs = "b1794770-133b-4de1-afb4-526377e9f4c5" GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889" OMEinsumContractionOrders = "6f22d1fd-8eed-4bb7-9776-e7d684900715" Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" [extensions] -ITensorNetworksEinExprsExt = "EinExprs" ITensorNetworksGraphsFlowsExt = "GraphsFlows" ITensorNetworksOMEinsumContractionOrdersExt = "OMEinsumContractionOrders" ITensorNetworksObserversExt = "Observers" @@ -64,7 +62,6 @@ DataStructures = "0.18, 0.19" Dictionaries = "0.4" Distributions = "0.25.86" DocStringExtensions = "0.9" -EinExprs = "0.6.4, 0.7" Graphs = "1.8" GraphsFlows = "0.1.1" ITensors = "0.7, 0.8, 0.9" diff --git a/ext/ITensorNetworksEinExprsExt/ITensorNetworksEinExprsExt.jl b/ext/ITensorNetworksEinExprsExt/ITensorNetworksEinExprsExt.jl deleted file mode 100644 index 726433da..00000000 --- a/ext/ITensorNetworksEinExprsExt/ITensorNetworksEinExprsExt.jl +++ /dev/null @@ -1,53 +0,0 @@ -module ITensorNetworksEinExprsExt - -using EinExprs: EinExprs, EinExpr, SizedEinExpr, einexpr -using ITensorNetworks: ITensorNetworks, ITensorList, ITensorNetwork, contraction_sequence, - vertex_data, vertextype -using ITensors: @Algorithm_str, ITensor, Index, inds, noncommoninds - -function to_einexpr(ts::ITensorList) - IndexType = Any - - tensor_exprs = EinExpr{IndexType}[] - inds_dims = Dict{IndexType, Int}() - - for tensor_v in ts - inds_v = collect(inds(tensor_v)) - push!(tensor_exprs, EinExpr{IndexType}(; head = inds_v)) - merge!(inds_dims, Dict(inds_v .=> size(tensor_v))) - end - - externalinds_tn = reduce(noncommoninds, ts) - return SizedEinExpr(sum(tensor_exprs; skip = externalinds_tn), inds_dims) -end - -function tensor_inds_to_vertex(ts::ITensorList) - IndexType = Any - VertexType = Int - - mapping = Dict{Set{IndexType}, VertexType}() - - for (v, tensor_v) in enumerate(ts) - inds_v = collect(inds(tensor_v)) - mapping[Set(inds_v)] = v - end - - return mapping -end - -function ITensorNetworks.contraction_sequence( - ::Algorithm"einexpr", tn::ITensorList; optimizer = EinExprs.Exhaustive() - ) - expr = to_einexpr(tn) - path = einexpr(optimizer, expr) - return to_contraction_sequence(path, tensor_inds_to_vertex(tn)) -end - -function to_contraction_sequence(expr, tensor_inds_to_vertex) - EinExprs.nargs(expr) == 0 && return tensor_inds_to_vertex[Set(expr.head)] - return map( - expr -> to_contraction_sequence(expr, tensor_inds_to_vertex), EinExprs.args(expr) - ) -end - -end diff --git a/test/Project.toml b/test/Project.toml index 595f5f25..14fb6667 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -6,7 +6,6 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" DataGraphs = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a" Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -EinExprs = "b1794770-133b-4de1-afb4-526377e9f4c5" Glob = "c27321d9-0574-5035-807b-f59d2c89b15c" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889" @@ -43,7 +42,6 @@ Compat = "4.16" DataGraphs = "0.2.13" Dictionaries = "0.4.4" Distributions = "0.25.118" -EinExprs = "0.6.8, 0.7" Glob = "1.3.1" Graphs = "1.12" GraphsFlows = "0.1.1" diff --git a/test/test_contraction_sequence.jl b/test/test_contraction_sequence.jl index 3b8e8043..bda7c0d0 100644 --- a/test/test_contraction_sequence.jl +++ b/test/test_contraction_sequence.jl @@ -1,5 +1,4 @@ @eval module $(gensym()) -using EinExprs: Exhaustive, Greedy using ITensorNetworks: contraction_sequence, norm_sqr_network, random_tensornetwork, siteinds using ITensors: ITensors, contract @@ -25,18 +24,9 @@ using Test: @test, @testset res_tree_sa = contract(tn; sequence = seq_tree_sa)[] seq_sa_bipartite = contraction_sequence(tn; alg = "sa_bipartite") res_sa_bipartite = contract(tn; sequence = seq_sa_bipartite)[] - seq_einexprs_exhaustive = contraction_sequence( - tn; alg = "einexpr", optimizer = Exhaustive() - ) - res_einexprs_exhaustive = contract(tn; sequence = seq_einexprs_exhaustive)[] - seq_einexprs_greedy = - contraction_sequence(tn; alg = "einexpr", optimizer = Greedy()) - res_einexprs_greedy = contract(tn; sequence = seq_einexprs_exhaustive)[] @test res_greedy ≈ res_optimal @test res_tree_sa ≈ res_optimal @test res_sa_bipartite ≈ res_optimal - @test res_einexprs_exhaustive ≈ res_optimal - @test res_einexprs_greedy ≈ res_optimal if !Sys.iswindows() # KaHyPar doesn't work on Windows @@ -50,10 +40,6 @@ using Test: @test, @testset Pkg.rm("KaHyPar"; io = devnull) res_kahypar_bipartite = contract(tn; sequence = seq_kahypar_bipartite)[] @test res_optimal ≈ res_kahypar_bipartite - #These tests were leading to CI issues that need to be investigated - # seq_einexprs_kahypar = contraction_sequence(tn; alg="einexpr", optimizer=HyPar()) - # res_einexprs_kahypar = contract(tn; sequence=seq_einexprs_kahypar)[] - # @test res_einexprs_kahypar ≈ res_optimal end end end From 5e46f9c26d9514525512228d6a15c0c15d766eae Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Thu, 23 Apr 2026 14:45:52 -0400 Subject: [PATCH 2/2] Bump version to 0.16.0 (breaking) Removing the EinExprs extension drops the `alg = "einexpr"` contraction sequence algorithm, so this is a breaking change. Bump the root package to 0.16.0 and update the pinned version in test/, docs/, and examples/ Project.toml files to match. Co-Authored-By: Claude Opus 4.7 (1M context) --- Project.toml | 2 +- docs/Project.toml | 2 +- examples/Project.toml | 2 +- test/Project.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index b067c254..94a8c370 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ITensorNetworks" uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7" -version = "0.15.27" +version = "0.16.0" authors = ["Matthew Fishman , Joseph Tindall and contributors"] [workspace] diff --git a/docs/Project.toml b/docs/Project.toml index 306a3ab7..3147096f 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -16,7 +16,7 @@ path = ".." Documenter = "1.10" Graphs = "1" ITensorFormatter = "0.2.27" -ITensorNetworks = "0.15" +ITensorNetworks = "0.16" ITensors = "0.9" Literate = "2.20.1" NamedGraphs = "0.8.2" diff --git a/examples/Project.toml b/examples/Project.toml index 3be4ed25..3875e656 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -5,4 +5,4 @@ ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" path = ".." [compat] -ITensorNetworks = "0.15" +ITensorNetworks = "0.16" diff --git a/test/Project.toml b/test/Project.toml index 14fb6667..a8889c87 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ Glob = "1.3.1" Graphs = "1.12" GraphsFlows = "0.1.1" ITensorMPS = "0.3.6" -ITensorNetworks = "0.15" +ITensorNetworks = "0.16" ITensorPkgSkeleton = "0.3.42" ITensors = "0.7, 0.8, 0.9" KrylovKit = "0.8, 0.9, 0.10"