Using HDF5 in DMRG.jl

Hi there,

I am trying to add a few lines of code that saves the psi to .h5 file during the DMRG sweeps. I add the following line to the top of dmrg.jl file:
using HDF5

but it reports the following error

  **ERROR:** LoadError: ArgumentError: Package ITensors does not have HDF5 in its dependencies:
- You may have a partially installed environment. Try `Pkg.instantiate()` to ensure all packages in the environment are installed.
- Or, if you have ITensors checked out for development and have added HDF5 as a dependency but haven't updated your primary environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with ITensors

Then, I tried to add HDF5 to the dependence of ITensor by running:

Pkg.activate("/home/cfengno1/.julia/dev/ITensors/")
Pkg.add("HDF5")
using ITensors

It gives the following error:

  **Warning:** The project dependencies or compat requirements have changed since the manifest was last resolved.
 It is recommended to `Pkg.resolve()` or consider `Pkg.update()` if necessary.
@ Pkg.API ~/.julia/juliaup/julia1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:1807

  **Precompiling** ITensors
  1 dependency successfully precompiled in 9 seconds. 91 already precompiled.

  **Warning:** The project dependencies or compat requirements have changed since the manifest was last resolved. It is recommended to `Pkg.resolve()` or consider `Pkg.update()` if necessary.@ Pkg.API ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:1807

  **Info:** Precompiling ITensorsVectorInterfaceExt [2f1fcacd-197e-560a-aa0f-27cf761d5e85]

**Warning:** Module ITensorsVectorInterfaceExt with build ID ffffffff-ffff-ffff-00d9-4bce33645c6f is missing from the cache. This may mean ITensorsVectorInterfaceExt [2f1fcacd-197e-560a-aa0f-27cf761d5e85] does not support precompilation but is imported by a module that does.
 @ Base loading.jl:1948

  ** Error:** Error during loading of extension ITensorsVectorInterfaceExt of ITensors, use `Base.retry_load_extensions()` to retry.
 exception =
1-element ExceptionStack:
Declaring __precompile__(false) is not allowed in files that are being precompiled.

Can you help me to save the state psi to file in the middle of the DMRG sweeps?

Best,
Feng Chen

Hi Feng,

I think it would be much safer to not modify the Project.toml of ITensor. Potentially a better idea is to make a custom Observer object which captures psi during a DMRG computations and writes it to disk there. That way your Observer code will interface with HDF5 and you will not need HDF5 in ITensors explicitly.
Additionally, I have found much better luck with using the JLD2 package over HDF5 for writing ITensors to disk.

All the best,
Karl

Thank you very much Karl!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.