Spaces:
Runtime error
Runtime error
Amit
commited on
Commit
·
d2fd675
1
Parent(s):
35990c0
plot scripts updated.
Browse files
plot_scripts/compare_expectation.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import h5py
|
3 |
+
# from map_packages_colors import *
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
|
6 |
+
import os
|
7 |
+
import sys
|
8 |
+
|
9 |
+
import warnings
|
10 |
+
warnings.filterwarnings("ignore")
|
11 |
+
|
12 |
+
|
13 |
+
params = {'backend': 'ps',
|
14 |
+
'axes.labelsize': 16,
|
15 |
+
'axes.titlesize': 14,
|
16 |
+
'font.size': 8,
|
17 |
+
'legend.fontsize': 14,
|
18 |
+
'xtick.labelsize': 16,
|
19 |
+
'ytick.labelsize': 16,
|
20 |
+
'figure.figsize': (10, 10),}
|
21 |
+
# 'text.usetex': True}
|
22 |
+
|
23 |
+
from matplotlib import rc
|
24 |
+
# plt.rc('text.latex', preamble=r'\usepackage{braket}')
|
25 |
+
plt.rcParams.update(params)
|
26 |
+
|
27 |
+
N_arr = np.arange(6, 14, 2)
|
28 |
+
|
29 |
+
path = os.getcwd()
|
30 |
+
|
31 |
+
data_path = path + '/exp_data/'
|
32 |
+
|
33 |
+
def compare_two_expect_all(task, prec, pkg_str):
|
34 |
+
fig, ax = plt.subplots()
|
35 |
+
|
36 |
+
comp_mat = np.zeros((len(pkg_str), len(pkg_str)))
|
37 |
+
|
38 |
+
for p1 in range(len(pkg_str)):
|
39 |
+
|
40 |
+
dat_file_p1 = data_path + '{}/{}/exp_mat_{}_{}.npy'.format(task, pkg_str[p1], pkg_str[p1], prec)
|
41 |
+
# print(dat_file_p1)
|
42 |
+
|
43 |
+
for p2 in range(len(pkg_str)):
|
44 |
+
|
45 |
+
dat_file_p2 = data_path + '{}/{}/exp_mat_{}_{}.npy'.format(task, pkg_str[p2], pkg_str[p2], prec)
|
46 |
+
|
47 |
+
if os.path.isfile(dat_file_p1) and os.path.isfile(dat_file_p2):
|
48 |
+
|
49 |
+
dat_p1 = np.load(dat_file_p1)
|
50 |
+
dat_p2 = np.load(dat_file_p2)
|
51 |
+
|
52 |
+
comp_mat[p1, p2] = np.log10(np.sum(np.abs(dat_p1 - dat_p2))/float(16))
|
53 |
+
# print(comp_mat[p1, p2])
|
54 |
+
else:
|
55 |
+
continue
|
56 |
+
|
57 |
+
plt.imshow(comp_mat, vmin=-16, vmax=0)
|
58 |
+
|
59 |
+
plt.xticks(range(len(pkg_str)), pkg_str)
|
60 |
+
locs, labels = plt.xticks()
|
61 |
+
|
62 |
+
plt.setp(labels, rotation=90)
|
63 |
+
plt.yticks(range(len(pkg_str)), pkg_str)
|
64 |
+
locs, labels = plt.yticks()
|
65 |
+
plt.colorbar()
|
66 |
+
plt.tight_layout()
|
67 |
+
# plt.savefig(fn)
|
68 |
+
plt.show()
|
69 |
+
|
70 |
+
package_str_sp = ['cirq', 'hybridq', 'intel_qs_cpp', 'pennylane', 'pennylane_l', 'qibo', 'qibojit', 'qiskit', 'qsimcirq', 'quest', 'yao', 'qiskit_gpu', 'hybridq_gpu', 'qibojit_gpu', 'qsimcirq_gpu', 'yao_gpu']#, 'pennylane_l_gpu', 'quest_gpu', 'projectq', 'qulacs', 'qulacs_gpu']
|
71 |
+
|
72 |
+
sorted_package_str_sp = ['qiskit_gpu', 'cuquantum_qiskit', 'qiskit', 'pennylane', 'cirq', 'qsimcirq', 'qsimcirq_gpu', 'qibojit_gpu', 'qibojit', 'qibo', 'intel_qs_cpp', 'quest', 'cuquantum_qsimcirq', 'pennylane_l', 'hybridq_gpu', 'hybridq', 'yao', 'yao_gpu']
|
73 |
+
|
74 |
+
# compare_two_expect_all('hdyn', 'sp', sorted_package_str_sp)#, 'compare_packages_qft_sp_N16_log.pdf')
|
75 |
+
|
76 |
+
package_str_dp = ['cirq', 'intel_qs_cpp', 'pennylane', 'pennylane_l', 'qibo', 'qibojit', 'qiskit', 'quest', 'yao', 'qiskit_gpu', 'qibojit_gpu', 'yao_gpu', 'pennylane_l_gpu', 'quest_gpu', 'projectq', 'qulacs', 'qulacs_gpu']#, 'hybridq', 'qsimcirq', 'hybridq_gpu', 'qsimcirq_gpu']
|
77 |
+
|
78 |
+
sorted_package_str_dp = sorted_package_str_dp = ['qibojit_gpu', 'qulacs', 'qiskit_gpu', 'cuquantum_qiskit', 'qiskit', 'qpanda', 'intel_qs_cpp', 'quest', 'qibo', 'qibojit', 'pennylane_l_gpu', 'pennylane', 'yao_gpu', 'yao', 'pennylane_l', 'cirq', 'quest_gpu', 'projectq', 'qulacs_gpu']
|
79 |
+
|
80 |
+
# compare_two_expect_all('hdyn', 'dp', sorted_package_str_dp)#, 'compare_packages_qft_dp_N16_log.pdf')
|
plot_scripts/plot_display_1v1.py
CHANGED
@@ -2,8 +2,10 @@ import numpy as np
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
|
|
|
|
5 |
import sys
|
6 |
-
sys.path.append('/plot_scripts')
|
7 |
from map_packages_colors_1v1 import *
|
8 |
from plot_scripts_1v1 import *
|
9 |
|
@@ -86,6 +88,8 @@ def abs_time(t1, p1, p1_cc, p1_pr, t2, p2, p2_cc, p2_pr, N_end):
|
|
86 |
|
87 |
fig, ax = plt.subplots()
|
88 |
|
|
|
|
|
89 |
if os.path.isfile(data_file_p1) and os.path.isfile(data_file_p2):
|
90 |
h5f_1 = h5py.File(data_file_p1, 'r')
|
91 |
dat_1 = h5f_1[storage_dict[p1]][:]
|
@@ -108,14 +112,14 @@ def abs_time(t1, p1, p1_cc, p1_pr, t2, p2, p2_cc, p2_pr, N_end):
|
|
108 |
|
109 |
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)
|
110 |
else:
|
111 |
-
|
112 |
|
113 |
# abs_time(task_1, package_1, p1_com_cap, p1_prec, task_2, package_2, p2_com_cap, p2_prec)
|
114 |
|
115 |
def relative_time_wrt_pack(t1, p1, p1_cc, p1_pr, t2, p2, p2_cc, p2_pr, N_end):
|
116 |
|
117 |
-
|
118 |
-
|
119 |
|
120 |
if t1 == "Heisenberg dynamics":
|
121 |
t1 = "hdyn"
|
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
5 |
+
import mercury as mr
|
6 |
+
|
7 |
import sys
|
8 |
+
sys.path.append('/plot_scripts/')
|
9 |
from map_packages_colors_1v1 import *
|
10 |
from plot_scripts_1v1 import *
|
11 |
|
|
|
88 |
|
89 |
fig, ax = plt.subplots()
|
90 |
|
91 |
+
mr.Md(f"TtS performance of the selected options")
|
92 |
+
|
93 |
if os.path.isfile(data_file_p1) and os.path.isfile(data_file_p2):
|
94 |
h5f_1 = h5py.File(data_file_p1, 'r')
|
95 |
dat_1 = h5f_1[storage_dict[p1]][:]
|
|
|
112 |
|
113 |
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)
|
114 |
else:
|
115 |
+
mr.Md(f" Re-select the options as the requested configuration is not supported (check the table in the index page for supported configurations)")
|
116 |
|
117 |
# abs_time(task_1, package_1, p1_com_cap, p1_prec, task_2, package_2, p2_com_cap, p2_prec)
|
118 |
|
119 |
def relative_time_wrt_pack(t1, p1, p1_cc, p1_pr, t2, p2, p2_cc, p2_pr, N_end):
|
120 |
|
121 |
+
mr.Md("___")
|
122 |
+
mr.Md(f"Relative performance")
|
123 |
|
124 |
if t1 == "Heisenberg dynamics":
|
125 |
t1 = "hdyn"
|
plot_scripts/plot_display_all.py
CHANGED
@@ -2,8 +2,10 @@ import numpy as np
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
|
|
|
|
5 |
import sys
|
6 |
-
sys.path.append('/plot_scripts')
|
7 |
from map_packages_colors_all import *
|
8 |
from plot_scripts_all import *
|
9 |
|
@@ -51,6 +53,8 @@ def abs_time(t, cc, pr, compare_pack, N_end):
|
|
51 |
|
52 |
pack_list = []
|
53 |
|
|
|
|
|
54 |
for package in package_str:
|
55 |
data_file = dir + '/data/{}/{}_{}_{}.h5'.format(t, package, cc, pr)
|
56 |
|
@@ -75,11 +79,12 @@ def abs_time(t, cc, pr, compare_pack, N_end):
|
|
75 |
# print(" Re-select the options as the requested option data is not available.")
|
76 |
|
77 |
if compare_pack not in pack_list:
|
78 |
-
|
|
|
79 |
|
80 |
else:
|
81 |
-
|
82 |
-
|
83 |
|
84 |
fig, ax = plt.subplots()
|
85 |
|
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
5 |
+
import mercury as mr
|
6 |
+
|
7 |
import sys
|
8 |
+
sys.path.append('/plot_scripts/')
|
9 |
from map_packages_colors_all import *
|
10 |
from plot_scripts_all import *
|
11 |
|
|
|
53 |
|
54 |
pack_list = []
|
55 |
|
56 |
+
mr.Md(f"TtS performance of the different packages")
|
57 |
+
|
58 |
for package in package_str:
|
59 |
data_file = dir + '/data/{}/{}_{}_{}.h5'.format(t, package, cc, pr)
|
60 |
|
|
|
79 |
# print(" Re-select the options as the requested option data is not available.")
|
80 |
|
81 |
if compare_pack not in pack_list:
|
82 |
+
mr.Md(f"For relative performance select one from the list: , {pack_list}")
|
83 |
+
# mr.Md(" Select one package from the list ")
|
84 |
|
85 |
else:
|
86 |
+
mr.Md("___")
|
87 |
+
mr.Md(f"Relative performance to the package {compare_pack}")
|
88 |
|
89 |
fig, ax = plt.subplots()
|
90 |
|
plot_scripts/plot_display_com_pack.py
CHANGED
@@ -2,8 +2,10 @@ import numpy as np
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
|
|
|
|
5 |
import sys
|
6 |
-
sys.path.append('/plot_scripts')
|
7 |
from map_packages_colors_all import *
|
8 |
from plot_scripts_all import *
|
9 |
|
@@ -117,8 +119,8 @@ def abs_time_pack(t1, t2, cc, pr, N_end):
|
|
117 |
else:
|
118 |
N_arr = N_arr_t1
|
119 |
|
120 |
-
|
121 |
-
|
122 |
|
123 |
plot_comp_data_n_arr(N_arr, ng1, ng2, 'gate_count')
|
124 |
gen_settings(fig, ax, r"N (system size)", r"Task I/Task II ($t_{T1}/t_{T2}$)", False, False, True, N_arr[0]-2, N_arr[-1], True, -3, 25, "out", None)
|
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
5 |
+
import mercury as mr
|
6 |
+
|
7 |
import sys
|
8 |
+
sys.path.append('/plot_scripts/')
|
9 |
from map_packages_colors_all import *
|
10 |
from plot_scripts_all import *
|
11 |
|
|
|
119 |
else:
|
120 |
N_arr = N_arr_t1
|
121 |
|
122 |
+
mr.Md(f" Number of gates of Task 1: {ng1}")
|
123 |
+
mr.Md(f" Number of gates of Task 2: {ng2}")
|
124 |
|
125 |
plot_comp_data_n_arr(N_arr, ng1, ng2, 'gate_count')
|
126 |
gen_settings(fig, ax, r"N (system size)", r"Task I/Task II ($t_{T1}/t_{T2}$)", False, False, True, N_arr[0]-2, N_arr[-1], True, -3, 25, "out", None)
|
plot_scripts/plot_display_mgpu.py
CHANGED
@@ -2,8 +2,10 @@ import numpy as np
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
|
|
|
|
5 |
import sys
|
6 |
-
sys.path.append('/plot_scripts')
|
7 |
from map_packages_colors_mgpu import *
|
8 |
from plot_scripts_mgpu import *
|
9 |
|
@@ -29,6 +31,8 @@ def abs_time(t, pr, n_gpu, compare_pack, N_end):
|
|
29 |
|
30 |
pack_list = []
|
31 |
|
|
|
|
|
32 |
for package in package_str:
|
33 |
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
|
34 |
|
@@ -56,6 +60,9 @@ def abs_time(t, pr, n_gpu, compare_pack, N_end):
|
|
56 |
main_dat = h5f[storage_dict[compare_pack]][:]
|
57 |
h5f.close()
|
58 |
|
|
|
|
|
|
|
59 |
for package in package_str:
|
60 |
dat_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
|
61 |
if os.path.isfile(dat_file):
|
@@ -91,6 +98,8 @@ def abs_time_ngpus(t, pr, pack, compare_ngpu, N_end):
|
|
91 |
else:
|
92 |
N_arr = range(12, N_end, 2)
|
93 |
|
|
|
|
|
94 |
for ngpu in [1, 2, 4, 8]:
|
95 |
|
96 |
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, pack, ngpu, pr)
|
@@ -108,6 +117,8 @@ def abs_time_ngpus(t, pr, pack, compare_ngpu, N_end):
|
|
108 |
# else:
|
109 |
# print(" Re-select the options as the requested option data is not available.")
|
110 |
|
|
|
|
|
111 |
|
112 |
fig, ax = plt.subplots()
|
113 |
|
|
|
2 |
import h5py
|
3 |
import os
|
4 |
|
5 |
+
import mercury as mr
|
6 |
+
|
7 |
import sys
|
8 |
+
sys.path.append('/plot_scripts/')
|
9 |
from map_packages_colors_mgpu import *
|
10 |
from plot_scripts_mgpu import *
|
11 |
|
|
|
31 |
|
32 |
pack_list = []
|
33 |
|
34 |
+
mr.Md(f"TtS performance of the different packages")
|
35 |
+
|
36 |
for package in package_str:
|
37 |
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
|
38 |
|
|
|
60 |
main_dat = h5f[storage_dict[compare_pack]][:]
|
61 |
h5f.close()
|
62 |
|
63 |
+
mr.Md("___")
|
64 |
+
mr.Md(f"Relative performance to the package {compare_pack}")
|
65 |
+
|
66 |
for package in package_str:
|
67 |
dat_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, package, n_gpu, pr)
|
68 |
if os.path.isfile(dat_file):
|
|
|
98 |
else:
|
99 |
N_arr = range(12, N_end, 2)
|
100 |
|
101 |
+
mr.Md(f"TtS performance of the package with respect to different number of GPU's")
|
102 |
+
|
103 |
for ngpu in [1, 2, 4, 8]:
|
104 |
|
105 |
data_file = dir + '/data/{}/{}_gpu_{}_{}.h5'.format(t, pack, ngpu, pr)
|
|
|
117 |
# else:
|
118 |
# print(" Re-select the options as the requested option data is not available.")
|
119 |
|
120 |
+
mr.Md("___")
|
121 |
+
mr.Md(f"Relative performance to the {compare_ngpu} GPUs")
|
122 |
|
123 |
fig, ax = plt.subplots()
|
124 |
|