using Metal: mtl
using NamedGraphs.NamedGraphGenerators: named_grid
using ITensorNetworks: random_tensornetwork, siteinds
g = named_grid((2, 2))
s = siteinds("S=1/2", g)
tn = random_tensornetwork(s)
tn_mtl = mtl(tn)
and we can see the tensors have been moved to GPU:
@JoeyT1994 with this you should then be able to follow the same instructions that are shown here: https://itensor.github.io/ITensors.jl/dev/RunningOnGPUs.html to run calculation on GPU, for example for gate application before calling apply load the relevant GPU package and transfer the gates and tensor network to GPU using the corresponding conversion function, i.e. cu, mtl, roc, etc.
There may be parts of the library code that aren't generic enough for GPU, for example making implicit assumptions about the element type, constructing intermediate tensors on CPU instead of on the GPU device of the tensor network, etc. We had to go through a process of stamping out those kinds of issues in ITensors.jl and ITensorMPS.jl but they aren't hard to fix using Adapt.adapt.
With this we can now do:
and we can see the tensors have been moved to GPU:
@JoeyT1994 with this you should then be able to follow the same instructions that are shown here: https://itensor.github.io/ITensors.jl/dev/RunningOnGPUs.html to run calculation on GPU, for example for gate application before calling
apply
load the relevant GPU package and transfer the gates and tensor network to GPU using the corresponding conversion function, i.e.cu
,mtl
,roc
, etc.There may be parts of the library code that aren't generic enough for GPU, for example making implicit assumptions about the element type, constructing intermediate tensors on CPU instead of on the GPU device of the tensor network, etc. We had to go through a process of stamping out those kinds of issues in ITensors.jl and ITensorMPS.jl but they aren't hard to fix using
Adapt.adapt
.