Skip to content

Commit

Permalink
Fix gauging tests. Lower tol for default
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Jun 25, 2024
1 parent b23f5a6 commit 8ad4493
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 2 additions & 8 deletions src/caches/beliefpropagationcache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ default_partitioned_vertices(ψ::AbstractITensorNetwork) = group(v -> v, vertice
function default_partitioned_vertices(f::AbstractFormNetwork)
return group(v -> original_state_vertex(f, v), vertices(f))
end
default_cache_update_kwargs(cache) = (; maxiter=20, tol=1e-5)
default_cache_update_kwargs(cache) = (; maxiter=25, tol=1e-8)
function default_cache_construction_kwargs(alg::Algorithm"bp", ψ::AbstractITensorNetwork)
return (; partitioned_vertices=default_partitioned_vertices(ψ))
end

function message_diff(message_a::Vector{ITensor}, message_b::Vector{ITensor})
lhs, rhs = contract(message_a), contract(message_b)
@assert issetequal(inds(lhs), inds(rhs))
c = combiner(inds(lhs))
lhs *= c
rhs *= c
lhs /= norm(lhs)
rhs /= norm(rhs)
f = abs(dot(lhs, rhs))^2
f = abs(dot(lhs / norm(lhs), rhs / norm(rhs)))^2
return 1 - f
end

Expand Down
6 changes: 2 additions & 4 deletions test/test_gauging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ using Test: @test, @testset
ψ = random_tensornetwork(rng, s; link_space=χ)

# Move directly to vidal gauge
ψ_vidal = VidalITensorNetwork(
ψ; cache_update_kwargs=(; maxiter=20, tol=1e-12, verbose=true)
)
ψ_vidal = VidalITensorNetwork(ψ; cache_update_kwargs=(; maxiter=30, verbose=true))
@test gauge_error(ψ_vidal) < 1e-8

# Move to symmetric gauge
Expand All @@ -38,7 +36,7 @@ using Test: @test, @testset
bp_cache = cache_ref[]

# Test we just did a gauge transform and didn't change the overall network
@test inner(ψ_symm, ψ) / sqrt(inner(ψ_symm, ψ_symm) * inner(ψ, ψ)) 1.0
@test inner(ψ_symm, ψ) / sqrt(inner(ψ_symm, ψ_symm) * inner(ψ, ψ)) 1.0 atol = 1e-8

#Test all message tensors are approximately diagonal even when we keep running BP
bp_cache = update(bp_cache; maxiter=10)
Expand Down

0 comments on commit 8ad4493

Please sign in to comment.