Spaces:
Runtime error
Runtime error
File size: 4,383 Bytes
f415c73 3c7abdd f415c73 3c7abdd f415c73 3c7abdd f415c73 3c7abdd f415c73 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
import numpy as np
import h5py
import os
import sys
sys.path.append('/plot_scripts')
from map_packages_colors_mgpu import *
from plot_scripts_mgpu import *
package_str = ['qiskit' , 'cirq', 'qsimcirq', 'pennylane', 'pennylane_l', 'qibo', 'qibojit', 'yao', 'quest', 'qulacs', 'intel_qs_cpp', 'projectq', 'svsim', 'hybridq', 'hiq', 'qcgpu', 'qrack_sch', 'cuquantum_qiskit', 'cuquantum_qsimcirq']
def abs_time(t, pr, n_gpu, compare_pack, N_end):
if t == "Heisenberg dynamics":
t = "hdyn"
elif t == "Random Quantum Circuit":
t = "rqc"
elif t == "Quantum Fourier Transform":
t = "qft"
if pr == "Single":
pr = "sp"
elif pr == "Double":
pr = "dp"
fig, ax = plt.subplots()
dir = os.getcwd()
pack_list = []
for package in package_str:
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
if os.path.isfile(data_file):
h5f = h5py.File(data_file, 'r')
dat = h5f[storage_dict[package]][:]
h5f.close()
pack_list.append(package)
if t == 'hdyn' or t == 'qft':
N_arr = range(6, N_end, 2)
else:
N_arr = range(12, N_end, 2)
plot_abs_data_n_arr(N_arr, dat, package+'_'+t+'_'+'gpu_'+str(n_gpu)+'_'+pr)
gen_settings(fig, ax, r"N (system size)", r"Time ($t_{package}$)", False, True, True, N_arr[0]-2, N_arr[-1], True, 10**-1, 10**4, "out", None)
# else:
# print(" Re-select the options as the requested option data is not available.")
p_main = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, compare_pack, n_gpu, pr)
if not os.path.isfile(p_main):
return "Please select other package"
fig, ax = plt.subplots()
h5f = h5py.File(p_main, 'r')
main_dat = h5f[storage_dict[compare_pack]][:]
h5f.close()
for package in package_str:
dat_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
if os.path.isfile(dat_file):
h5f = h5py.File(dat_file, 'r')
dat = h5f[storage_dict[package]][:]
h5f.close()
plot_comp_data_n_arr(N_arr, dat, main_dat, package+'_'+t+'_'+'gpu_'+str(n_gpu)+'_'+pr)
gen_settings(fig, ax, r"N (system size)", r"Relative time", False, False, True, N_arr[0]-2, N_arr[-1], True, -1, 10, "out", None)
# abs_time("Heisenberg dynamics", "Single", 1, "cuquantum_qsimcirq", 36)
def abs_time_ngpus(t, pr, pack, compare_ngpu, N_end):
if t == "Heisenberg dynamics":
t = "hdyn"
elif t == "Random Quantum Circuit":
t = "rqc"
elif t == "Quantum Fourier Transform":
t = "qft"
if pr == "Single":
pr = "sp"
elif pr == "Double":
pr = "dp"
fig, ax = plt.subplots()
dir = os.getcwd()
if t == 'hdyn' or t == 'qft':
N_arr = range(6, N_end, 2)
else:
N_arr = range(12, N_end, 2)
for ngpu in [1, 2, 4, 8]:
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, pack, ngpu, pr)
if not os.path.isfile(data_file):
return "Please select other package"
if os.path.isfile(data_file):
h5f = h5py.File(data_file, 'r')
dat = h5f[storage_dict[pack]][:]
h5f.close()
plot_abs_data_n_arr(N_arr, dat, pack+'_'+t+'_'+'gpu_'+str(ngpu)+'_'+pr)
gen_settings(fig, ax, r"N (system size)", r"Time ($t_{package}$)", False, True, True, N_arr[0]-2, N_arr[-1], True, 10**-1, 10**4, "out", None)
# else:
# print(" Re-select the options as the requested option data is not available.")
fig, ax = plt.subplots()
p_main = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, pack, compare_ngpu, pr)
h5f = h5py.File(p_main, 'r')
main_dat = h5f[storage_dict[pack]][:]
h5f.close()
for n_gpu in [1, 2, 4, 8]:
dat_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, pack, n_gpu, pr)
if os.path.isfile(dat_file):
h5f = h5py.File(dat_file, 'r')
dat = h5f[storage_dict[pack]][:]
h5f.close()
plot_comp_data_n_arr(N_arr, dat, main_dat, pack+'_'+t+'_'+'gpu_'+str(n_gpu)+'_'+pr)
gen_settings(fig, ax, r"N (system size)", r"Relative time", False, False, True, N_arr[0]-2, N_arr[-1], True, -1, 10, "out", None)
# abs_time_ngpus("Heisenberg dynamics", "Single", "cuquantum_qsimcirq", 8, 36)
|