-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgpu_comparison.jl
45 lines (34 loc) · 1.19 KB
/
gpu_comparison.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using CUDA
using PicoQuant
let
r = 4
c = 4
n = r * c
# circ = create_ghz_preparation_circuit(n)
circ = create_RQC(r, c, 32)
function sim_circ_mps_gpu(circ, profile=false)
backend = InteractiveBackend{CuArray{ComplexF64}}()
tng = convert_qiskit_circ_to_network(circ, decompose=true, transpile=true, backend)
add_input!(tng, "0"^circ.n_qubits)
CUDA.synchronize()
if !profile
CUDA.@time output_node = contract_mps_tensor_network_circuit!(tng)
else
CUDA.@profile output_node = contract_mps_tensor_network_circuit!(tng)
end
end
function sim_circ_mps_cpu(circ)
backend = InteractiveBackend{Array{ComplexF32}}()
tng = convert_qiskit_circ_to_network(circ, decompose=true, transpile=true, backend)
add_input!(tng, "0"^circ.n_qubits)
@time output_node = contract_mps_tensor_network_circuit!(tng)
end
println("Run CPU version")
# sim_circ_mps_cpu(circ)
sim_circ_mps_cpu(circ)
CUDA.allowscalar(false)
println("Run GPU version")
# sim_circ_mps_gpu(circ)
sim_circ_mps_gpu(circ)
sim_circ_mps_gpu(circ, true)
end