Skip to content

Commit

Permalink
Emergency bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Aug 8, 2024
1 parent cb12157 commit 3af1b08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[compat]
Dictionaries = "0.4.2"
Expand All @@ -21,4 +22,4 @@ ITensorNetworks = "0.11.15"
ITensors = "0.5, 0.6"
NamedGraphs = "0.6"
Random = "1.8"
julia = "1.8"
julia = "1.10"
16 changes: 2 additions & 14 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ using ITensorNetworks:
environment,
update,
factor,
default_message_update,
tensornetwork,
partitioned_tensornetwork,
operator_vertex,
Expand Down Expand Up @@ -64,20 +63,9 @@ function base(s::IndsNetwork)
return first(dims)
end

function ITensorNetworks.message(bp_cache::BeliefPropagationCache, edge::PartitionEdge)
mts = messages(bp_cache)
haskey(mts, edge) && return mts[edge]
return default_message(bp_cache, edge)
end

function ITensorNetworks.default_message_update(
contract_list::Vector{ITensor}; normalize=true, kwargs...
)
function unnormalized_message_update(contract_list::Vector{ITensor}; kwargs...)
sequence = optimal_contraction_sequence(contract_list)
updated_messages = contract(contract_list; sequence, kwargs...)
if normalize
updated_messages /= norm(updated_messages)
end
return ITensor[updated_messages]
end

Expand All @@ -98,7 +86,7 @@ function two_site_rdm(
pg = rem_vertex(pg, operator_vertex(ψIψ, v2))
ψIψ_bpc_mod = BeliefPropagationCache(pg, messages(ψIψ_bpc), default_message)
ψIψ_bpc_mod = update(
ψIψ_bpc_mod, path; message_update=ms -> default_message_update(ms; normalize=false)
ψIψ_bpc_mod, path; message_update=ms -> unnormalized_message_update(ms)
)
incoming_mts = environment(ψIψ_bpc_mod, [PartitionVertex(v2)])
local_state = factor(ψIψ_bpc_mod, PartitionVertex(v2))
Expand Down

0 comments on commit 3af1b08

Please sign in to comment.