Spaces:
Runtime error
Runtime error
import numpy as np | |
import h5py | |
import os | |
import mercury as mr | |
import sys | |
sys.path.append('/plot_scripts/') | |
from map_packages_colors_all import * | |
from plot_scripts_all import * | |
# print(" Tasks to choose from : ") | |
# print(" Heisenberg dynamics (hdyn), Random Quantum Circuits (rqc), Quantum Fourier Transform (qft)") | |
# print("###############################") | |
# print(" Compute capability choices for packages :") | |
# print(" singlethread, multithread, gpu") | |
# print("###############################") | |
# print(" Precision choices for different compute capabilities :") | |
# print(" sp (single precision), dp (double precision)") | |
# print("###############################") | |
# task_1 = input(" Enter the task to compare : ") | |
# package_1 = input(" Enter the choice of the package, package 1 : ") | |
# p_com_cap = input(" Enter the choice of the compute capability : ") | |
# p_prec = input(" Enter the choice of the precision : ") | |
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', 'qpanda', 'qpp', 'myqlm', 'myqlm_cpp', 'braket'] | |
def abs_time(t, cc, pr, 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 cc == "Singlethread": | |
cc = "singlethread" | |
elif cc == "Multithread": | |
cc = "multithread" | |
elif cc == "GPU": | |
cc = "gpu" | |
if pr == "Single": | |
pr = "sp" | |
elif pr == "Double": | |
pr = "dp" | |
fig, ax = plt.subplots() | |
dir = os.getcwd() | |
pack_list = [] | |
mr.Md(f"TtS performance of the different packages") | |
for package in package_str: | |
data_file = dir + '/data/{}/{}_{}_{}.h5'.format(t, package, cc, 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+'_'+cc+'_'+pr) | |
# save_flag = input("Do you want to save the plot?") | |
# if save_flag == "Y": | |
# gen_settings(fig, ax, r"N (system size)", r"Time ($t_{package}$)", False, True, True, 10**-1, 10**5, "out", "perf_{}_{}_{}_{}_{}_{}_{}_{}.pdf".format(t1, p1, p1_cc, p1_pr, t2, p2, p2_cc, p2_pr)) | |
# else: | |
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**5, "out", None) | |
# else: | |
# print(" Re-select the options as the requested option data is not available.") | |
if compare_pack not in pack_list: | |
mr.Md(f"For relative performance select one from the list: , {pack_list}") | |
# mr.Md(" Select one package from the list ") | |
else: | |
mr.Md("___") | |
mr.Md(f"Relative performance to the package {compare_pack}") | |
fig, ax = plt.subplots() | |
p_main = dir + '/data/{}/{}_{}_{}.h5'.format(t, compare_pack, cc, pr) | |
h5f = h5py.File(p_main, 'r') | |
main_dat = h5f[storage_dict[compare_pack]][:] | |
h5f.close() | |
for package in package_str: | |
dat_file = dir + '/data/{}/{}_{}_{}.h5'.format(t, package, cc, 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+'_'+cc+'_'+pr) | |
# gen_settings(fig, ax, xlabel_str, ylabel_str, log_x_on, log_y_on, xlim_on, xlim_low, xlim_upp, ylim_on, ylim_low, ylim_upp, leg_loc, fn): | |
gen_settings(fig, ax, r"N (system size)", r"Relative time", False, True, True, N_arr[0]-2, N_arr[-1], True, 10**-1, 10**3, "out", None) | |
# pkg_str = ['qiskit' , 'cirq', 'qsimcirq', 'pennylane', 'pennylane_l', 'qibo', 'qibojit', 'yao', 'quest', 'qulacs', 'intel_qs_cpp', 'projectq', 'svsim', 'hybridq', 'hiq', 'qcgpu', 'qrack_sch'] | |
# abs_time(pkg_str, task_1, p_com_cap, p_prec) | |
# abs_time("Heisenberg dynamics", "Singlethread", "Single", 'qsimcirq', 34) | |