Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ Random = "1"
Statistics = "1"
TensorKit = "0.17.4"
TensorKitTensors = "0.3.1"
TensorOperations = "5.8.1"
TensorOperations = "5.8.4"
TupleTools = "1.6.0"
VectorInterface = "0.4, 0.5, 0.6, 0.7"
Zygote = "0.6, 0.7"
julia = "1.10"

[sources]
TensorKit = {url = "https://github.com/QuantumKitHub/TensorKit.jl/", rev = "ksh/normalize_rrule"}
2 changes: 1 addition & 1 deletion ext/PEPSKitGPUArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const GPUTensorMap = TensorMap{<:LinearAlgebra.BlasFloat, <:Any, <:Any, <:Any, <
_offsets(S::TensorKit.SectorDict) = Int32.(first.(values(S)))
_offsets(S::AbstractDict) = sort!(Int32.(first.(values(S))))
function PEPSKit.corner_spectrum(C::GPUTensorMap, ::PEPSKit.C4vCTMRG)
S = eigh_vals(C, MatrixAlgebraKit.default_algorithm(eigh_vals!, C; check_hermiticity = false))
S = eigh_vals(C, MAK.default_algorithm(eigh_vals!, C; check_hermiticity = false))
x = parent(S)
isempty(x) && return S
m = reduce(_maxabs_signed, x; dims = 1, init = zero(eltype(x)))
Expand Down
53 changes: 29 additions & 24 deletions src/algorithms/contractions/ctmrg/characteristic_equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const RightProjectors{TP} = Array{TP, 3} where {TP <: RightProjector}

# north edge and its left projector
function contract_EnVd(
En::EdgeTensor{S, 3}, Vd::LeftProjector{S, 3}, O::PEPSSandwich
En::EdgeTensor{S, 3}, Vd::LeftProjector{S, 3}, O::PEPSSandwich, allocator
) where {S}
@autoopt @tensor EnVd[χ_NNW D_W_a D_W_b D_S_a D_S_b; χ_E] :=
@autoopt @tensor allocator = allocator EnVd[χ_NNW D_W_a D_W_b D_S_a D_S_b; χ_E] :=
Vd[χ_NNE D_E_a D_E_b; χ_E] *
En[χ_NNW D_N_a D_N_b; χ_NNE] *
ket(O)[d; D_N_a D_E_a D_S_a D_W_a] *
Expand All @@ -32,8 +32,8 @@ function contract_EnVd(
end

# northwest enlarged corner with its left projector
function contract_EwCEnVd(Ew::EdgeTensor{S, 3}, C::CornerTensor{S}, EnVd::LeftProjector{S, 5}) where {S}
@autoopt @tensor EwCEnVd[χ_WSW D_S_a D_S_b; χ_E] :=
function contract_EwCEnVd(Ew::EdgeTensor{S, 3}, C::CornerTensor{S}, EnVd::LeftProjector{S, 5}, allocator) where {S}
@autoopt @tensor allocator = allocator EwCEnVd[χ_WSW D_S_a D_S_b; χ_E] :=
Ew[χ_WSW D_W_a D_W_b; χ_WNW] *
C[χ_WNW; χ_NNW] *
EnVd[χ_NNW D_W_a D_W_b D_S_a D_S_b; χ_E]
Expand All @@ -42,8 +42,8 @@ end

# north edge renormalization
# NOTE: will need to be rewritten in terms of tensor multiplication for (future) fermion support
function contract_E´(Ud::RightProjector{S, 3}, EnVd::LeftProjector{S, 5}) where {S}
@tensor E´[-1 -2 -3; -4] := Ud[-1; 1 2 3] * EnVd[1 2 3 -2 -3; -4]
function contract_E´(Ud::RightProjector{S, 3}, EnVd::LeftProjector{S, 5}, allocator) where {S}
@tensor allocator = allocator E´[-1 -2 -3; -4] := Ud[-1; 1 2 3] * EnVd[1 2 3 -2 -3; -4]
return E´
end

Expand Down Expand Up @@ -102,7 +102,8 @@ function generate_symmetric_characteristic_equation(
Cfp::CornerTensor,
Efp::EdgeTensor, # unused
Ufp::LeftProjector,
ULfp::LeftProjector;
ULfp::LeftProjector,
allocator;
projector_alg,
getsite = getindex,
)
Expand All @@ -127,8 +128,8 @@ function generate_symmetric_characteristic_equation(

# evaluate partial contractions to reuse
# north edge and its left projector
EnVd = contract_EnVd(E, U, O)
EwCEnVd = contract_EwCEnVd(Ep, C, EnVd)
EnVd = contract_EnVd(E, U, O, allocator)
EwCEnVd = contract_EwCEnVd(Ep, C, EnVd, allocator)

# F1: corner
C´ = Ud * EwCEnVd
Expand All @@ -137,7 +138,7 @@ function generate_symmetric_characteristic_equation(
F1 = C´ / λ_C - C

# F2: edge
E´ = contract_E´(Ud, EnVd)
E´ = contract_E´(Ud, EnVd, allocator)
E´ = _project_hermitian(E´) # project output
λ_E = dot(E, E´)
F2 = E´ / λ_E - E
Expand Down Expand Up @@ -354,9 +355,9 @@ end
# --------------------

function contract_EPL(
E::EdgeTensor{S, 3}, PL::LeftProjector{S, 3}, O::PEPSSandwich,
E::EdgeTensor{S, 3}, PL::LeftProjector{S, 3}, O::PEPSSandwich, allocator
) where {S}
@autoopt @tensor eipl[χ_W D_W_above D_W_below D_S_above D_S_below; χ_S] :=
@autoopt @tensor allocator = allocator eipl[χ_W D_W_above D_W_below D_S_above D_S_below; χ_S] :=
PL[χ_N D_E_above D_E_below; χ_S] *
E[χ_W D_N_above D_N_below; χ_N] *
ket(O)[d; D_N_above D_E_above D_S_above D_W_above] *
Expand All @@ -365,18 +366,18 @@ function contract_EPL(
end

function contract_EiCiEPL(
EiCi::EdgeTensor{S, 3}, EPL::LeftProjector{S, 5},
EiCi::EdgeTensor{S, 3}, EPL::LeftProjector{S, 5}, allocator
) where {S}
@tensor ecepl[-1 -2 -3; -4] :=
@tensor allocator = allocator ecepl[-1 -2 -3; -4] :=
EPL[1 2 3 -2 -3; -4] *
EiCi[-1 2 3; 1]
return ecepl
end

function contract_PREPL(
PR::RightProjector{S, 3}, EPL::LeftProjector{S, 5},
PR::RightProjector{S, 3}, EPL::LeftProjector{S, 5}, allocator
) where {S}
@tensor E´[-1 -2 -3; -4] :=
@tensor allocator = allocator E´[-1 -2 -3; -4] :=
PR[-1; 1 2 3] * EPL[1 2 3 -2 -3; -4]
return E´
end
Expand Down Expand Up @@ -404,7 +405,8 @@ function contract_halfinfinite_characteristic_equation(
Ud::RightProjectors, Vd::LeftProjectors,
iCi::CornerTensors,
proj_u, proj_v,
iSfp::CornerTensors;
iSfp::CornerTensors,
allocator;
getsite = getindex,
)
coordinates = eachcoordinate(n, 1:4)
Expand All @@ -417,7 +419,7 @@ function contract_halfinfinite_characteristic_equation(
end
envi = CTMRGEnv(iCi, E)
EC = map(coordinates) do co
return TensorMap(_enlarged_corner(n, envi, co; getsite))
return TensorMap(_enlarged_corner(n, envi, co; getsite), allocator)
end
PR = map(coordinates) do co
co′ = _proj_sinv_indices(co, nrows, ncols)
Expand All @@ -440,12 +442,12 @@ function contract_halfinfinite_characteristic_equation(
end
# pre-contract the top edge and its sandwich into the left projector
EPL = map(coordinates) do co
return contract_EPL(E[_above(co, nrows, ncols)...], PL[co...], Or[co...])
return contract_EPL(E[_above(co, nrows, ncols)...], PL[co...], Or[co...], allocator)
end
# pre-contract the top-left corner and left edge into the previous to complete the
# top-left enlarged corner
EiCiEPL = map(coordinates) do co
return contract_EiCiEPL(EiCi[co...], EPL[co...])
return contract_EiCiEPL(EiCi[co...], EPL[co...], allocator)
end

# corners
Expand All @@ -458,7 +460,7 @@ function contract_halfinfinite_characteristic_equation(

# edges
F2 = map(coordinates) do co
E´ = contract_PREPL(PR[_left_projector(co, nrows, ncols)...], EPL[co...])
E´ = contract_PREPL(PR[_left_projector(co, nrows, ncols)...], EPL[co...], allocator)
λ_E = dot(E[co...], E´)
return E´ / λ_E - E[co...]
end
Expand Down Expand Up @@ -491,7 +493,8 @@ end
::CTMRGAlgorithm{<:HalfInfiniteProjector},
iSfp::CornerTensors,
Ufp::LeftProjectors,
Vfp::RightProjectors;
Vfp::RightProjectors,
allocator;
getsite = getindex,
)

Expand Down Expand Up @@ -529,7 +532,8 @@ are differentiated at all; see [`PEPSKit.constant_site`](@ref).
function generate_halfinfinite_characteristic_equation(
iSfp::CornerTensors,
Ufp::LeftProjectors,
Vfp::RightProjectors;
Vfp::RightProjectors,
allocator;
getsite = getindex,
)

Expand Down Expand Up @@ -594,7 +598,8 @@ function generate_halfinfinite_characteristic_equation(
Ud, Vd,
iCi,
proj_u, proj_v,
iSfp;
iSfp,
allocator;
getsite,
)

Expand Down
Loading
Loading