diff --git a/examples/gauging/gauging_itns.jl b/examples/gauging/gauging_itns.jl index 82f6cf8e..0f65dc8e 100644 --- a/examples/gauging/gauging_itns.jl +++ b/examples/gauging/gauging_itns.jl @@ -22,6 +22,7 @@ using ITensorNetworks: using NamedGraphs using NamedGraphs: add_edges!, rem_vertex!, hexagonal_lattice_graph using Graphs +using MKL """Eager Gauging""" function eager_gauging(ψ::ITensorNetwork, bond_tensors::DataGraph, mts::DataGraph) @@ -85,7 +86,7 @@ function benchmark_state_gauging( C[i] = vidal_itn_canonicalness(ψ, bond_tensors) end - + @show times_iters, time simulation_times = cumsum(times_iters) + times_gauging return simulation_times, C diff --git a/src/beliefpropagation/beliefpropagation.jl b/src/beliefpropagation/beliefpropagation.jl index bbd73dd6..bb7f376f 100644 --- a/src/beliefpropagation/beliefpropagation.jl +++ b/src/beliefpropagation/beliefpropagation.jl @@ -22,12 +22,13 @@ function message_tensors_skeleton(subgraphs::DataGraph) end function message_tensors( - subgraphs::DataGraph; itensor_constructor=inds_e -> dense(delta(inds_e)) + subgraphs::DataGraph; itensor_constructor=x -> ITensor[dense(delta(i)) for i in x] ) mts = message_tensors_skeleton(subgraphs) for e in edges(subgraphs) - inds_e = commoninds(subgraphs[src(e)], subgraphs[dst(e)]) - mts[e] = ITensorNetwork(map(itensor_constructor, inds_e)) + inds_e = [i for i in commoninds(subgraphs[src(e)], subgraphs[dst(e)])] + itensors = itensor_constructor(inds_e) + mts[e] = ITensorNetwork(itensors) mts[reverse(e)] = dag(mts[e]) end return mts @@ -118,7 +119,7 @@ function belief_propagation( contract_kwargs=(; alg="density_matrix", output_structure=path_graph_structure, maxdim=1), niters=20, target_precision::Union{Float64,Nothing}=nothing, - update_sequence::String="parallel", + update_sequence::String="sequential", edges = edge_update_order(undirected_graph(underlying_graph(mts))) ) compute_norm = target_precision == nothing ? false : true @@ -143,10 +144,11 @@ function belief_propagation( npartitions=nothing, subgraph_vertices=nothing, niters=20, + update_sequence::String="sequential", target_precision::Union{Float64,Nothing}=nothing, ) mts = message_tensors(tn; nvertices_per_partition, npartitions, subgraph_vertices) - return belief_propagation(tn, mts; contract_kwargs, niters, target_precision) + return belief_propagation(tn, mts; contract_kwargs, niters, target_precision, update_sequence) end """ diff --git a/src/beliefpropagation/sqrt_beliefpropagation.jl b/src/beliefpropagation/sqrt_beliefpropagation.jl index 07b074da..c9ba053e 100644 --- a/src/beliefpropagation/sqrt_beliefpropagation.jl +++ b/src/beliefpropagation/sqrt_beliefpropagation.jl @@ -5,7 +5,7 @@ function sqrt_belief_propagation( tn::ITensorNetwork, mts::DataGraph; niters=20, - update_sequence::String="parallel", + update_sequence::String="sequential", # target_precision::Union{Float64,Nothing}=nothing, ) # compute_norm = target_precision == nothing ? false : true @@ -27,8 +27,8 @@ end function sqrt_belief_propagation_iteration( tn::ITensorNetwork, sqrt_mts::DataGraph; - update_sequence::String="parallel", - edges=Graphs.edges(sqrt_mts), + update_sequence::String="sequential", + edges=edge_update_order(undirected_graph(underlying_graph(mts))), # compute_norm=false, ) diff --git a/src/gauging.jl b/src/gauging.jl index 2ef8dd0c..79aca813 100644 --- a/src/gauging.jl +++ b/src/gauging.jl @@ -95,6 +95,7 @@ function vidal_gauge( regularization=10 * eps(real(scalartype(ψ))), niters=30, target_canonicalness::Union{Nothing,Float64}=nothing, + update_sequence = "sequential", svd_kwargs..., ) ψψ = norm_network(ψ) @@ -102,7 +103,7 @@ function vidal_gauge( mts = message_tensors(Z) mts = belief_propagation( - ψψ, mts; contract_kwargs=(; alg="exact"), niters, target_precision=target_canonicalness + ψψ, mts; contract_kwargs=(; alg="exact"), niters, target_precision=target_canonicalness, update_sequence ) return vidal_gauge( ψ, mts; eigen_message_tensor_cutoff, regularization, niters, svd_kwargs... diff --git a/test/test_belief_propagation.jl b/test/test_belief_propagation.jl index 4c75bf90..dff03220 100644 --- a/test/test_belief_propagation.jl +++ b/test/test_belief_propagation.jl @@ -52,7 +52,7 @@ ITensors.disable_warn_order() ψψ, mts, [(v, 1)]; verts_tn=ITensorNetwork(ITensor[apply(op("Sz", s[v]), ψ[v])]) ) denominator_network = approx_network_region(ψψ, mts, [(v, 1)]) - bp_sz = contract(numerator_network)[] / contract(denominator_network)[] + bp_sz = ITensors.contract(numerator_network)[] / ITensors.contract(denominator_network)[] @test abs.(bp_sz - exact_sz) <= 1e-14 @@ -85,7 +85,7 @@ ITensors.disable_warn_order() ψψ, mts, [(v, 1)]; verts_tn=ITensorNetwork(ITensor[apply(op("Sz", s[v]), ψ[v])]) ) denominator_network = approx_network_region(ψψ, mts, [(v, 1)]) - bp_sz = contract(numerator_network)[] / contract(denominator_network)[] + bp_sz = ITensors.contract(numerator_network)[] / ITensors.contract(denominator_network)[] @test abs.(bp_sz - exact_sz) <= 1e-14 @@ -112,7 +112,7 @@ ITensors.disable_warn_order() ) denominator_network = approx_network_region(ψψ, mts, vs) - bp_szsz = contract(numerator_network)[] / contract(denominator_network)[] + bp_szsz = ITensors.contract(numerator_network)[] / ITensors.contract(denominator_network)[] @test abs.(bp_szsz - actual_szsz) <= 0.05 @@ -134,7 +134,7 @@ ITensors.disable_warn_order() mts = belief_propagation(ψψ, mts; contract_kwargs=(; alg="exact")) ψψsplit = split_index(ψψ, NamedEdge.([(v, 1) => (v, 2) for v in vs])) - rdm = contract( + rdm = ITensors.contract( approx_network_region( ψψ, mts, @@ -183,7 +183,7 @@ ITensors.disable_warn_order() numerator_network = approx_network_region(ψψ, mts, [v]; verts_tn=ITensorNetwork(ψOψ[v])) denominator_network = approx_network_region(ψψ, mts, [v]) - bp_sz = contract(numerator_network)[] / contract(denominator_network)[] + bp_sz = ITensors.contract(numerator_network)[] / ITensors.contract(denominator_network)[] exact_sz = contract_boundary_mps(ψOψ; cutoff=1e-16) / contract_boundary_mps(ψψ; cutoff=1e-16) diff --git a/test/test_gauging.jl b/test/test_gauging.jl index b8d9fb5f..5d5e6c77 100644 --- a/test/test_gauging.jl +++ b/test/test_gauging.jl @@ -21,7 +21,7 @@ using SplitApplyCombine dims = (n, n) g = named_grid(dims) s = siteinds("S=1/2", g) - χ = 3 + χ = 6 Random.seed!(5467) ψ = randomITensorNetwork(s; link_space=χ)