You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like CuYao recompiles apply! every time the parameters of a circuit are changed, even though the circuit is still the same. This is in contrast to running a circuit on the CPU and and not on the GPU where compilation happens only once when running a circuit for the first time and then all future runs are fast when changing the parameters. See the following MWE:
using Yao, Yao.AD, Yao.EasyBuild
using CuYao
import CUDA
n =10
d =5
circuit =variational_circuit(n, d)
cureg =zero_state(n) |> cu
reg =zero_state(n)
# every time this block gets run the first `apply!()` takes much longer than the second `appply!()`begin
cureg.state .=0.@CUDA.allowscalar cureg.state[1] =1.dispatch!(circuit, :random)
@timeapply!(cureg, circuit)
@timeapply!(cureg, circuit)
end# only the very first time this block gets run the first `apply!()` invokes a compilation pass, after# that the first `apply!()` and the second apply always take roughly the same time.begin
reg.state .=0.
reg.state[1] =1.dispatch!(circuit, :random)
@timeapply!(reg, circuit)
@timeapply!(reg, circuit)
end
The text was updated successfully, but these errors were encountered:
It seems like CuYao recompiles
apply!
every time the parameters of a circuit are changed, even though the circuit is still the same. This is in contrast to running a circuit on the CPU and and not on the GPU where compilation happens only once when running a circuit for the first time and then all future runs are fast when changing the parameters. See the following MWE:The text was updated successfully, but these errors were encountered: