Skip to content

Commit dbb07fe

Browse files
mtfishmanclaude
andauthored
Remove Vidal gauge (#331)
## Summary Delete `VidalITensorNetwork` and its supporting machinery — `src/gauging.jl` (188 lines), the `apply(::Union{NamedEdge, ITensor}, ::VidalITensorNetwork; ...)` method in `src/apply.jl` (~72 lines), and `test/test_gauging.jl`. Trim the Vidal cases out of `test/test_apply.jl` (the SBP/GBP/exact fidelity comparisons stay). **Breaking:** - `VidalITensorNetwork` type removed, along with `vidalitensornetwork_preserve_cache`, `vidal_gauge_isometry` / `vidal_gauge_isometries`, `gauge_error`, the `ITensorNetwork(::VidalITensorNetwork; ...)` round-trip constructor, `update(::VidalITensorNetwork; ...)`, and the `apply(gate, ::VidalITensorNetwork; ...)` specialization. **Downstream impact** - **Tennis.jl:** no Vidal uses (GitHub code search). - **Other ITensor-org repos:** no hits. - **Third-party consumers with Vidal usage** (out-of-scope for this org but worth noting): - [anthonypetertc/OpenNetworks.jl](https://github.com/anthonypetertc/OpenNetworks.jl) — uses `VidalITensorNetwork(ψ)` - [coesu/TTNEvo](https://github.com/coesu/TTNEvo) — uses `VidalITensorNetwork` + `gauge_error` + `bond_tensors` Both are pinned and will be protected by SemVer (0.17 → 0.18 breaking). They'll stay on 0.17.x until they choose to migrate. **Incidental import cleanups** A few imports were previously available inside `ITensorNetworks` as a side effect of `using` clauses in `src/gauging.jl`. They are now imported directly by the files that actually use them: - `ITensors.NDTensors: scalartype` — `src/apply.jl`, `src/abstractitensornetwork.jl` - `ITensors: tags` — `src/apply.jl`, `src/abstractitensornetwork.jl` **Version** Bumps to `0.18.0` (pre-1.0 minor bump = breaking) and updates pinned `ITensorNetworks` compat in `test/`, `docs/`, and `examples/` Project.toml. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 04b80c5 commit dbb07fe

10 files changed

Lines changed: 10 additions & 327 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ITensorNetworks"
22
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
authors = ["Matthew Fishman <mfishman@flatironinstitute.org>, Joseph Tindall <jtindall@flatironinstitute.org> and contributors"]
55

66
[workspace]

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ path = ".."
1616
Documenter = "1.10"
1717
Graphs = "1"
1818
ITensorFormatter = "0.2.27"
19-
ITensorNetworks = "0.17"
19+
ITensorNetworks = "0.18"
2020
ITensors = "0.9"
2121
Literate = "2.20.1"
2222
NamedGraphs = "0.8.2"

examples/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7"
55
path = ".."
66

77
[compat]
8-
ITensorNetworks = "0.17"
8+
ITensorNetworks = "0.18"

src/ITensorNetworks.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ include("formnetworks/abstractformnetwork.jl")
2323
include("formnetworks/bilinearformnetwork.jl")
2424
include("formnetworks/linearformnetwork.jl")
2525
include("formnetworks/quadraticformnetwork.jl")
26-
include("gauging.jl")
2726
include("utils.jl")
2827
include("update_observer.jl")
2928

src/abstractitensornetwork.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ using Graphs: Graphs, Graph, add_edge!, add_vertex!, bfs_tree, center, dst, edge
77
ne, neighbors, rem_edge!, src, vertices
88
using ITensors: ITensors, @Algorithm_str, ITensor, addtags, combiner, commoninds,
99
commontags, contract, dag, hascommoninds, inds, noprime, onehot, prime, replaceprime,
10-
replacetags, setprime, settags, sim, swaptags, unioninds, uniqueinds
10+
replacetags, setprime, settags, sim, swaptags, tags, unioninds, uniqueinds
1111
using LinearAlgebra: LinearAlgebra, factorize
1212
using MacroTools: @capture
13-
using NDTensors: NDTensors, Algorithm, dim
13+
using NDTensors: NDTensors, Algorithm, dim, scalartype
1414
using NamedGraphs.GraphsExtensions:
1515
directed_graph, incident_edges, rename_vertices, vertextype,
1616
using NamedGraphs: NamedGraphs, NamedGraph, not_implemented, steiner_tree

src/apply.jl

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using .BaseExtensions: maybe_real
22
using Graphs: has_edge
3+
using ITensors.NDTensors: scalartype
34
using ITensors: ITensors, ITensor, Index, Ops, apply, commonind, commoninds, contract, dag,
45
denseblocks, factorize, factorize_svd, hasqns, isdiag, noncommoninds, noprime, prime,
5-
replaceind, replaceinds, unioninds, uniqueinds
6+
replaceind, replaceinds, tags, unioninds, uniqueinds
67
using KrylovKit: linsolve
78
using LinearAlgebra: eigen, norm, qr, svd
89
using NamedGraphs: NamedEdge, has_edge
@@ -304,80 +305,6 @@ function _contract_gate(o::AbstractEdge, ψv1, Λ, ψv2)
304305
return Qᵥ₁, Rᵥ₁, Qᵥ₂, Rᵥ₂, theta
305306
end
306307

307-
# In the future we will try to unify this into apply() above but currently leave it mostly as a separate function
308-
# Apply() function for an ITN in the Vidal Gauge. Hence the bond tensors are required.
309-
# Gate does not necessarily need to be passed. Can supply an edge to do an identity update instead. Uses Simple Update procedure assuming gate is two-site
310-
function ITensors.apply(
311-
o::Union{NamedEdge, ITensor}, ψ::VidalITensorNetwork; normalize = false, apply_kwargs...
312-
)
313-
updated_ψ = copy(site_tensors(ψ))
314-
updated_bond_tensors = copy(bond_tensors(ψ))
315-
v⃗ = _gate_vertices(o, ψ)
316-
if length(v⃗) == 2
317-
e = NamedEdge(v⃗[1] => v⃗[2])
318-
ψv1, ψv2 = ψ[src(e)], ψ[dst(e)]
319-
e_ind = commonind(ψv1, ψv2)
320-
321-
for vn in neighbors(ψ, src(e))
322-
if (vn != dst(e))
323-
ψv1 = noprime(ψv1 * bond_tensor(ψ, vn => src(e)))
324-
end
325-
end
326-
327-
for vn in neighbors(ψ, dst(e))
328-
if (vn != src(e))
329-
ψv2 = noprime(ψv2 * bond_tensor(ψ, vn => dst(e)))
330-
end
331-
end
332-
333-
Qᵥ₁, Rᵥ₁, Qᵥ₂, Rᵥ₂, theta = _contract_gate(o, ψv1, bond_tensor(ψ, e), ψv2)
334-
335-
U, S, V = ITensors.svd(
336-
theta,
337-
uniqueinds(Rᵥ₁, Rᵥ₂);
338-
lefttags = ITensorNetworks.edge_tag(e),
339-
righttags = ITensorNetworks.edge_tag(e),
340-
apply_kwargs...
341-
)
342-
343-
ind_to_replace = commonind(V, S)
344-
ind_to_replace_with = commonind(U, S)
345-
S = replaceind(S, ind_to_replace => ind_to_replace_with')
346-
V = replaceind(V, ind_to_replace => ind_to_replace_with)
347-
348-
ψv1, updated_bond_tensors[e], ψv2 = U * Qᵥ₁, S, V * Qᵥ₂
349-
350-
for vn in neighbors(ψ, src(e))
351-
if (vn != dst(e))
352-
ψv1 =
353-
noprime(ψv1 * ITensorsExtensions.inv_diag(bond_tensor(ψ, vn => src(e))))
354-
end
355-
end
356-
357-
for vn in neighbors(ψ, dst(e))
358-
if (vn != src(e))
359-
ψv2 =
360-
noprime(ψv2 * ITensorsExtensions.inv_diag(bond_tensor(ψ, vn => dst(e))))
361-
end
362-
end
363-
364-
if normalize
365-
ψv1 /= norm(ψv1)
366-
ψv2 /= norm(ψv2)
367-
updated_bond_tensors[e] /= norm(updated_bond_tensors[e])
368-
end
369-
370-
setindex_preserve_graph!(updated_ψ, ψv1, src(e))
371-
setindex_preserve_graph!(updated_ψ, ψv2, dst(e))
372-
373-
return VidalITensorNetwork(updated_ψ, updated_bond_tensors)
374-
375-
else
376-
updated_ψ = apply(o, updated_ψ; normalize)
377-
return VidalITensorNetwork(updated_ψ, updated_bond_tensors)
378-
end
379-
end
380-
381308
### Full Update Routines ###
382309

383310
# Calculate the overlap of the gate acting on the previous p and q versus the new p and q in the presence of environments. This is the cost function that optimise_p_q will minimise

src/gauging.jl

Lines changed: 0 additions & 188 deletions
This file was deleted.

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Glob = "1.3.1"
4646
Graphs = "1.12"
4747
GraphsFlows = "0.1.1"
4848
ITensorMPS = "0.3.6"
49-
ITensorNetworks = "0.17"
49+
ITensorNetworks = "0.18"
5050
ITensorPkgSkeleton = "0.3.42"
5151
ITensors = "0.7, 0.8, 0.9"
5252
KrylovKit = "0.8, 0.9, 0.10"

test/test_apply.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@eval module $(gensym())
22
using Compat: Compat
33
using Graphs: vertices
4-
using ITensorNetworks: BeliefPropagationCache, ITensorNetwork, VidalITensorNetwork, apply,
5-
environment, norm_sqr_network, random_tensornetwork, siteinds, update
4+
using ITensorNetworks: BeliefPropagationCache, apply, environment, norm_sqr_network,
5+
random_tensornetwork, siteinds, update
66
using ITensors: ITensors, Algorithm, ITensor, inner, op
77
using NamedGraphs.NamedGraphGenerators: named_grid
88
using SplitApplyCombine: group
@@ -23,7 +23,6 @@ using Test: @test, @testset
2323
bp_cache = BeliefPropagationCache(ψψ, group(v -> v[1], vertices(ψψ)))
2424
bp_cache = update(bp_cache; maxiter = 20)
2525
envsSBP = environment(bp_cache, [(v1, "bra"), (v1, "ket"), (v2, "bra"), (v2, "ket")])
26-
ψv = VidalITensorNetwork(ψ; cache_update_kwargs = (; maxiter = 20))
2726
#This grouping will correspond to calculating the environments exactly (each column of the grid is a partition)
2827
bp_cache = BeliefPropagationCache(ψψ, group(v -> v[1][1], vertices(ψψ)))
2928
bp_cache = update(bp_cache; maxiter = 20)
@@ -49,8 +48,6 @@ using Test: @test, @testset
4948
envisposdef = true,
5049
callback
5150
)
52-
ψOv = apply(o, ψv; maxdim = χ, normalize = true)
53-
ψOVidal_symm = ITensorNetwork(ψOv)
5451
ψOGBP = apply(
5552
o,
5653
ψ;
@@ -66,11 +63,6 @@ using Test: @test, @testset
6663
inner(ψOexact, ψOexact; alg = inner_alg) *
6764
inner(ψOSBP, ψOSBP; alg = inner_alg)
6865
)
69-
fVidal =
70-
inner(ψOVidal_symm, ψOexact; alg = inner_alg) / sqrt(
71-
inner(ψOexact, ψOexact; alg = inner_alg) *
72-
inner(ψOVidal_symm, ψOVidal_symm; alg = inner_alg)
73-
)
7466
fGBP =
7567
inner(ψOGBP, ψOexact; alg = inner_alg) /
7668
sqrt(
@@ -79,7 +71,6 @@ using Test: @test, @testset
7971
)
8072
@test !iszero(truncerr)
8173
@test real(fGBP * conj(fGBP)) >= real(fSBP * conj(fSBP))
82-
@test isapprox(real(fSBP * conj(fSBP)), real(fVidal * conj(fVidal)); atol = 1.0e-3)
8374
end
8475
end
8576
end

0 commit comments

Comments
 (0)