-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmake_test_circuits.py
40 lines (33 loc) · 1.11 KB
/
make_test_circuits.py
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
import numpy as np
from qiskit import *
import glob
from generate_circuits import supremacy_circuit, pad_circuit
from qiskit.transpiler.exceptions import TranspilerError
if __name__ == '__main__':
IBMQ.load_account()
provider = IBMQ.get_provider(group='open')
backend = provider.get_backend('ibmq_burlington')
n_circuits = 1000
n = 5
circuits = []
for i in range(n_circuits):
print(i)
try_again = True
while try_again:
try_again = False
family = []
s = supremacy_circuit(n=n, m=5)
# compile to optimization_level=3
qc = QuantumCircuit.from_qasm_str(s)
try:
qc_t = transpile(qc, backend=backend, optimization_level=3)
except TranspilerError:
try_again = True
if not try_again:
c = qc_t.qasm()
p = pad_circuit(c, backend, n=n)
if p is None:
try_again = True
circuits.append(c)
circuits = np.array(circuits)
np.save('test_circuits_5.npy', circuits)