Hi all!
First of all, I would like to say that I’ve been using ITensor a lot in the first couple months of my PhD, and it’s been a great experience!
While doing DMRG calculations on the GPU using the CUDA backend, I encountered a problem:
I cannot save an MPS which is on the GPU to a hdf5 file.
Is this not implemented, or am I doing something wrong?
Here’s a minimal bit of code to reproduce this issue:
using ITensors, ITensorMPS
using HDF5
using CUDA
sites = siteinds("S=1/2", 5, conserve_qns=false)
psi_random = random_mps(sites;linkdims=5)
psi_random_gpu = cu(psi_random)
fi = h5open("test.h5","cw")
write(fi, "MPS", psi_random) #Saving CPU MPS to hdf5, works fine
write(fi, "MPS_GPU", psi_random_gpu) #Saving GPU MPS to hdf5, throws error
close(fi)
It throws the following error:
ERROR: ArgumentError: Illegal conversion of a CUDA.DeviceMemory to a Ptr{Float32}
A possible fix would be to move the psi_random_gpu (the GPU MPS) back onto the CPU, though I could not find how to do this.
Thanks in advance!
Pim