jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
484 stars 108 forks source link

Using tensor_dmrg with SLEPC is causing an issue #199

Closed ElHirad closed 1 year ago

ElHirad commented 1 year ago

What is your issue?

I'm running quimb to solve a DMRG problem. When I use SLEPC backend, this error appears:

File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/base_linalg.py", line 148, in eigensystem_partial
    return _EIGS_METHODS[bkd](A, **settings, **backend_opts)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/mpi_launcher.py", line 322, in __call__
    return self.fn(*args, comm_self=True, **kwargs)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/mpi_launcher.py", line 267, in __call__
    res = self.fn(*args, comm=comm, **kwargs)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/slepc_linalg.py", line 551, in eigs_slepc
    raise RuntimeError("SLEPC eigs did not find enough eigenpairs, "
RuntimeError: SLEPC eigs did not find enough eigenpairs, wanted: 1, found: 0.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fluids_main_FPKD_dmrg.ipy", line 105, in <module>
    p_mps, costs = proloSolveDmrgFP(NK-3)
  File "fluids_main_FPKD_dmrg.ipy", line 47, in proloSolveDmrgFP
    uu_ket_var, costs_update = ffpg.solveDmrgFP(v_mps, Hams, K= K_phi, Nt = Nt_temp, split = split,
  File "/home/hirad/Desktop/Nik_Work/SpaceTimeFPKD-DMRG/FokkerPlanck/fluids_FokkerPlanckGeneral.py", line 59, in solveDmrgFP
    dmrg.solve(tol=eps_DMRG, max_sweeps=maxSweeps, bond_dims=chi, cutoffs=eps_DMRG/2, sweep_sequence ="RL", verbosity=2) #local
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 1043, in solve
    self.energies.append(self.sweep(direction=LR, **sweep_opts))
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 914, in sweep
    local_ens, tot_ens = zip(*[
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 915, in <listcomp>
    self._update_local_state(i, direction=direction, **update_opts)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 838, in _update_local_state
    return {
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 797, in _update_local_state_2site
    loc_en, loc_gs = self._eigs(Heff, B=Neff, v0=loc_gs_old)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/tensor/tensor_dmrg.py", line 619, in _eigs
    return eigh(
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/base_linalg.py", line 197, in eigensystem
    return eigensystem_partial(A, k=k, isherm=isherm, sort=sort,
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/base_linalg.py", line 158, in eigensystem_partial
    return eigs_scipy(A, **settings, **backend_opts)
  File "/home/hirad/.local/lib/python3.8/site-packages/quimb/linalg/scipy_linalg.py", line 110, in eigs_scipy
    lk, vk = eigs(A, **settings, **eigs_opts)
  File "/home/hirad/.local/lib/python3.8/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 1697, in eigsh
    params.iterate()
  File "/home/hirad/.local/lib/python3.8/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 571, in iterate
    self._raise_no_convergence()
  File "/home/hirad/.local/lib/python3.8/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 377, in _raise_no_convergence
    raise ArpackNoConvergence(msg % (num_iter, k_ok, self.k), ev, vec)
scipy.sparse.linalg._eigen.arpack.arpack.ArpackNoConvergence: ARPACK error -1: No convergence (1001 iterations, 0/1 eigenvectors converged)

I've checked the installation of quimb and SLEPC and everything seems ok. Can you tell me what is going on?

jcmgray commented 1 year ago

Looks like a numerical rather than software issue, neither slepc or the fallback script can converge an eigenvector to the tolerance specified. You could try loosening the tolerance or tweaking other settings like the number of lanczos vectors. It might also be something to do with the conditioning of your application. But no easy fixes I’m afraid!

ElHirad commented 1 year ago

Is there a way to request the eigensolver to provide its "best guess" of the solution instead of returning an error?

jcmgray commented 1 year ago

You could try the lobpcg backend, I think it does that by default, just with a warning.

ElHirad commented 1 year ago

It takes a lot of time with lobpcg. So, can't use SLEPC for that? maybe with a tweak in the code?

jcmgray commented 1 year ago

Not that I can recall off the top of my head, but you are welcome to look around the slepc4py documentation and submit a PR if you find something.