Giter Club home page Giter Club logo

pepskit.jl's People

Contributors

daanmaertens avatar dependabot[bot] avatar github-actions[bot] avatar huangrzh avatar leburgel avatar lkdvos avatar maartenvd avatar pbrehmer avatar qmortier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pepskit.jl's Issues

Planar automatic differentiation.

I tried to use @lkdvos his new https://github.com/Jutho/TensorKit.jl/tree/ld/planar-ad to get the automatic derivative of the planar PEPS implementation but this seems to fail.

More specifically the /examples/fermionic.jl file fails to execute due to a space mismatch whilst calculating the derivative :
image

Please note that this is still with ComplexSpaces, the only fermionic part of the code is my usage of @planar and tau symbols.

Edit : my branch is at https://github.com/quantumghent/PEPSKit.jl/tree/planar_branch

My planar contractions currently lead to space mismatches.

In my first commit I managed to make the relevant diagrams planar trough the introduction of braiding symbols.

The resulting code however gives a spacemismatch on the contraction :

function northwest_corner(E4, C1, E1, peps_above, peps_below=peps_above)
    @planar opt=true corner[-1 -2 -3; -4 -5 -6] := 
        E4[-1 1 2; 3] *
        C1[3; 4] *
        E1[4 5 6; -4] *
        peps_above[21; 11 10 18 17] *
        conj(peps_below[21; 13 14 15 16])*
        τ[5 7;6 8]*τ[-5 9;-6 10]*τ[8 12;9 11]*τ[7 14;12 13]*τ[15 2;16 19]*τ[19 1;17 20]*τ[20 -2;18 -3]
end

The stack leads to this final function :

function planarcontract!(C::AbstractTensorMap{S,N₁,N₂},
                         A::BraidingTensor{S}   , (oindA, cindA)::Index2Tuple{2,2}, 
                         B::AbstractTensorMap{S}, (cindB, oindB)::Index2Tuple{2,N₃},
                         (p1, p2)::Index2Tuple{N₁,N₂},
                         α::Number, β::Number,
                         backend::Backend...) where {S,N₁,N₂,N₃}

which spits out :
ERROR: SpaceMismatch("(ℂ^1 ⊗ ℂ^1) ← ((ℂ^1)' ⊗ ℂ^1) ≠ permute(((ℂ^1)' ⊗ ℂ^1) ← (ℂ^1 ⊗ (ℂ^1)')[(2, 4), (1, 3)] * (ℂ^1 ⊗ ℂ^1 ⊗ (ℂ^1)') ← ℂ^1[(2, 3), (1, 4)], ((1, 2), (3, 4))")
Stacktrace:

I suspect that the origin of this bug is a mislabeling of my tau indices but I dont know which is the appropriate labeling.
@Jutho ?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Gauge fixing for nontrivial symmetries and unit cells

I was trying out the new updates on a model with $\mathbb{Z}_2$ symmetry and a $2 \times 2$ unit cell as a test, and I ran into some issues with the gauge fixing.

Unit cells should be fine in principle, but in the current implementation this can give some space mismatches when the edge tensor spaces aren't the same for every site, I think due to this line
https://github.com/quantumghent/PEPSKit.jl/blob/a24ac36321dfbccb0e1e12b3eb9378411f0a4ab5/src/algorithms/ctmrg.jl#L95
not taking into account the site dependence, which is easily fixed.

Symmetries are bit more tricky, since there's two steps where the block structure isn't taken into account,
https://github.com/quantumghent/PEPSKit.jl/blob/a24ac36321dfbccb0e1e12b3eb9378411f0a4ab5/src/algorithms/ctmrg.jl#L82-L83
and
https://github.com/quantumghent/PEPSKit.jl/blob/a24ac36321dfbccb0e1e12b3eb9378411f0a4ab5/src/algorithms/ctmrg.jl#L93-L95
For the first one, projecting out one specific configuration of physical indices isn't very natural in the presence of symmetries. We could just do it, but I'm not sure if this is then still what we want. The second one seems more involved, mainly because I'm not sure what's happening exactly. Just trying the closest block-diagonal analogue to what's there breaks the $\mathbb{Z}_2$ version of the test_gauge_fixing.jl test, so I didn't manage to patch it without understanding it.

Probably the case of symmetries just requires the use of a different gauge-fixing procedures, but just wanted to point this out in case there's a quick fix after all. Any thoughts @pbrehmer, @lkdvos?

Infinite error during CTMRG.

