Skip to content

Commit

Permalink
6x speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
lpawela committed May 20, 2021
1 parent 8d13927 commit 8ea9f68
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
32 changes: 16 additions & 16 deletions src/PEPS.jl
Expand Up @@ -59,15 +59,15 @@ end


@memoize Dict function peps_tensor(peps::PEPSNetwork, i::Int, j::Int) where {T <: Number}
println("Computing peps_tensor for $(i), $(j)")
# println("Computing peps_tensor for $(i), $(j)")
# generate tensors from projectors
A = build_tensor(peps, (i, j))

# include energy
h = build_tensor(peps, (i, j-1), (i, j))
v = build_tensor(peps, (i-1, j), (i, j))
println("Starting @tensor")
@time @tensor B[l, u, r, d, σ] := h[l, l̃] * v[u, ũ] * A[l̃, ũ, r, d, σ]
# println("Starting @tensor")
@tensor B[l, u, r, d, σ] := h[l, l̃] * v[u, ũ] * A[l̃, ũ, r, d, σ]
B
end

Expand Down Expand Up @@ -97,7 +97,7 @@ function SpinGlassTensors.MPO(::Type{T},
end


SpinGlassTensors.MPO(
@memoize Dict SpinGlassTensors.MPO(
peps::PEPSNetwork,
i::Int,
states_indices::Dict{NTuple{2, Int}, Int} = Dict{NTuple{2, Int}, Int}()
Expand Down Expand Up @@ -169,24 +169,24 @@ end
function conditional_probability(peps::PEPSNetwork, v::Vector{Int},
)

@time i, j = node_from_index(peps, length(v)+1)
@time ∂v = generate_boundary_states(peps, v, (i, j))
i, j = node_from_index(peps, length(v)+1)
∂v = generate_boundary_states(peps, v, (i, j))

@time W = MPO(peps, i)
@time ψ = MPS(peps, i+1)
W = MPO(peps, i)
ψ = MPS(peps, i+1)

@time L = left_env(ψ, ∂v[1:j-1])
@time R = right_env(ψ, W, ∂v[j+2:peps.ncols+1])
@time A = peps_tensor(peps, i, j)
L = left_env(ψ, ∂v[1:j-1])
R = right_env(ψ, W, ∂v[j+2:peps.ncols+1])
A = peps_tensor(peps, i, j)

@time l, u = ∂v[j:j+1]
@time M = ψ[j]
@time = A[l, u, :, :, :]
@time @tensor prob[σ] := L[x] * M[x, d, y] *
l, u = ∂v[j:j+1]
M = ψ[j]
= A[l, u, :, :, :]
@tensor prob[σ] := L[x] * M[x, d, y] *
Ã[r, d, σ] * R[y, r] order = (x, d, r, y)


@time _normalize_probability(prob)
_normalize_probability(prob)
end

function bond_energy(network, u::NTuple{2, Int}, v::NTuple{2, Int}, σ::Int)
Expand Down
18 changes: 9 additions & 9 deletions src/search.jl
Expand Up @@ -22,15 +22,15 @@ end

function branch_solution(partial_sol::Solution, network::AbstractGibbsNetwork)

if length(partial_sol.states[1]) > 6
println("Separator 1")
conditional_probability(network, partial_sol.states[1])
println("Separator 2")
conditional_probability(network, partial_sol.states[1])
println(length(memoize_cache(peps_tensor)))

exit(42)
end
# if length(partial_sol.states[1]) > 6
# println("Separator 1")
# conditional_probability(network, partial_sol.states[1])
# println("Separator 2")
# conditional_probability(network, partial_sol.states[1])
# println(length(memoize_cache(peps_tensor)))

# exit(42)
# end
Solution(
vcat(
[
Expand Down

0 comments on commit 8ea9f68

Please sign in to comment.