Skip to content

Commit c79d473

Browse files
committed
Speed up Expect
1 parent 1346439 commit c79d473

File tree

4 files changed

+8
-29
lines changed

4 files changed

+8
-29
lines changed

src/Backend/abstractbeliefpropagationcache.jl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,6 @@ function update_iteration(
179179
return bpc
180180
end
181181

182-
"""
183-
Do parallel updates between groups of edges of all message tensors
184-
Currently we send the full message tensor data struct to update for each edge_group. But really we only need the
185-
mts relevant to that group.
186-
"""
187-
function update_iteration(
188-
alg::Algorithm"bp",
189-
bpc::AbstractBeliefPropagationCache,
190-
edge_groups::Vector{<:Vector{<:AbstractEdge}};
191-
(update_diff!) = nothing,
192-
)
193-
new_mts = empty(messages(bpc))
194-
for edges in edge_groups
195-
bpc_t = update_iteration(alg.kwargs.message_update_alg, bpc, edges; (update_diff!))
196-
for e in edges
197-
set!(new_mts, e, message(bpc_t, e))
198-
end
199-
end
200-
return set_messages(bpc, new_mts)
201-
end
202-
203182
"""
204183
More generic interface for update, with default params
205184
"""

src/expect.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function expect(
8484

8585
incoming_ms = incoming_messages(cache, steiner_vs)
8686
ψIψ_tensors = ITensor[norm_factors(network(cache), steiner_vs); incoming_ms]
87-
denom_seq = contraction_sequence(ψIψ_tensors; alg = "einexpr", optimizer = Greedy())
87+
denom_seq = contraction_sequence(ψIψ_tensors; alg = "optimal")
8888
denom = contract(ψIψ_tensors; sequence = denom_seq)[]
8989

9090
ψOψ_tensors = ITensor[norm_factors(network(cache), steiner_vs; op_strings = op_string_f); incoming_ms]
91-
numer_seq = contraction_sequence(ψOψ_tensors; alg = "einexpr", optimizer = Greedy())
91+
numer_seq = contraction_sequence(ψOψ_tensors; alg = "optimal")
9292
numer = contract(ψOψ_tensors; sequence = numer_seq)[]
9393

9494
return coeff * numer / denom
@@ -195,4 +195,4 @@ function boundarymps_partitioning(observable::Union{Tuple, Vector{<:Tuple}})
195195
end
196196
end
197197
return partitioning
198-
end
198+
end

src/symmetric_gauge.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,6 @@ end
136136
- The truncated `tns::TensorNetworkState`.
137137
"""
138138
function ITensors.truncate(tns::TensorNetworkState, args...; alg, kwargs...)
139-
algorithm_check(tns, alg)
139+
algorithm_check(tns, "truncate", alg)
140140
return truncate(Algorithm(alg), tns, args...; kwargs...)
141141
end

src/utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ function algorithm_check(tns::Union{AbstractBeliefPropagationCache, TensorNetwor
4343
return error("Expected BeliefPropagationCache or TensorNetworkState for 'loop correctiom' algorithm, got $(typeof(tns))")
4444
end
4545

46-
if f ["normalize", "expect", "entanglement", "sample"]
46+
if f ["normalize", "expect", "entanglement", "sample", "truncate"]
4747
return error("Loop correction-based contraction not supported for this functionality yet")
4848
end
4949
elseif alg == "boundarymps"
5050
if !((tns isa BoundaryMPSCache) || (tns isa TensorNetworkState))
5151
return error("Expected BoundaryMPSCache or TensorNetworkState for 'boundarymps' algorithm, got $(typeof(tns))")
5252
end
53-
if f ["normalize", "entanglement"]
53+
if f ["normalize", "entanglement", "truncate"]
5454
return error("boundarymps contraction not supported for this functionality yet")
5555
end
5656
elseif alg == "exact"
57-
if f ["normalize", "entanglement", "sample"]
57+
if f ["normalize", "entanglement", "sample", "truncate"]
5858
return error("exact contraction not supported for this functionality yet")
5959
end
6060
elseif alg ["exact", "bp", "loopcorrections", "boundarymps"]
@@ -66,4 +66,4 @@ end
6666

6767
default_alg(bp_cache::BeliefPropagationCache) = "bp"
6868
default_alg(bmps_cache::BoundaryMPSCache) = "boundarymps"
69-
default_alg(any) = error("You must specify a contraction algorithm. Currently supported: exact, bp and boundarymps.")
69+
default_alg(any) = error("You must specify a contraction algorithm. Currently supported: exact, bp and boundarymps.")

0 commit comments

Comments
 (0)