hi, as the title says I was currently playing around with UnifiedMemory to avoid running out of GPU memory by using two GPUs - I basically followed the instructions here
Whether this is actually working and fast(er than cpu) I have no idea yet, since I’m getting errors when trying to apply an MPO to an MPS - I didn’t want to truncate, so I was using the alg=“naive”,truncate=false which in some occasion turned out to be a bit more robust for me - that’s probably matter for another topic)
Specifically I’m getting this error below. Is this to be expected or there is something missing somewhere? Using the latest ITensors etc.
as always, thanks for the great work!
ERROR: TypeError: in new, expected NDTensors.Dense{ComplexF64, CuArray{ComplexF64, 1}}, got a value of type NDTensors.Dense{ComplexF64, CuArray{ComplexF64, 1, CUDA.DeviceMemory}}
Stacktrace:
[1] NDTensors.DenseTensor{…}(::NDTensors.AllowAlias, storage::NDTensors.Dense{…}, inds::Tuple{…})
@ NDTensors ~/.julia/packages/NDTensors/WCcIa/src/tensor/tensor.jl:27
[2] similar(tensortype::Type{NDTensors.DenseTensor{ComplexF64, 3, Tuple{…}, NDTensors.Dense{…}}}, dims::Tuple{Index{Int64}, Index{Int64}, Index{Int64}})
@ NDTensors ~/.julia/packages/NDTensors/WCcIa/src/tensor/similar.jl:22
[3] contraction_output
@ ~/.julia/packages/NDTensors/WCcIa/src/dense/tensoralgebra/contract.jl:3 [inlined]
[4] contraction_output
@ ~/.julia/packages/NDTensors/WCcIa/src/tensoroperations/generic_tensor_operations.jl:62 [inlined]
[5] contract(tensor1::NDTensors.DenseTensor{…}, labelstensor1::Tuple{…}, tensor2::NDTensors.DenseTensor{…}, labelstensor2::Tuple{…}, labelsoutput_tensor::Tuple{…})
@ NDTensors ~/.julia/packages/NDTensors/WCcIa/src/tensoroperations/generic_tensor_operations.jl:108
[6] contract(::Type{…}, tensor1::NDTensors.DenseTensor{…}, labels_tensor1::Tuple{…}, tensor2::NDTensors.DenseTensor{…}, labels_tensor2::Tuple{…})
@ NDTensors ~/.julia/packages/NDTensors/WCcIa/src/tensoroperations/generic_tensor_operations.jl:91
[7] contract
@ ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:331 [inlined]
[8] _contract(A::NDTensors.DenseTensor{ComplexF64, 3, Tuple{…}, NDTensors.Dense{…}}, B::NDTensors.DenseTensor{ComplexF64, 2, Tuple{…}, NDTensors.Dense{…}})
@ ITensors ~/.julia/packages/ITensors/fUsvl/src/tensor_operations/tensor_algebra.jl:3
[9] _contract(A::ITensor, B::ITensor)
@ ITensors ~/.julia/packages/ITensors/fUsvl/src/tensor_operations/tensor_algebra.jl:9
[10] contract(A::ITensor, B::ITensor)
@ ITensors ~/.julia/packages/ITensors/fUsvl/src/tensor_operations/tensor_algebra.jl:74
[11] *
@ ~/.julia/packages/ITensors/fUsvl/src/tensor_operations/tensor_algebra.jl:61 [inlined]
[12] truncate!(::NDTensors.BackendSelection.Algorithm{:frobenius, @NamedTuple{}}, M::MPS; site_range::UnitRange{Int64}, kwargs::@Kwargs{})
@ ITensors.ITensorMPS ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/abstractmps.jl:1694
[13] truncate!
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/abstractmps.jl:1679 [inlined]
[14] truncate!(M::MPS; alg::String, kwargs::@Kwargs{})
@ ITensors.ITensorMPS ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/abstractmps.jl:1676
[15] truncate!
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/abstractmps.jl:1675 [inlined]
[16] _contract(::NDTensors.BackendSelection.Algorithm{:naive, @NamedTuple{}}, A::MPO, ψ::MPS; truncate::Bool, kwargs::@Kwargs{})
@ ITensors.ITensorMPS ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:804
[17] _contract
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:778 [inlined]
[18] #contract#465
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:811 [inlined]
[19] contract
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:810 [inlined]
[20] #apply#454
@ ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:604 [inlined]
[21] product(alg::NDTensors.BackendSelection.Algorithm{:naive, @NamedTuple{}}, A::MPO, ψ::MPS)
@ ITensors.ITensorMPS ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:603
[22] product(A::MPO, ψ::MPS; alg::String, kwargs::@Kwargs{})
@ ITensors.ITensorMPS ~/.julia/packages/ITensors/fUsvl/src/lib/ITensorMPS/src/mpo.jl:600
[23] top-level scope
@ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.
MWE:
using ITensors, ITensorMPS
using CUDA
s = siteinds(4,20)
psi = random_mps(ComplexF64, s, linkdims=40)
phi = random_mps(ComplexF64, s, linkdims=50)
inner(psi,phi)
cu_psi = NDTensors.cu(psi, storagemode=CUDA.UnifiedMemory)
cu_phi = NDTensors.cu(phi, storagemode=CUDA.UnifiedMemory)
inner(cu_psi, cu_phi) #works
o = random_mpo(s) + random_mpo(s)
cu_o = NDTensors.cu(o, storagemode=CUDA.UnifiedMemory)
test1 = apply(cu_o, cu_psi) # works
test1 = apply(cu_o, cu_psi, alg="naive") #errors