MPSKit.jl icon indicating copy to clipboard operation
MPSKit.jl copied to clipboard

IDMRG2 can error when the input state is not full rank

Open lkdvos opened this issue 1 year ago • 0 comments

When starting with an InfiniteMPS from tensors that are not full rank, the gauging algorithm does not necessarily lead to square CR tensors. If this happens at the edges of the unitcell, IDMRG2 fails because it takes an inverse of C which is not square.

julia> using MPSKit, TensorKit
julia> As = [MPSTensor(ℂ^2, ℂ^1, ℂ^3), MPSTensor(ℂ^2, ℂ^3, ℂ^4), MPSTensor(ℂ^2, ℂ^4, ℂ^1)];

julia> psi = InfiniteMPS(As)
3-site InfiniteMPS:
│   ⋮
│ CR[3]: TensorMap(ℂ^1 ← ℂ^1)
├── AL[3]: TensorMap((ℂ^4 ⊗ ℂ^2) ← ℂ^1)
├── AL[2]: TensorMap((ℂ^2 ⊗ ℂ^2) ← ℂ^4)
├── AL[1]: TensorMap((ℂ^1 ⊗ ℂ^2) ← ℂ^2)
│   ⋮


julia> space.(psi.CR)
3-element PeriodicArray{TensorMapSpace{ComplexSpace, 1, 1}, 1}:
 ℂ^2 ← ℂ^2
 ℂ^4 ← ℂ^2
 ℂ^1 ← ℂ^1

In general, there are many subtle problems for MPS tensors that aren't full rank, so I think we should both add an explicit check in the InfiniteMPS constructor that prohibits this, as well as provide a mechanism for creating full rank MPS tensors from non-full rank ones.

partial stack trace for completeness:

LoadError: SpaceMismatch("codomain ProductSpace(Vect[(FermionParity ⊠ Irrep[U₁] ⊠ Irrep[SU₂])]((0, 0, 0)=>16, (0, 4, 0)=>35, (0, -4, 0)=>1, (0, 8, 0)=>16, (0, 12, 0)=>1, (1, 2, 1/2)=>44, (1, -2, 1/2)=>8, (1, 6, 1/2)=>44, (1, 10, 1/2)=>8, (0, 0, 1)=>22, (0, 4, 1)=>51, (0, -4, 1)=>1, (0, 8, 1)=>22, (0, 12, 1)=>1, (1, 2, 3/2)=>28, (1, -2, 3/2)=>4, (1, 6, 3/2)=>28, (1, 10, 3/2)=>4, (0, 0, 2)=>6, (0, 4, 2)=>17, (0, 8, 2)=>6, (1, 2, 5/2)=>4, (1, 6, 5/2)=>4, (0, 4, 3)=>1)) and domain ProductSpace(Vect[(FermionParity ⊠ Irrep[U₁] ⊠ Irrep[SU₂])]((0, 0, 0)=>3, (0, 4, 0)=>1, (0, -4, 0)=>1, (1, 2, 1/2)=>2, (1, -2, 1/2)=>2, (0, 0, 1)=>1)) are not isomorphic: no inverse")
Stacktrace:
 [1] inv(t::TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 1, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}})
   @ TensorKit ~/.julia/packages/TensorKit/gpuAY/src/tensors/linalg.jl:268
 [2] find_groundstate(ost::InfiniteMPS{TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 1, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}}, H::MPOHamiltonian{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 2, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}}, ComplexF64}, alg::IDMRG2{KrylovKit.Arnoldi{KrylovKit.ModifiedGramSchmidt2, Float64}}, oenvs::MPSKit.MPOHamInfEnv{MPOHamiltonian{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 2, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}}, ComplexF64}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}, InfiniteMPS{TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 1, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}}, KrylovKit.GMRES{KrylovKit.ModifiedGramSchmidt2, Float64}})
   @ MPSKit ~/.julia/packages/MPSKit/JT8u6/src/algorithms/groundstate/idmrg.jl:116
 [3] find_groundstate(ost::InfiniteMPS{TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 1, 1, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 1, 0, 0, Nothing}}}, H::MPOHamiltonian{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, TensorMap{GradedSpace{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Int64}}, 2, 2, ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, TensorKit.SortedVectorDict{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, Matrix{ComplexF64}}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}, FusionTree{ProductSector{Tuple{FermionParity, U1Irrep, SU2Irrep}}, 2, 0, 1, Nothing}}, ComplexF64}, alg::IDMRG2{KrylovKit.Arnoldi{KrylovKit.ModifiedGramSchmidt2, Float64}})
   @ MPSKit ~/.julia/packages/MPSKit/JT8u6/src/algorithms/groundstate/idmrg.jl:85

lkdvos avatar Feb 20 '24 12:02 lkdvos