some work on performance stuff
This commit is contained in:
parent
05231fd5ae
commit
58265fc8de
|
@ -1,6 +1,7 @@
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import json
|
||||||
|
|
||||||
from pyqcs import State, H, X, S, CZ
|
from pyqcs import State, H, X, S, CZ
|
||||||
from pyqcs.graph.state import GraphState
|
from pyqcs.graph.state import GraphState
|
||||||
|
@ -35,13 +36,14 @@ def test_scaling_circuits(state_factory
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
nstart = 400
|
nstart = 400
|
||||||
nstop = 1600
|
nstop = 800
|
||||||
step = 50
|
step = 50
|
||||||
ncircuits = 250
|
ncircuits = 50
|
||||||
nqbits0 = 100
|
nqbits0 = 100
|
||||||
nqbits1 = 50
|
nqbits1 = 50
|
||||||
|
seed = 0xdeadbeef
|
||||||
|
|
||||||
np.random.seed(0xdeadbeef)
|
np.random.seed(seed)
|
||||||
results_graph0 = test_scaling_circuits(GraphState.new_zero_state
|
results_graph0 = test_scaling_circuits(GraphState.new_zero_state
|
||||||
, nstart
|
, nstart
|
||||||
, nstop
|
, nstop
|
||||||
|
@ -49,7 +51,7 @@ if __name__ == "__main__":
|
||||||
, nqbits0
|
, nqbits0
|
||||||
, ncircuits
|
, ncircuits
|
||||||
, repeat=10)
|
, repeat=10)
|
||||||
np.random.seed(0xdeadbeef)
|
np.random.seed(seed)
|
||||||
results_graph1 = test_scaling_circuits(GraphState.new_zero_state
|
results_graph1 = test_scaling_circuits(GraphState.new_zero_state
|
||||||
, nstart
|
, nstart
|
||||||
, nstop
|
, nstop
|
||||||
|
@ -58,19 +60,21 @@ if __name__ == "__main__":
|
||||||
, ncircuits
|
, ncircuits
|
||||||
, repeat=10)
|
, repeat=10)
|
||||||
|
|
||||||
h0 = plt.errorbar(results_graph0[:, 0], results_graph0[:, 2], results_graph0[:, 3]
|
np.savetxt("circuit_scaling_graph0.csv", results_graph0)
|
||||||
, label=f"Graphical Simulator $N_q={nqbits0}$ Qbits"
|
print("saved results0 to circuit_scaling_graph0.csv")
|
||||||
, marker="^"
|
np.savetxt("circuit_scaling_graph1.csv", results_graph1)
|
||||||
, color="black")
|
print("saved results1 to circuit_scaling_graph1.csv")
|
||||||
h1 = plt.errorbar(results_graph1[:, 0], results_graph1[:, 2], results_graph1[:, 3]
|
|
||||||
, label=f"Graphical Simulator $N_q={nqbits1}$ Qbits"
|
|
||||||
, marker="o"
|
|
||||||
, color="black")
|
|
||||||
|
|
||||||
plt.legend(handles=[h0, h1])
|
meta = {
|
||||||
plt.xlabel("Number of gates in circuit")
|
"nstart": 400
|
||||||
plt.ylabel("Execution time per circuit [s]")
|
, "nstop": 1800
|
||||||
plt.title(f"Execution Time for random Circuits")
|
, "step": 50
|
||||||
|
, "ncircuits": 50
|
||||||
|
, "nqbits0": 100
|
||||||
|
, "nqbits1": 50
|
||||||
|
, "seed": 0xdeadbeef}
|
||||||
|
|
||||||
|
with open("circuit_scaling_meta.json", "w") as fout:
|
||||||
|
json.dump(meta, fout)
|
||||||
|
print("saved meta to circuit_scaling_meta.json")
|
||||||
|
|
||||||
#plt.show()
|
|
||||||
plt.savefig("scaling_circuits.png", dpi=400)
|
|
|
@ -1,6 +1,7 @@
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import json
|
||||||
|
|
||||||
from pyqcs import State, H, X, S, CZ
|
from pyqcs import State, H, X, S, CZ
|
||||||
from pyqcs.graph.state import GraphState
|
from pyqcs.graph.state import GraphState
|
||||||
|
@ -31,18 +32,19 @@ def test_scaling_qbits(state_factory
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
nstart = 4
|
nstart = 4
|
||||||
nstop = 19
|
nstop = 16
|
||||||
ncircuits = 250
|
ncircuits = 50
|
||||||
ngates_per_qbit = 100
|
ngates_per_qbit = 100
|
||||||
|
seed = 0xdeadbeef
|
||||||
|
|
||||||
np.random.seed(0xdeadbeef)
|
np.random.seed(seed)
|
||||||
results_naive = test_scaling_qbits(State.new_zero_state
|
results_naive = test_scaling_qbits(State.new_zero_state
|
||||||
, nstart
|
, nstart
|
||||||
, nstop
|
, nstop
|
||||||
, ngates_per_qbit
|
, ngates_per_qbit
|
||||||
, ncircuits
|
, ncircuits
|
||||||
, repeat=10)
|
, repeat=10)
|
||||||
np.random.seed(0xdeadbeef)
|
np.random.seed(seed)
|
||||||
results_graph = test_scaling_qbits(GraphState.new_zero_state
|
results_graph = test_scaling_qbits(GraphState.new_zero_state
|
||||||
, nstart
|
, nstart
|
||||||
, nstop
|
, nstop
|
||||||
|
@ -50,19 +52,18 @@ if __name__ == "__main__":
|
||||||
, ncircuits
|
, ncircuits
|
||||||
, repeat=10)
|
, repeat=10)
|
||||||
|
|
||||||
h0 = plt.errorbar(results_naive[:, 0], results_naive[:, 2], results_naive[:, 3]
|
np.savetxt("qbit_scaling_naive.csv", results_naive)
|
||||||
, label=f"Dense Vector Simulator $N_c={int(results_naive[:, 1][0])}$ circuits"
|
print("saved naive results to qbit_scaling_naive.csv")
|
||||||
, marker="o"
|
np.savetxt("qbit_scaling_graph.csv", results_graph)
|
||||||
, color="black")
|
print("saved graph results to qbit_scaling_graph.csv")
|
||||||
h1 = plt.errorbar(results_graph[:, 0], results_graph[:, 2], results_graph[:, 3]
|
|
||||||
, label=f"Graphical Simulator $N_c={int(results_graph[:, 1][0])}$ circuits"
|
|
||||||
, marker="^"
|
|
||||||
, color="black")
|
|
||||||
|
|
||||||
plt.legend(handles=[h0, h1])
|
meta = {"nstart": nstart
|
||||||
plt.xlabel("Number of Qbits $N_q$")
|
, "nstop": nstop
|
||||||
plt.ylabel("Execution time per circuit [s]")
|
, "ncircuits": ncircuits
|
||||||
plt.title(f"Execution Time for ${ngates_per_qbit}\\times N_q$ Gates with random Circuits (rescaled)")
|
, "ngates_per_qbit": ngates_per_qbit
|
||||||
|
, "seed": seed}
|
||||||
|
|
||||||
|
with open("qbit_scaling_meta.json", "w") as fout:
|
||||||
|
json.dump(meta, fout)
|
||||||
|
print("saved meta data to qbit_scaling_meta.json")
|
||||||
|
|
||||||
#plt.show()
|
|
||||||
plt.savefig("Figure_1.png", dpi=400)
|
|
29
performance/plot_scaling_circuits_linear.py
Normal file
29
performance/plot_scaling_circuits_linear.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from collections import deque
|
||||||
|
import matplotlib
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
|
||||||
|
matplotlib.rcParams.update({'errorbar.capsize': 2})
|
||||||
|
|
||||||
|
results_graph0 = np.genfromtxt("circuit_scaling_graph0.csv")
|
||||||
|
results_graph1 = np.genfromtxt("circuit_scaling_graph1.csv")
|
||||||
|
with open("circuit_scaling_meta.json") as fin:
|
||||||
|
meta = json.load(fin)
|
||||||
|
|
||||||
|
h0 = plt.errorbar(results_graph0[:, 0], results_graph0[:, 2], results_graph0[:, 3]
|
||||||
|
, label=f"Graphical Simulator $N_q={meta['nqbits0']}$ Qbits"
|
||||||
|
, marker="^"
|
||||||
|
, color="black")
|
||||||
|
h1 = plt.errorbar(results_graph1[:, 0], results_graph1[:, 2], results_graph1[:, 3]
|
||||||
|
, label=f"Graphical Simulator $N_q={meta['nqbits1']}$ Qbits"
|
||||||
|
, marker="o"
|
||||||
|
, color="black")
|
||||||
|
|
||||||
|
plt.legend(handles=[h0, h1])
|
||||||
|
plt.xlabel("Number of gates in circuit")
|
||||||
|
plt.ylabel("Execution time per circuit [s]")
|
||||||
|
plt.title(f"Execution Time for random Circuits")
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
#plt.savefig("scaling_circuits_linear.png", dpi=400)
|
29
performance/plot_scaling_qbits_linear.py
Normal file
29
performance/plot_scaling_qbits_linear.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
|
||||||
|
matplotlib.rcParams.update({'errorbar.capsize': 2})
|
||||||
|
|
||||||
|
results_naive = np.genfromtxt("qbit_scaling_naive.csv")
|
||||||
|
results_graph = np.genfromtxt("qbit_scaling_graph.csv")
|
||||||
|
with open("qbit_scaling_meta.json") as fin:
|
||||||
|
meta = json.load(fin)
|
||||||
|
|
||||||
|
|
||||||
|
h0 = plt.errorbar(results_naive[:, 0], results_naive[:, 2], results_naive[:, 3]
|
||||||
|
, label=f"Dense Vector Simulator $N_c={int(results_naive[:, 1][0])}$ circuits"
|
||||||
|
, marker="o"
|
||||||
|
, color="black")
|
||||||
|
h1 = plt.errorbar(results_graph[:, 0], results_graph[:, 2], results_graph[:, 3]
|
||||||
|
, label=f"Graphical Simulator $N_c={int(results_graph[:, 1][0])}$ circuits"
|
||||||
|
, marker="^"
|
||||||
|
, color="black")
|
||||||
|
|
||||||
|
plt.legend(handles=[h0, h1])
|
||||||
|
plt.xlabel("Number of Qbits $N_q$")
|
||||||
|
plt.ylabel("Execution time per circuit [s]")
|
||||||
|
plt.title(f"Execution Time for ${meta['ngates_per_qbit']}\\times N_q$ Gates with random Circuits (rescaled)")
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
#plt.savefig("scaling_qbits_linear.png", dpi=400)
|
31
performance/plot_scaling_qbits_log.py
Normal file
31
performance/plot_scaling_qbits_log.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
|
||||||
|
matplotlib.rcParams.update({'errorbar.capsize': 2})
|
||||||
|
|
||||||
|
results_naive = np.genfromtxt("qbit_scaling_naive.csv")
|
||||||
|
results_graph = np.genfromtxt("qbit_scaling_graph.csv")
|
||||||
|
with open("qbit_scaling_meta.json") as fin:
|
||||||
|
meta = json.load(fin)
|
||||||
|
|
||||||
|
|
||||||
|
h0 = plt.errorbar(results_naive[:, 0], results_naive[:, 2], results_naive[:, 3]
|
||||||
|
, label=f"Dense Vector Simulator $N_c={int(results_naive[:, 1][0])}$ circuits"
|
||||||
|
, marker="o"
|
||||||
|
, color="black")
|
||||||
|
h1 = plt.errorbar(results_graph[:, 0], results_graph[:, 2], results_graph[:, 3]
|
||||||
|
, label=f"Graphical Simulator $N_c={int(results_graph[:, 1][0])}$ circuits"
|
||||||
|
, marker="^"
|
||||||
|
, color="black")
|
||||||
|
|
||||||
|
plt.yscale("log")
|
||||||
|
plt.legend(handles=[h0, h1])
|
||||||
|
plt.xlabel("Number of Qbits $N_q$")
|
||||||
|
plt.ylabel("Execution time per circuit [s]")
|
||||||
|
plt.title(f"Execution Time for ${meta['ngates_per_qbit']}\\times N_q$ Gates with random Circuits (rescaled)")
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
#plt.savefig("scaling_qbits_log.png", dpi=400)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 204 KiB |
Loading…
Reference in New Issue
Block a user