Skip to content

Commit

Permalink
Update for the latest ITensors
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Mar 27, 2024
1 parent 0477e9d commit 6f11a2e
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 950 deletions.
5 changes: 1 addition & 4 deletions src/ITensorNetworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ using ITensors:
AbstractMPS,
Algorithm,
OneITensor,
check_hascommoninds,
commontags,
dim,
orthocenter,
ProjMPS,
set_nsite!
orthocenter
using KrylovKit: exponentiate, eigsolve, linsolve
using NamedGraphs:
AbstractNamedGraph,
Expand Down
19 changes: 0 additions & 19 deletions src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -803,25 +803,6 @@ function hascommoninds(
return true
end

function check_hascommoninds(
::typeof(siteinds), A::AbstractITensorNetwork{V}, B::AbstractITensorNetwork{V}
) where {V}
N = nv(A)
if nv(B) N
throw(
DimensionMismatch(
"$(typeof(A)) and $(typeof(B)) have mismatched number of vertices $N and $(nv(B))."
),
)
end
for v in vertices(A)
!hascommoninds(siteinds(A, v), siteinds(B, v)) && error(
"$(typeof(A)) A and $(typeof(B)) B must share site indices. On vertex $v, A has site indices $(siteinds(A, v)) while B has site indices $(siteinds(B, v)).",
)
end
return nothing
end

function hassameinds(
::typeof(siteinds), A::AbstractITensorNetwork{V}, B::AbstractITensorNetwork{V}
) where {V}
Expand Down
1 change: 0 additions & 1 deletion src/imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ import ITensors:
# permute
permute,
#commoninds
check_hascommoninds,
hascommoninds,
# linkdims
linkdim,
Expand Down
12 changes: 0 additions & 12 deletions src/solvers/alternating_update/alternating_update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ function alternating_update(
end

function alternating_update(operator::AbstractTTN, init_state::AbstractTTN; kwargs...)
check_hascommoninds(siteinds, operator, init_state)
check_hascommoninds(siteinds, operator, init_state')
# Permute the indices to have a better memory layout
# and minimize permutations
operator = ITensors.permute(operator, (linkind, siteinds, linkind))
Expand All @@ -106,8 +104,6 @@ end
function alternating_update(
operator::AbstractTTN, init_state::AbstractTTN, sweep_plans; kwargs...
)
check_hascommoninds(siteinds, operator, init_state)
check_hascommoninds(siteinds, operator, init_state')
# Permute the indices to have a better memory layout
# and minimize permutations
operator = ITensors.permute(operator, (linkind, siteinds, linkind))
Expand Down Expand Up @@ -138,10 +134,6 @@ Returns:
function alternating_update(
operators::Vector{<:AbstractTTN}, init_state::AbstractTTN; kwargs...
)
for operator in operators
check_hascommoninds(siteinds, operator, init_state)
check_hascommoninds(siteinds, operator, init_state')
end
operators .= ITensors.permute.(operators, Ref((linkind, siteinds, linkind)))
projected_operators = ProjTTNSum(operators)
return alternating_update(projected_operators, init_state; kwargs...)
Expand All @@ -150,10 +142,6 @@ end
function alternating_update(
operators::Vector{<:AbstractTTN}, init_state::AbstractTTN, sweep_plans; kwargs...
)
for operator in operators
check_hascommoninds(siteinds, operator, init_state)
check_hascommoninds(siteinds, operator, init_state')
end
operators .= ITensors.permute.(operators, Ref((linkind, siteinds, linkind)))
projected_operators = ProjTTNSum(operators)
return alternating_update(projected_operators, init_state, sweep_plans; kwargs...)
Expand Down
2 changes: 0 additions & 2 deletions src/solvers/contract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function sum_contract(
return typeof(tn2)([res])
end

# check_hascommoninds(siteinds, tn1, tn2)

# In case `tn1` and `tn2` have the same internal indices
operator = ProjOuterProdTTN{vertextype(first(tn1s))}[]
for (tn1, tn2) in zip(tn1s, tn2s)
Expand Down
12 changes: 0 additions & 12 deletions src/treetensornetworks/abstracttreetensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ function loginner(
end
ψ1dag = sim(dag(ψ1); sites=[])
traversal_order = reverse(post_order_dfs_vertices(ψ1, root_vertex))
check_hascommoninds(siteinds, ψ1dag, ψ2)

O = ψ1dag[root_vertex] * ψ2[root_vertex]

Expand Down Expand Up @@ -370,8 +369,6 @@ function inner(
y::AbstractTTN, A::AbstractTTN, x::AbstractTTN; root_vertex=default_root_vertex(x, A, y)
)
traversal_order = reverse(post_order_dfs_vertices(x, root_vertex))
check_hascommoninds(siteinds, A, x)
check_hascommoninds(siteinds, A, y)
ydag = sim(dag(y); sites=[])
x = sim(x; sites=[])
O = ydag[root_vertex] * A[root_vertex] * x[root_vertex]
Expand All @@ -397,15 +394,6 @@ function inner(
),
)
end
check_hascommoninds(siteinds, A, x)
check_hascommoninds(siteinds, B, y)
for v in vertices(B)
!hascommoninds(
uniqueinds(siteinds(A, v), siteinds(x, v)), uniqueinds(siteinds(B, v), siteinds(y, v))
) && error(
"$(typeof(x)) Ax and $(typeof(y)) By must share site indices. On site $v, Ax has site indices $(uniqueinds(siteinds(A, v), (siteinds(x, v)))) while By has site indices $(uniqueinds(siteinds(B, v), siteinds(y, v))).",
)
end
ydag = sim(linkinds, dag(y))
Bdag = sim(linkinds, dag(B))
traversal_order = reverse(post_order_dfs_vertices(x, root_vertex))
Expand Down
Loading

0 comments on commit 6f11a2e

Please sign in to comment.