ITensor / ITensor/ITensorMPS.jl

[ITensors] [BUG] QN error when applying MPO to MPS

Open
#72 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description of bug

When applying certain MPOs to MPS, there is an error coming from eigen from within the apply(::MPO,::MPS) function. It seems to only happen when:

  1. the MPO has non-trivial flux
  2. the MPS has a bond dimension of 1

Looking into it some more, it could actually be a problem with randomMPS (and a similar problem occurring with productMPS), which is that the link indices seem to have the wrong quantum numbers in the case of making a product state. See below for the product state I made.

Minimal code demonstrating the bug or unexpected behavior

using ITensors

let
  N = 4
  s = siteinds("Boson",N; conserve_qns=true)

  terms = OpSum()
  terms += "Adag",3
  W = MPO(terms,s)

  psi = randomMPS(s,[isodd(n) ? "1" : "0" for n=1:N]; linkdims=1)
  @show psi

  Wpsi = apply(W,psi)
  @show norm(Wpsi)

  return
end

Actual output or behavior

Output of minimal runnable code

ERROR: LoadError: AssertionError: flux(A) == QN()
Stacktrace:
  [1] macro expansion
    @ ~/.julia/dev/ITensors/src/decomp.jl:229 [inlined]
  [2] macro expansion
    @ ~/.julia/dev/ITensors/src/global_variables.jl:177 [inlined]
  [3] eigen(A::ITensor, Linds::Vector{Index{Vector{Pair{QN, Int64}}}}, Rinds::Vector{Index{Vector{Pair{QN, Int64}}}}; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:ishermitian, :tags), Tuple{Bool, TagSet}}})
    @ ITensors ~/.julia/dev/ITensors/src/decomp.jl:227
  [4] contract(::ITensors.Algorithm{:densitymatrix}, A::MPO, ψ::MPS; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ITensors ~/.julia/dev/ITensors/src/mps/mpo.jl:631
  [5] contract
    @ ~/.julia/dev/ITensors/src/mps/mpo.jl:587 [inlined]
  [6] contract(A::MPO, ψ::MPS; alg::String, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ITensors ~/.julia/dev/ITensors/src/mps/mpo.jl:531
  [7] contract
    @ ~/.julia/dev/ITensors/src/mps/mpo.jl:516 [inlined]
  [8] #apply#922
    @ ~/.julia/dev/ITensors/src/mps/mpo.jl:507 [inlined]
  [9] product(A::MPO, ψ::MPS)
    @ ITensors ~/.julia/dev/ITensors/src/mps/mpo.jl:507
 [10] top-level scope
    @ ~/software/troubleshooting/miles/ampo_redesign/apply_bug.jl:14
 [11] include(fname::String)
    @ Base.MainInclude ./client.jl:451
 [12] top-level scope
    @ REPL[4]:1
in expression starting at /Users/mstoudenmire/software/troubleshooting/miles/ampo_redesign/apply_bug.jl:3

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, westmere)
Environment:
  JULIA_DIR = /Applications/Julia-1.7.app/Contents/Resources/julia

Using latest development branch of ITensors.jl

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.

Research direction

Start by running the minimal Julia example and trace apply(::MPO,::MPS) through src/mps/mpo.jl, then inspect eigen in src/decomp.jl. Compare the link-index quantum numbers produced by randomMPS and productMPS for bond dimension 1 and non-trivial flux. Done means the example completes without the flux assertion and the resulting MPS has consistent quantum numbers.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.