unable to determine if "filename.h5" is accessible in the HDF5 format (file may not exist)

I saved an MPS using ITensors.HDF5 but while loading it, I get the error
unable to determine if "filename.h5" is accessible in the HDF5 format (file may not exist) (assuming that the file is filename.h5).

I even ran the program in the same directory as the .h5 file itself but I keep getting the same error. The file doesn’t seem to be corrupted (it’s quite heavy, around 1.8 GB).

How do I solve this?

Best,
Kartikeya

Unfortunately I don’t think we can provide very much help with this. It sounds to me like a bug or issue with the Julia HDF5 library, or the underlying C HDF5 library that Julia HDF5 wraps around. (ITensors.HDF5 is just a shorthand for the HDF5.jl Julia library which we do not maintain.)

You may make some progress searched on the Julia language Discourse forum to see if others have gotten a similar error message.

Hi Miles,

I couldn’t find any resource to solve this error. Please let me know if have anything in mind to solve this.

Is there any other way to save these MPS files to use in Julia? I mean apart from HDF5.

Hi Kartikeya,
I’m really not sure why this error is happening without more information. Could you share the code you are using? Also did you get a longer printout of the error showing a “backtrace” of where the problem is occurring?

Miles

In the meantime while you try to resolve the error you are seeing with HDF5, you can try a package like JLD2 that can save and load any Julia object.

FYI, I am seeing the same error when running the unit tests

julia .julia/dev/ITensors/test/readwrite.jl

readwrite

HDF5 v0.16.12
ITensors v0.3.20 ~/.julia/dev/ITensors
Ubuntu 22.04

Presumably the continuous integration server jenkins is not picking up this problem, or all PRs would fail, no?
It looks like dense tensors can write, but diag/block tensors cannot !!?! (but only for some people)

The unit test error you’re seeing is probably because Diag tensor has an error and doesn’t close the file data.h5. Support for Diag ITensors was added after the latest release (v0.3.20) .

I’ve opened a bug report re: the test failures

1 Like

I just tried to save an MPS for the first time with my own code and I am also getting this error. I am using ITensors v0.3.23. Below is some code get replicates the issue for me.

using ITensors, ITensors.HDF5

begin
    d = 2
    N = 10
    n = d^N
    x = LinRange(0, 1, n)
    y = 2 * x
    inds = siteinds(d, N)
    ȳ = MPS(y, inds)
end

h5open("mps.hdf5", "w") do fid
    create_group(fid, "mps")
    fid["mps"]["y"] = ȳ
end

h5open("mps.hdf5", "r") # error happens here

Disregard.

I forgot that commands will use the root workspace. I was doing

h5open("mps.hdf5", "r")

I should have done

h5open("path/to/current/directory/mps.hdf5", "r")

Once I fixed the path issue it works no problem now.

Sorry for any confusion.

Ok thanks for letting us know anyway!