Skip to content

Commit

Permalink
Comment out HalfInfiniteEnv SVD test
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrehmer committed Oct 25, 2024
1 parent bb4af77 commit 899b10b
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions test/ctmrg/svd_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using KrylovKit
using ChainRulesCore, Zygote
using Accessors
using PEPSKit
using PEPSKit: HalfInfiniteEnv
# using PEPSKit: HalfInfiniteEnv

# Gauge-invariant loss function
function lossfun(A, alg, R=TensorMap(randn, space(A)), trunc=notrunc())
Expand Down Expand Up @@ -94,47 +94,47 @@ symm_R = TensorMap(randn, dtype, space(symm_r))
@test g_fullsvd_tr[1] g_itersvd_fb[1] rtol = rtol
end

χbond = 2
χenv = 6
ctm_alg = CTMRG(; tol=1e-10, verbosity=2, svd_alg=SVDAdjoint())
Random.seed!(91283219347)
H = heisenberg_XYZ(InfiniteSquare())
psi = InfinitePEPS(2, χbond)
env = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg);
hienv = HalfInfiniteEnv(
env.corners[1],
env.corners[2],
env.edges[4],
env.edges[1],
env.edges[1],
env.edges[2],
psi[1],
psi[1],
psi[1],
psi[1],
)
hienv_dense = hienv()
env_R = TensorMap(randn, space(hienv))

PEPSKit.tsvd!(hienv, iter_alg) # TODO: make the space mismatches work

@testset "IterSVD with HalfInfiniteEnv function handle" begin
# Equivalence of dense and sparse contractions
x₀ = PEPSKit.random_start_vector(hienv)
x′ = hienv(x₀, Val(false))
x″ = hienv(x, Val(true))
x‴ = hienv(x, Val(false))

a = hienv_dense * x₀
b = hienv_dense' * a
c = hienv_dense * b
@test a x′
@test b x
@test c x

# TODO: code up pullback
# l_fullsvd, g_fullsvd = withgradient(A -> lossfun(A, full_alg, env_R), hienv_dense)
# l_itersvd, g_itersvd = withgradient(A -> lossfun(A, iter_alg, env_R), hienv)
# @test l_itersvd ≈ l_fullsvd
# @test g_fullsvd[1] ≈ g_itersvd[1] rtol = rtol
end
# TODO: Add when IterSVD is implemented for HalfInfiniteEnv
# χbond = 2
# χenv = 6
# ctm_alg = CTMRG(; tol=1e-10, verbosity=2, svd_alg=SVDAdjoint())
# Random.seed!(91283219347)
# H = heisenberg_XYZ(InfiniteSquare())
# psi = InfinitePEPS(2, χbond)
# env = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg);
# hienv = HalfInfiniteEnv(
# env.corners[1],
# env.corners[2],
# env.edges[4],
# env.edges[1],
# env.edges[1],
# env.edges[2],
# psi[1],
# psi[1],
# psi[1],
# psi[1],
# )
# hienv_dense = hienv()
# env_R = TensorMap(randn, space(hienv))

# PEPSKit.tsvd!(hienv, iter_alg)

# @testset "IterSVD with HalfInfiniteEnv function handle" begin
# # Equivalence of dense and sparse contractions
# x₀ = PEPSKit.random_start_vector(hienv)
# x′ = hienv(x, Val(false))
# x″ = hienv(x, Val(true))
# x‴ = hienv(x″, Val(false))

# a = hienv_dense * x₀
# b = hienv_dense' * a
# c = hienv_dense * b
# @test a ≈ x
# @test b ≈ x
# @test c ≈ x‴

# # l_fullsvd, g_fullsvd = withgradient(A -> lossfun(A, full_alg, env_R), hienv_dense)
# # l_itersvd, g_itersvd = withgradient(A -> lossfun(A, iter_alg, env_R), hienv)
# # @test l_itersvd ≈ l_fullsvd
# # @test g_fullsvd[1] ≈ g_itersvd[1] rtol = rtol
# end

0 comments on commit 899b10b

Please sign in to comment.