Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ITensorNetworks"
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
version = "0.17.0"
version = "0.18.0"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org>, Joseph Tindall <jtindall@flatironinstitute.org> and contributors"]

[workspace]
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = ".."
Documenter = "1.10"
Graphs = "1"
ITensorFormatter = "0.2.27"
ITensorNetworks = "0.17"
ITensorNetworks = "0.18"
ITensors = "0.9"
Literate = "2.20.1"
NamedGraphs = "0.8.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7"
path = ".."

[compat]
ITensorNetworks = "0.17"
ITensorNetworks = "0.18"
1 change: 0 additions & 1 deletion src/ITensorNetworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ include("formnetworks/abstractformnetwork.jl")
include("formnetworks/bilinearformnetwork.jl")
include("formnetworks/linearformnetwork.jl")
include("formnetworks/quadraticformnetwork.jl")
include("gauging.jl")
include("utils.jl")
include("update_observer.jl")

Expand Down
4 changes: 2 additions & 2 deletions src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ using Graphs: Graphs, Graph, add_edge!, add_vertex!, bfs_tree, center, dst, edge
ne, neighbors, rem_edge!, src, vertices
using ITensors: ITensors, @Algorithm_str, ITensor, addtags, combiner, commoninds,
commontags, contract, dag, hascommoninds, inds, noprime, onehot, prime, replaceprime,
replacetags, setprime, settags, sim, swaptags, unioninds, uniqueinds
replacetags, setprime, settags, sim, swaptags, tags, unioninds, uniqueinds
using LinearAlgebra: LinearAlgebra, factorize
using MacroTools: @capture
using NDTensors: NDTensors, Algorithm, dim
using NDTensors: NDTensors, Algorithm, dim, scalartype
using NamedGraphs.GraphsExtensions:
directed_graph, incident_edges, rename_vertices, vertextype, ⊔
using NamedGraphs: NamedGraphs, NamedGraph, not_implemented, steiner_tree
Expand Down
77 changes: 2 additions & 75 deletions src/apply.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using .BaseExtensions: maybe_real
using Graphs: has_edge
using ITensors.NDTensors: scalartype
using ITensors: ITensors, ITensor, Index, Ops, apply, commonind, commoninds, contract, dag,
denseblocks, factorize, factorize_svd, hasqns, isdiag, noncommoninds, noprime, prime,
replaceind, replaceinds, unioninds, uniqueinds
replaceind, replaceinds, tags, unioninds, uniqueinds
using KrylovKit: linsolve
using LinearAlgebra: eigen, norm, qr, svd
using NamedGraphs: NamedEdge, has_edge
Expand Down Expand Up @@ -304,80 +305,6 @@ function _contract_gate(o::AbstractEdge, ψv1, Λ, ψv2)
return Qᵥ₁, Rᵥ₁, Qᵥ₂, Rᵥ₂, theta
end

# In the future we will try to unify this into apply() above but currently leave it mostly as a separate function
# Apply() function for an ITN in the Vidal Gauge. Hence the bond tensors are required.
# 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
function ITensors.apply(
o::Union{NamedEdge, ITensor}, ψ::VidalITensorNetwork; normalize = false, apply_kwargs...
)
updated_ψ = copy(site_tensors(ψ))
updated_bond_tensors = copy(bond_tensors(ψ))
v⃗ = _gate_vertices(o, ψ)
if length(v⃗) == 2
e = NamedEdge(v⃗[1] => v⃗[2])
ψv1, ψv2 = ψ[src(e)], ψ[dst(e)]
e_ind = commonind(ψv1, ψv2)

for vn in neighbors(ψ, src(e))
if (vn != dst(e))
ψv1 = noprime(ψv1 * bond_tensor(ψ, vn => src(e)))
end
end

for vn in neighbors(ψ, dst(e))
if (vn != src(e))
ψv2 = noprime(ψv2 * bond_tensor(ψ, vn => dst(e)))
end
end

Qᵥ₁, Rᵥ₁, Qᵥ₂, Rᵥ₂, theta = _contract_gate(o, ψv1, bond_tensor(ψ, e), ψv2)

U, S, V = ITensors.svd(
theta,
uniqueinds(Rᵥ₁, Rᵥ₂);
lefttags = ITensorNetworks.edge_tag(e),
righttags = ITensorNetworks.edge_tag(e),
apply_kwargs...
)