I'm trying to to run PEPSKit for the pi-flux model (which lives on a 2 by 2 unit cell with fermions) and I'm bumping into some issues. More specifically leading_boundary(CTMRGEnv(state, χ), state, ctm_alg); gives me an infinite error for all except the first iteration.

A MWE ( which doesn't even care about the Hamiltonian yet) is :

using Revise
using TensorKit, PEPSKit, KrylovKit, OptimKit
########################################
#Define the symmetry gorup of the model#
########################################
sym = (SU2Irrep  U1Irrep  FermionParity);  #mixing colors * PN_conservation * it's fermions
#define some elementary IRREPS of this symmetry group.
empty  = sym.(0   ,0,0);  #empty empty
single = sym.(1//2,1,1);  #full empty + empty full
double = sym.(0   ,2,0);  #full full
#define the physical Hilbert space of this model :
ph = Vect[sym](empty => 1, single => 1, double => 1);
    
#############
#Find the GS#
#############
#define IC
D = Vect[sym](empty => 1, single=>1, double=>1)  #intial space of PEPS
intitial_tensors = [TensorMap(rand, ComplexF64, ph, D*D'*D'*D)  TensorMap(rand, ComplexF64, ph, D*D'*D'*D) ;
                    TensorMap(rand, ComplexF64, ph, D*D'*D'*D)  TensorMap(rand, ComplexF64, ph, D*D'*D'*D) ]  ;
initial_state = InfinitePEPS(intitial_tensors);

#Define the GS_search algorithm 
χ = Vect[sym](empty => 3, single=>3, double=>3)  #intial space of the boundary MPS
χ_max = 20                                       #maximal bond dimension of the boundary MPS
ctm_alg = CTMRG(; tol=1e-10, miniter=4, maxiter=100, verbosity=3, trscheme=truncdim( χ_max )); #verbosity can be lowered if you want less output.

#use the above to actually get the GS
state = initial_state
environments = leading_boundary(CTMRGEnv(state, χ), state, ctm_alg);  #initial boundaries

I also ran the same code with sym = (SU2Irrep ⊠ U1Irrep ⊠ Z2Irrep) which produces the same error. Therefore I suspect the issue doesn't sit with the fermionic reps.

Error after unconverged KrylovKit.GMRES linear solve

It seems that on the newest version KrylovKit something broke: If we compute the fixed-point gradient fpgrad using KrylovKit.GMRES and it doesn't converge, I get the following conversion error:

ERROR: MethodError: Cannot `convert` an object of type
  CTMRGEnv{TensorMap{ComplexSpace,1,1,Trivial,Array{Complex{Float64},2},Nothing,Nothing},TensorMap{ComplexSpace,1,1,Trivial,Array{Complex{Float64},2},Nothing,Nothing}} to an object of type
  CTMRGEnv{TensorMap{ComplexSpace,1,1,Trivial,Array{Complex{Float64},2},Nothing,Nothing},TensorMap{ComplexSpace,3,1,Trivial,Array{Complex{Float64},2},Nothing,Nothing}}

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  (::Type{CTMRGEnv{C, T}} where {C, T})(::Any, ::Any)
   @ PEPSKit ~/repos/PEPSKit.jl/src/environments/ctmrgenv.jl:7

Stacktrace:
  [1] setindex!(A::Vector{CTMRGEnv{…}}, x::CTMRGEnv{TrivialTensorMap{…}, TrivialTensorMap{…}}, i1::Int64)
    @ Base ./array.jl:1021
  [2] setindex!(b::KrylovKit.OrthonormalBasis{CTMRGEnv{…}}, i::CTMRGEnv{TrivialTensorMap{…}, TrivialTensorMap{…}}, q::Int64)
    @ KrylovKit ~/.julia/packages/KrylovKit/wPepJ/src/orthonormal.jl:42
  [3] _rmul!(b::KrylovKit.OrthonormalBasis{CTMRGEnv{…}}, G::LinearAlgebra.Givens{ComplexF64})
    @ KrylovKit ~/.julia/packages/KrylovKit/wPepJ/src/dense/givens.jl:34
  [4] rmul!(b::KrylovKit.OrthonormalBasis{CTMRGEnv{…}}, G::LinearAlgebra.Givens{ComplexF64})
    @ KrylovKit ~/.julia/packages/KrylovKit/wPepJ/src/dense/givens.jl:16
  [5] linsolve(operator::Function, b::CTMRGEnv{…}, x₀::CTMRGEnv{…}, alg::GMRES{…}, a₀::Int64, a₁::Int64)
    @ KrylovKit ~/.julia/packages/KrylovKit/wPepJ/src/linsolve/gmres.jl:114
  [6] fpgrad(∂F∂x::CTMRGEnv{…}, ∂f∂x::Function, ∂f∂A::PEPSKit.var"#∂f∂A#174"{}, y₀::CTMRGEnv{…}, alg::GMRES{…})
    @ PEPSKit ~/repos/PEPSKit.jl/src/algorithms/peps_opt.jl:201
  [7] (::PEPSKit.var"#leading_boundary_pullback#172"{})(Δenvs′::CTMRGEnv{…})
    @ PEPSKit ~/repos/PEPSKit.jl/src/algorithms/peps_opt.jl:128
  [8] #28
    @ ~/repos/PEPSKit.jl/src/utility/hook_pullback.jl:34 [inlined]
  [9] ZBack
    @ ~/.julia/packages/Zygote/nsBv0/src/compiler/chainrules.jl:211 [inlined]
 [10] (::Zygote.var"#kw_zpullback#53"{PEPSKit.var"#28#29"{}})(dy::CTMRGEnv{TrivialTensorMap{…}, TrivialTensorMap{…}})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/chainrules.jl:237
 [11] #2
    @ ~/repos/PEPSKit.jl/test/ctmrg/gradients.jl:63 [inlined]
 [12] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface2.jl:0
 [13] (::Zygote.var"#75#76"{Zygote.Pullback{Tuple{}, Tuple{}}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:91
 [14] withgradient(f::Function, args::InfinitePEPS{TrivialTensorMap{ComplexSpace, 1, 4, Matrix{ComplexF64}}})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:213
 [15] compute_grad(peps::InfinitePEPS{…}, envs::CTMRGEnv{…}, boundary_alg::CTMRG, alg_rrule::GMRES{…})
    @ Main ~/repos/PEPSKit.jl/test/ctmrg/gradients.jl:62
 [16] top-level scope
    @ ~/repos/PEPSKit.jl/test/ctmrg/gradients.jl:70

It turns out that this only happens on the newest version v0.7.1, whereas on the previous version v0.6.1 this was not a problem. For comparison, I currently use the following package versions:

(PEPSKit) pkg> status
Project PEPSKit v0.1.0
Status `~/repos/PEPSKit.jl/Project.toml`
  [7d9f7c33] Accessors v0.1.36
  [d360d2e6] ChainRulesCore v1.24.0
  [34da2185] Compat v4.15.0
  [0b1a1467] KrylovKit v0.7.1
  [bb1c41ca] MPSKit v0.10.2 `https://github.com/maartenvd/MPSKit.jl.git#master`
  [77e91f04] OptimKit v0.3.1
  [07d1fe3e] TensorKit v0.12.4
  [409d34a3] VectorInterface v0.4.5
  [e88e6eb3] Zygote v0.6.70
  [37e2e46d] LinearAlgebra
  [de0858da] Printf
  [9a3f8284] Random
  [10745b16] Statistics v1.10.0

Note that I added the master branch of MPSKit to resolve the KrylovKit dependency conflict. Here's a MWE that should reproduce the error where I intentionally prevent the linear solver from converging:

using Random
using PEPSKit
using TensorKit
using Zygote
using KrylovKit

Random.seed!(42039482038)
χbond = 2
χenv = 8
boundary_alg = CTMRG(;
    trscheme=truncdim(χenv), tol=1e-10, miniter=20, maxiter=100, verbosity=1
)
psi = InfinitePEPS(2, χbond)
env = leading_boundary(CTMRGEnv(psi; Venv=^χenv), psi, boundary_alg)

function compute_grad(peps, envs, boundary_alg, alg_rrule)
    E, g = Zygote.withgradient(peps) do psi
        envs2 = PEPSKit.hook_pullback(leading_boundary, envs, psi, boundary_alg; alg_rrule)
        return costfun(psi, envs2, H)
    end
    return only(g)
end

g = compute_grad(psi, env, boundary_alg, KrylovKit.GMRES(; tol=1e-16, maxiter=2, verbosity=3))

Maybe @lkdvos knows what's going on here?

Warning: svd cotangents sensitive to gauge choice

Hi,

I am running a 2×2 unit cell Heisenberg model and repeatedly receive the following warning:
┌ Warning: svd cotangents sensitive to gauge choice: (|Δgauge| = 1.0548972842168783e-8) └ @ TensorKitChainRulesCoreExt C:\Users\dgj\.julia\packages\TensorKit\Fz2UW\ext\TensorKitChainRulesCoreExt\factorizations.jl:257.
Could you please provide guidance on how to address or mitigate this issue? Any suggestions for changes or improvements in the code or parameters that could help avoid this warning would be greatly appreciated.
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.