Transferring data between CPU and GPU

Hi, ITensor Teams!

Thanks for sharing such highly efficient code~ I am recently trying to use GPU to accelerate the Julia ITensor code.

I can realize the Time Evolution on GPU by the follow codes,

using ITensors
using ITensorsGPU

L = 5
Nx,Ny = L,L 
s = siteinds("S=1/2", Nx*Ny)

gates = ITensor[]
push!(gates,exp(1im * op("S+",s[1])*op("S-",s[2])))
X = cu.(gates)

state0=["Dn" for i in 1:Nx*Ny] 
psi = apply(X,psi)

These codes work well.

But, I want to calculate the entropy, and the svd function seem can’t work on GPU. The follow codes meet problem,

b = round(Int,Nx*Ny/2)
U,S,V = svd(psi[b], (linkind(psi, b-1), siteind(psi,b)))

I want to transfer the MPS from GPU to CPU. And I have seen that you mention that Adapt.adapt_structure() can realize the idea.

But, I can’t use it well. Could you please give me a simple and constract example about how to transfer data from GPU to CPU. For example, calculating an entropy starting from GPU MPS

Thank you very much and looking forward to your reply!