ind_to_replace = commonind(V, S)
ind_to_replace_with = commonind(U, S)
S = replaceind(S, ind_to_replace => ind_to_replace_with')
V = replaceind(V, ind_to_replace => ind_to_replace_with)

ψv1, updated_bond_tensors[e], ψv2 = U * Qᵥ₁, S, V * Qᵥ₂

for vn in neighbors(ψ, src(e))
if (vn != dst(e))
ψv1 =
noprime(ψv1 * ITensorsExtensions.inv_diag(bond_tensor(ψ, vn => src(e))))
end
end

for vn in neighbors(ψ, dst(e))
if (vn != src(e))
ψv2 =
noprime(ψv2 * ITensorsExtensions.inv_diag(bond_tensor(ψ, vn => dst(e))))
end
end

if normalize
ψv1 /= norm(ψv1)
ψv2 /= norm(ψv2)
updated_bond_tensors[e] /= norm(updated_bond_tensors[e])
end

setindex_preserve_graph!(updated_ψ, ψv1, src(e))
setindex_preserve_graph!(updated_ψ, ψv2, dst(e))

return VidalITensorNetwork(updated_ψ, updated_bond_tensors)

else
updated_ψ = apply(o, updated_ψ; normalize)
return VidalITensorNetwork(updated_ψ, updated_bond_tensors)
end
end

### Full Update Routines ###

# 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
Expand Down
188 changes: 0 additions & 188 deletions src/gauging.jl

This file was deleted.

2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Glob = "1.3.1"
Graphs = "1.12"
GraphsFlows = "0.1.1"
ITensorMPS = "0.3.6"
ITensorNetworks = "0.17"
ITensorNetworks = "0.18"
ITensorPkgSkeleton = "0.3.42"
ITensors = "0.7, 0.8, 0.9"
KrylovKit = "0.8, 0.9, 0.10"
Expand Down
13 changes: 2 additions & 11 deletions test/test_apply.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@eval module $(gensym())
using Compat: Compat
using Graphs: vertices
using ITensorNetworks: BeliefPropagationCache, ITensorNetwork, VidalITensorNetwork, apply,
environment, norm_sqr_network, random_tensornetwork, siteinds, update
using ITensorNetworks: BeliefPropagationCache, apply, environment, norm_sqr_network,
random_tensornetwork, siteinds, update
using ITensors: ITensors, Algorithm, ITensor, inner, op
using NamedGraphs.NamedGraphGenerators: named_grid
using SplitApplyCombine: group
Expand All @@ -23,7 +23,6 @@ using Test: @test, @testset
bp_cache = BeliefPropagationCache(ψψ, group(v -> v[1], vertices(ψψ)))
bp_cache = update(bp_cache; maxiter = 20)
envsSBP = environment(bp_cache, [(v1, "bra"), (v1, "ket"), (v2, "bra"), (v2, "ket")])
ψv = VidalITensorNetwork(ψ; cache_update_kwargs = (; maxiter = 20))
#This grouping will correspond to calculating the environments exactly (each column of the grid is a partition)
bp_cache = BeliefPropagationCache(ψψ, group(v -> v[1][1], vertices(ψψ)))
bp_cache = update(bp_cache; maxiter = 20)
Expand All @@ -49,8 +48,6 @@ using Test: @test, @testset
envisposdef = true,
callback
)
ψOv = apply(o, ψv; maxdim = χ, normalize = true)
ψOVidal_symm = ITensorNetwork(ψOv)
ψOGBP = apply(
o,
ψ;
Expand All @@ -66,11 +63,6 @@ using Test: @test, @testset
inner(ψOexact, ψOexact; alg = inner_alg) *
inner(ψOSBP, ψOSBP; alg = inner_alg)
)
fVidal =
inner(ψOVidal_symm, ψOexact; alg = inner_alg) / sqrt(
inner(ψOexact, ψOexact; alg = inner_alg) *
inner(ψOVidal_symm, ψOVidal_symm; alg = inner_alg)
)
fGBP =
inner(ψOGBP, ψOexact; alg = inner_alg) /
sqrt(
Expand All @@ -79,7 +71,6 @@ using Test: @test, @testset
)
@test !iszero(truncerr)
@test real(fGBP * conj(fGBP)) >= real(fSBP * conj(fSBP))
@test isapprox(real(fSBP * conj(fSBP)), real(fVidal * conj(fVidal)); atol = 1.0e-3)
end
end
end
Loading
Loading