From 5656563d8de44ebbc82235d3c0410c96feb47eb7 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Tue, 21 Jul 2026 15:07:31 -0400 Subject: [PATCH] Support ITensorBase v0.13 ## Summary Builds ITensorNetworksNext against ITensorBase v0.13 (https://github.com/ITensor/ITensorBase.jl/pull/222), which reworks `NamedTensorOperator` around an output/input name pairing. Renames the `domainnames` accessor to `inputnames` in the belief-propagation apply path. The Ising-network generator inserted each bond matrix with `apply` on an operator whose shared leg was its output. The reworked `apply` preserves a state's names and only contracts an operator's input, so it now rejects that usage. The old `apply` had degraded to a plain contraction in that case anyway, so this replaces it with the direct named contraction it was really doing, leaving the generated network and the Ising free-energy checks unchanged. --- Project.toml | 4 ++-- src/ITensorNetworkGenerators/ising_network.jl | 10 ++++++---- src/apply/apply_operators.jl | 4 ++-- test/Project.toml | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 3af3b67..00bf323 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ITensorNetworksNext" uuid = "302f2e75-49f0-4526-aef7-d8ba550cb06c" -version = "0.9.8" +version = "0.9.9" authors = ["ITensor developers and contributors"] [workspace] @@ -36,7 +36,7 @@ Combinatorics = "1" DataGraphs = "0.5" Dictionaries = "0.4.5" Graphs = "1.13.1" -ITensorBase = "0.10, 0.11, 0.12" +ITensorBase = "0.13" LinearAlgebra = "1.10" MacroTools = "0.5.16" MatrixAlgebraKit = "0.6" diff --git a/src/ITensorNetworkGenerators/ising_network.jl b/src/ITensorNetworkGenerators/ising_network.jl index 803adff..65f054b 100644 --- a/src/ITensorNetworkGenerators/ising_network.jl +++ b/src/ITensorNetworkGenerators/ising_network.jl @@ -1,6 +1,6 @@ using ..ITensorNetworksNext using Graphs: degree, dst, edges, src -using ITensorBase: apply, name, operator, uniquename +using ITensorBase: name, nameddims, uniquename using LinearAlgebra: Diagonal, eigen using NamedGraphs.GraphsExtensions: vertextype @@ -43,9 +43,11 @@ function ising_network( deg2 = degree(tn, v2) m = sqrt_ising_bond(β; J, h, deg1, deg2) - t = operator(m, (name(fp(e)),), (name(f(e)),)) - tn[v1] = apply(t, tn[v1]) - tn[v2] = apply(t, tn[v2]) + # Split the Ising bond as √b on each endpoint, contracting the delta-network bond + # name `fp(e)` and renaming the shared bond to the requested name `f(e)`. + b = nameddims(m, (name(fp(e)), name(f(e)))) + tn[v1] = b * tn[v1] + tn[v2] = b * tn[v2] end return tn end diff --git a/src/apply/apply_operators.jl b/src/apply/apply_operators.jl index 74836b8..a885ca9 100644 --- a/src/apply/apply_operators.jl +++ b/src/apply/apply_operators.jl @@ -3,7 +3,7 @@ using AlgorithmsInterface: AlgorithmsInterface as AI using Base: @kwdef using Graphs: dst, src, vertices using ITensorBase: - ITensorBase as ITB, AbstractITensor, dimnames, domainnames, operator, replacedimnames + ITensorBase as ITB, AbstractITensor, dimnames, inputnames, operator, replacedimnames using LinearAlgebra: norm using MatrixAlgebraKit: qr_compact, svd_trunc using NamedGraphs.GraphsExtensions: all_edges, boundary_edges @@ -209,7 +209,7 @@ function apply_gate_bp!( dest::AbstractITensorNetwork, op::AbstractITensor, state::AbstractITensorNetwork, env; kwargs... ) - op_in = domainnames(op) + op_in = inputnames(op) vs = [v for v in vertices(state) if !isempty(intersect(op_in, sitenames(state, v)))] isempty(vs) && throw( ArgumentError("operator shares no indices with the tensor network") diff --git a/test/Project.toml b/test/Project.toml index ca405a2..0711602 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -31,7 +31,7 @@ DataGraphs = "0.5" Dictionaries = "0.4.5" GradedArrays = "0.13.2" Graphs = "1.13.1" -ITensorBase = "0.10, 0.11, 0.12" +ITensorBase = "0.13" ITensorNetworksNext = "0.9" ITensorPkgSkeleton = "0.3.42" MatrixAlgebraKit = "0.6"