Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mtfishman opened this issue Nov 16, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mtfishman
Copy link
Member

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

function ham(n)
  os = OpSum()
  for j=1:n
    os += 1.0,"Nup",j
    os += 1.0,"Ndn",j
  end
  for j=1:n-1
    os += 1.0,"Cdagup",j,"Cup",j+1
    os += 1.0,"Cdagup",j+1,"Cup",j
    os += 1.0,"Cdagdn",j,"Cdn",j+1
    os += 1.0,"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(randomMPS(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.

@mtfishman mtfishman added the bug Something isn't working label Nov 16, 2023
@mtfishman mtfishman changed the title [NDTensors] [BUG] Bug running DMRG on Metal [NDTensors] [BUG] Bug running DMRG on Metal with small cutoffs and large bond dimensions Nov 16, 2023
@kmp5VT kmp5VT self-assigned this Nov 16, 2023
@mtfishman mtfishman transferred this issue from ITensor/ITensors.jl Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants