ITensor / ITensor/ITensorMPS.jl

[BUG] write_when_maxdim_exceeds not working for excited state dmrg calculation

Open
#145 0 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

I seem to be running into a bug regarding "write_when_maxdim_exceeds" when calculating excited states using dmrg. This seems to be a similar bug other people have posted about for other solvers, but I was hoping since "write_when_maxdim_exceeds" works for the ground state dmrg calculation, it may be easily fixed for the subsequent excited state calculations.

Let me know if there is a known work around.

Minimal code demonstrating the bug or unexpected behavior

Minimal runnable code

using ITensors, ITensorMPS

let
  N = 100
  sites = siteinds("S=1",N)

  os = OpSum()
  for j=1:N-1
    os += 0.5,"S+",j,"S-",j+1
    os += 0.5,"S-",j,"S+",j+1
    os += "Sz",j,"Sz",j+1
  end
  H = MPO(os,sites)

  nsweeps = 5 # number of sweeps is 5
  maxdim = [10,20,100,100,200] # gradually increase states kept
  cutoff = [1E-10] # desired truncation error

  psi0 = random_mps(sites;linkdims=2)

  energy,psi = dmrg(H,psi0;nsweeps,maxdim,cutoff, write_when_maxdim_exceeds=1)

  energy2, psi2 = dmrg(H,[psi], psi0;nsweeps,maxdim,cutoff, write_when_maxdim_exceeds=1)

  return
end

Expected output or behavior

I guess I expect the 2nd dmrg calculation done for the first excited state to be able to save to disk.

Actual output or behavior

I get the following error once the 2nd dmrg sweeps start

Output of minimal runnable code

ERROR: LoadError: MethodError: no method matching disk(::ProjMPO_MPS; path::String)
The function `disk` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  disk(::ProjMPO; kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\diskprojmpo.jl:69
  disk(::ITensorMPS.DiskProjMPO; kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\diskprojmpo.jl:82
  disk(::ITensorMPS.AbstractSum; disk_kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\projmposum.jl:118
  ...

Stacktrace:
 [1] dmrg(PH::ProjMPO_MPS, psi0::MPS, sweeps::Sweeps; which_decomp::Nothing, svd_alg::Nothing, observer::NoObserver, outputlevel::Int64, write_when_maxdim_exceeds::Int64, write_path::String, eigsolve_tol::Float64, eigsolve_krylovdim::Int64, eigsolve_maxiter::Int64, eigsolve_verbosity::Int64, eigsolve_which_eigenvalue::Symbol, ishermitian::Bool)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:199
 [2] dmrg
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:158 [inlined]
 [3] dmrg(H::MPO, Ms::Vector{MPS}, psi0::MPS, sweeps::Sweeps; weight::Bool, kwargs::@Kwargs{outputlevel::Int64, write_when_maxdim_exceeds::Int64})
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:55
 [4] dmrg
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:41 [inlined]
 [5] #dmrg#518
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:374 [inlined]
 [6] top-level scope
   @ C:\Users\395642\Documents\julia\save_to_disk_test.jl:23
in expression starting at C:\Users\395642\Documents\julia\save_to_disk_test.jl:3

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13950HX
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)
  • Output from using Pkg; Pkg.status("ITensorMPS"):
julia> using Pkg; Pkg.status("ITensorMPS")
Status `C:\Users\395642\.julia\environments\v1.11\Project.toml`
  [0d1a4710] ITensorMPS v0.3.18

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

Reproduce the minimal Julia example, then read src/dmrg.jl around line 199 and the disk methods in src/abstractprojmpo/diskprojmpo.jl. Trace the excited-state dmrg path that receives ProjMPO_MPS and compare it with the working ground-state path. Done means the excited-state calculation can use write_when_maxdim_exceeds without the reported MethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.