ITensor / ITensor/ITensorMPS.jl

[NDTensors] [BUG] Bug running DMRG on Metal with small cutoffs and large bond dimensions

Open
#87 0 comments 0 reactions 1 assignee View on GitHub

@kmp5VT is already working on this.

Since Nov 16, 2023.

bug
Dominant language
Julia
Stars
85
Forks
27
Avg merge
22m
Merged PRs (30d)
1

Description

using ITensors: MPO, OpSum, dmrg, random_mps, siteinds
using Metal: mtl
using Random: Random

function ham(n)
  os = OpSum()
  for j=1:n
    os += "Nup",j
    os += "Ndn",j
  end
  for j=1:n-1
    os += "Cdagup",j,"Cup",j+1
    os += "Cdagup",j+1,"Cup",j
    os += "Cdagdn",j,"Cdn",j+1
    os += "Cdagdn",j+1,"Cdn",j
  end
  return os
end

function main(; n, device, conserve_qns, nsweeps, maxdim)
  s = siteinds("Electron", n; conserve_nfparity=conserve_qns)
  Random.seed!(1234)
  ψ = device(random_mps(s, j -> isodd(j) ? "↑" : "↓"; linkdims=4))
  cutoff = [1e-3, 1e-13]
  outputlevel = 1
  H = device(MPO(ham(n), s))
  energy, ψ = dmrg(H, ψ; nsweeps, maxdim, cutoff, outputlevel)
end

Running either of these:

main(; device=mtl, conserve_qns=true, n=20, nsweeps=4, maxdim=200)
main(; device=mtl, conserve_qns=false, n=20, nsweeps=4, maxdim=200)

after some random small number of sweeps leads to the following error:

ERROR: operator does not appear to be hermitian: 0.0 vs NaN
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] expand!(iter::KrylovKit.LanczosIterator{ITensors.ProjMPO, ITensors.ITensor, KrylovKit.ModifiedGramSchmidt2}, state::KrylovKit.LanczosFactorization{ITensors.ITensor, Float32}; verbosity::Int64)
    @ KrylovKit ~/.julia/packages/KrylovKit/diNbc/src/factorizations/lanczos.jl:250
  [3] eigsolve(A::ITensors.ProjMPO, x₀::ITensors.ITensor, howmany::Int64, which::Symbol, alg::KrylovKit.Lanczos{KrylovKit.ModifiedGramSchmidt2, Float64})
    @ KrylovKit ~/.julia/packages/KrylovKit/diNbc/src/eigsolve/lanczos.jl:76
...

It doesn't seem to occur at smaller bond dimensions, and also is fixed by user a larger cutoff, i.e.

  cutoff = [1e-3, 1e-7]

so seems to be related to the condition number of the MPS.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.