import time
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
MEGA = 1e6
GIGA = 1e9
MICRO = 1e-6
NANO = 1e-9
def read_signal_txt(xfile, yfile, timescale=1e-9):
with open(xfile, 'r') as f:
x = np.array([float(d) * timescale for d in f.readlines()])
with open(yfile, 'r') as f:
y = np.array([float(d) for d in f.readlines()])
return x, y
def read_signal_dat(file, timescale=1e-9):
with open(file, 'r') as f:
x = np.array([[float(x[0]) * timescale, float(x[1])] for x in [d.split() for d in f.readlines()]])
return x[:,0], x[:, 1]
keys = ["Jeshcke_Birad_80K_Qband", "TbypT_Birad_RT_Xband", "Test_Birad_80K_Qband"]
NS = [16, 32, 64]
graphs = {}
for key in keys:
x, y = read_signal_dat(f'oscillations/new_data/{key}.dat')
graphs[key] = {"00 raw": (x, y)}
def show_subplots(data, vertical=True, x_ranges=None, sharex=False, sharey=False):
import matplotlib
rolling = [
('gray', ':', '', 1),
('#222222', '-', 'o', 2),
('green', '--', '*', 2),
('blue', ':', '+', 1),
('blue', '-', '*', 1),
('black', '-', '^', 2)
]
matplotlib.rcParams.update({'font.size': 16})
n = len(data)
fig, ax = plt.subplots(n if vertical else 1, 1 if vertical else n,
sharex=sharex, sharey=sharey, figsize=(20, 20))
for i, key in enumerate(data.keys()):
charts = data[key]
for j, g in enumerate(sorted(list(charts.keys()))):
ax[i].plot(
charts[g][0], charts[g][1], label=g,
color = rolling[j % len(rolling)][0],
ls = rolling[j % len(rolling)][1],
marker= rolling[j % len(rolling)][2],
lw = rolling[j % len(rolling)][3],
)
if x_ranges is not None and key in x_ranges:
ax[i].set_xlim(x_ranges[key])
ax[i].legend()
ax[i].set_title(key)
# plt.subplots_adjust(top=2)
plt.tight_layout()
plt.show()
show_subplots(graphs)
def subsample(x, y, shift, step, N):
i = 0
while x[i] < shift: i += 1
result = x[i:i + (step * N):step], y[i:i + (step * N):step]
return result
shifts = {
"Jeshcke_Birad_80K_Qband" : 396 * NANO,
"TbypT_Birad_RT_Xband": 44 * NANO,
"Test_Birad_80K_Qband": 72 * NANO,
}
steps16 = {
"Jeshcke_Birad_80K_Qband" : 16,
"TbypT_Birad_RT_Xband": 4,
"Test_Birad_80K_Qband": 8,
}
steps32 = {
"Jeshcke_Birad_80K_Qband" : 8,
"TbypT_Birad_RT_Xband": 2,
"Test_Birad_80K_Qband": 4,
}
steps64 = {
"Jeshcke_Birad_80K_Qband" : 4,
"TbypT_Birad_RT_Xband": 1,
"Test_Birad_80K_Qband": 2,
}
steps = {
16: steps16, 32: steps32, 64: steps64
}
x_ranges = {}
for N in steps:
for key in keys:
x, y = read_signal_dat(f'oscillations/new_data/{key}.dat')
x, y = subsample(x, y, shift=shifts[key], step=steps[N][key], N=N)
graphs[key][f"{N}"] = (x, y)
if N == 64:
x_ranges[key] = min(x), max(x)
show_subplots(graphs)
show_subplots(graphs, x_ranges=x_ranges)
def fft(x, y):
fy = np.fft.fft(y)
fx = np.fft.fftfreq(len(y), x[1] - x[0])
data = np.array(sorted(list(zip(fx, fy))))
return data[:, 0].real, abs(data[:, 1])
def norm(x, y):
return x, (y / max(y))
fft_graphs = {}
freq_ranges = {}
for key in keys:
fft_graphs[key] = {}
for graph in graphs[key]:
x, y = graphs[key][graph]
fx, fy = norm(*fft(x, y))
fft_graphs[key][f'FFT {graph}'] = (fx, fy)
if graph == '64':
freq_ranges[key] = min(fx), max(fx)
We can observe, that sampling changes the distribution, but keeps the peaks.
show_subplots(fft_graphs, x_ranges=freq_ranges)
from qiskit import QuantumCircuit, BasicAer, QuantumRegister, ClassicalRegister, Aer, execute
from qiskit.circuit.library import QFT
from qiskit.compiler import transpile
from qiskit.visualization import plot_histogram, plot_circuit_layout
from qiskit.tools.monitor import job_monitor
from azure.quantum.qiskit import AzureQuantumProvider
from qiskit_ionq import IonQProvider
AZURE = None
def _get_azure_provider():
global AZURE
if AZURE is None:
AZURE = AzureQuantumProvider(resource_id = open('azure.key').read(), location = "eastus")
return AZURE
def _get_ionq_backend(realqpu):
provider = _get_azure_provider()
simulator_backend = provider.get_backend("ionq.qpu" if realqpu else "ionq.simulator")
return simulator_backend
def run_circuit(circuit, qpu, shots=1000):
print(f"Running {shots} shots on {qpu.name()}")
start = time.time()
if qpu.name() != 'qasm_simulator':
job = qpu.run(circuit, shots=shots)
job_id = job.id()
print("Job id", job_id)
job_monitor(job)
print(f"{time.time() - start:3f} seconds spent")
else:
job = execute(circuit, shots=shots, backend=qpu)
print('local simulation')
print(f"{time.time() - start:3f} seconds spent")
return job.result()
SIMULATOR = _get_ionq_backend(False)
QPU = _get_ionq_backend(True)
QASM = BasicAer.get_backend('qasm_simulator')
def get_circuit(data):
import math
dim = math.ceil(math.log2(len(data)))
print("Required qubits:", dim)
data_padded = np.zeros((2 ** dim,))
data_padded[:len(data)] = data
data_normed = data_padded / np.linalg.norm(abs(data_padded))
qr = QuantumRegister(dim, name="qubits")
cr = ClassicalRegister(dim, name="classical")
circuit = QuantumCircuit(qr, cr)
circuit.initialize(data_normed)
#circuit.barrier()
circuit.append(QFT(dim), qr)
#circuit.barrier()
circuit.measure(qr, cr)
return circuit
circuits = {}
for key in keys:
circuits[key] = {}
for N in NS:
x, y = read_signal_dat(f'oscillations/new_data/{key}.dat')
x, y = subsample(x, y, shift=shifts[key], step=steps[N][key], N=N)
circuits[key][N] = transpile(get_circuit(y), backend=SIMULATOR)
print(f"\t\t{key} {N} depth: {circuits[key][N].depth()}")
Required qubits: 4 Jeshcke_Birad_80K_Qband 16 depth: 55 Required qubits: 5 Jeshcke_Birad_80K_Qband 32 depth: 117 Required qubits: 6 Jeshcke_Birad_80K_Qband 64 depth: 243 Required qubits: 4 TbypT_Birad_RT_Xband 16 depth: 50 Required qubits: 5 TbypT_Birad_RT_Xband 32 depth: 107 Required qubits: 6 TbypT_Birad_RT_Xband 64 depth: 243 Required qubits: 4 Test_Birad_80K_Qband 16 depth: 55 Required qubits: 5 Test_Birad_80K_Qband 32 depth: 117 Required qubits: 6 Test_Birad_80K_Qband 64 depth: 226
def clean(data, threshold):
newdata = []
for i, gate in enumerate(data):
if gate[0].name == 'reset':
print('-init;', end=' ')
continue
if gate[0].name == 'ry':
if abs(gate[0]._params[0]) <= threshold:
print(f'-ry{gate[0]._params[0]:.3f};', end=' ')
continue
if gate[0].name == 'rz':
if abs(gate[0]._params[0]) <= threshold:
print('-rz;', end=' ')
continue
if gate[0].name == 'u':
a, b, c = gate[0]._params
if a == b == 0 and abs(c) <= threshold:
print('-u;', end=' ')
continue
if gate[0].name == 'u':
a, b, c = gate[0]._params
if abs(a) <= threshold and abs(b) <= threshold and abs(c) <= threshold:
print('-u;', end=' ')
continue
newdata.append(gate)
print()
#todo remove CX
i = len(newdata) - 1
while i >= 0 and newdata[i][0].name != 'swap':
i -= 1
e = i
while i >= 0 and newdata[i][0].name == 'swap':
i -= 1
if i > 0:
return newdata[:i+1] + newdata[e+1:]
else:
return newdata
def collapse(data):
newdata = []
olddata = list(data)
for i, _ in enumerate(data):
gate = olddata[i]
if gate is None:
print("-cx;", end=" ")
continue
if gate[0].name == 'cx':
gate_1 = olddata[i+1]
gate_2 = olddata[i+2]
if gate_1 is not None and gate_2 is not None and gate_2[0].name == 'cx' and gate_1[0].name == 'cx':
if gate_2[1] == gate[1]:
print('Matching CX pair... ', end="")
olddata[i+2] = None
continue
newdata.append(gate)
return newdata
def do_clean(circuit):
circuit.data = clean(circuit.data, 50 * np.pi * 1e-3)
print(circuit.depth())
for i in range(6):
circuit.data = collapse(circuit.data)
print("Depth:", circuit.depth())
for key in keys:
for N in NS:
do_clean(circuits[key][N])
-ry-0.013; -ry-0.080; -ry-0.145; -ry-0.069; -ry0.007; -ry0.139; 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 -ry-0.036; -ry-0.071; -ry0.113; -ry-0.001; -ry-0.039; -ry0.028; -ry-0.009; -ry0.068; -ry0.079; -ry0.075; -ry0.012; -ry0.062; -ry-0.058; -ry-0.003; -ry-0.009; -ry0.131; -ry0.013; -ry-0.009; 98 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 92 Matching CX pair... -cx; Depth: 90 Matching CX pair... -cx; Depth: 88 Depth: 88 Depth: 88 Depth: 88 -ry-0.137; -ry-0.053; -rz; -rz; -rz; -rz; -ry-0.033; -ry0.098; -ry-0.059; -ry0.039; -ry0.031; -ry0.058; -rz; -rz; -rz; -rz; -ry0.148; -ry0.027; -ry-0.120; -ry0.111; -ry-0.069; -ry0.145; -ry-0.114; -ry-0.025; -ry0.118; -ry-0.135; -ry0.139; -ry-0.136; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -ry-0.054; -ry0.030; -ry0.008; -ry0.001; -ry-0.153; -ry-0.028; -ry0.105; -ry0.108; -ry-0.138; -ry-0.011; -ry0.018; -ry-0.007; -ry0.091; -ry-0.035; -ry0.056; -ry-0.062; -ry-0.154; -ry-0.022; -ry0.070; -ry0.047; -ry0.103; -ry0.119; -ry0.010; -ry0.094; -ry0.057; -ry0.047; -ry-0.015; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; 152 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 111 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 102 Depth: 102 Depth: 102 Depth: 102 Depth: 102 -ry-0.063; -ry-0.031; -ry-0.149; -ry-0.075; -ry0.075; 44 Depth: 44 Depth: 44 Depth: 44 Depth: 44 Depth: 44 Depth: 44 -ry-0.015; -ry-0.106; -ry-0.028; -ry0.155; -ry0.015; -ry-0.101; -ry0.054; -ry-0.015; -ry0.063; -ry0.029; -ry0.120; -ry0.032; 94 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 89 Depth: 89 Depth: 89 Depth: 89 Depth: 89 Depth: 89 -rz; -rz; -ry0.128; -ry-0.051; -ry-0.147; -ry-0.065; -ry-0.015; -ry-0.086; -ry-0.153; -rz; -rz; -rz; -ry-0.052; -ry0.041; -ry-0.067; -ry0.001; -ry0.145; -ry0.152; -ry-0.003; -ry-0.116; -ry0.025; -ry-0.018; -ry0.012; -ry-0.146; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -ry0.013; -ry0.156; -ry-0.125; -ry0.054; -ry0.081; -ry0.019; -ry0.047; -ry0.043; -ry-0.053; -ry-0.005; -ry-0.114; -ry0.048; -ry-0.057; -ry0.120; -ry0.108; -ry-0.152; -ry-0.111; -ry0.012; -ry0.100; -ry-0.044; -ry-0.027; -ry0.016; -ry-0.134; -ry-0.020; -ry0.032; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; -rz; 170 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 139 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 127 Depth: 127 Depth: 127 Depth: 127 Depth: 127 -ry-0.046; -ry0.079; -ry-0.083; -ry-0.033; -ry-0.018; -ry-0.048; 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 Depth: 48 -ry-0.035; -ry0.125; -ry0.062; -ry0.024; -ry-0.049; -ry0.136; -ry0.046; -ry0.020; -ry0.005; -ry0.056; -ry-0.064; -ry-0.084; -ry-0.066; 103 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 98 Depth: 98 Depth: 98 Depth: 98 Depth: 98 Depth: 98 -ry-0.043; -ry0.006; -ry-0.061; -ry0.107; -ry0.062; -ry0.074; -ry-0.019; -ry0.017; -ry-0.091; -ry0.029; -ry-0.012; -ry0.026; -ry0.044; -ry-0.022; -ry0.063; -ry0.099; -ry-0.015; -ry0.083; -ry-0.086; -ry0.092; -ry-0.031; -ry0.114; -ry-0.018; -ry-0.083; -ry-0.142; -ry-0.049; -ry0.070; -ry-0.037; -ry0.036; -ry0.036; -ry0.099; -ry0.037; -ry0.047; -ry0.040; -ry-0.100; -ry0.069; -ry0.143; -ry-0.004; -ry-0.002; -ry-0.008; -ry0.120; -ry-0.148; -ry-0.040; -ry-0.097; -ry-0.023; -ry0.041; 179 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 154 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 147 Depth: 147 Depth: 147 Depth: 147 Depth: 147
## !!!! ALREADY SQUARE ROOT
def to_values(x, counts_raw, N=5, reorder=True):
f = "{0:0" + str(N) + "b}"
for i in range(2 ** N):
if f.format(i) not in counts_raw:
counts_raw[f.format(i)] = 0
ints = [[int(k[::-1] if reorder else k, base=2), v ** .5] for (k, v) in counts_raw.items()]
ints = sorted(ints)
# negative frequencies
ints = ints[len(ints) // 2:] + ints[:len(ints) // 2]
y = np.array(ints)[:, 1]
return norm(x, y)
import math
qft1 = {}
for key in keys:
qft1[key] = {}
qft1[key]['FFT'] = fft_graphs[key][f'FFT 00 raw']
for N in NS:
result = run_circuit(circuits[key][N], qpu=QASM, shots=5000).get_counts()
print(key, N)
print(result)
x, y = fft_graphs[key][f'FFT {N}']
fx, vals = to_values(x, result, N=int(math.log2(N)))
qft1[key][f"QFT' QASM {N}"] = fx, vals
Running 5000 shots on qasm_simulator local simulation 0.088608 seconds spent Jeshcke_Birad_80K_Qband 16 {'0111': 2023, '0100': 1940, '1111': 277, '1010': 33, '1000': 280, '1100': 140, '1011': 147, '0000': 37, '1101': 37, '1001': 3, '0011': 45, '0010': 23, '0110': 7, '0001': 5, '0101': 3} Running 5000 shots on qasm_simulator local simulation 0.143081 seconds spent Jeshcke_Birad_80K_Qband 32 {'01000': 2035, '01111': 1926, '10111': 123, '11000': 145, '11111': 321, '10000': 304, '11110': 1, '00101': 4, '11100': 6, '00000': 38, '11011': 6, '10101': 6, '10100': 11, '11010': 6, '01100': 1, '00010': 3, '00011': 3, '10010': 7, '10011': 7, '00100': 9, '00111': 15, '11101': 6, '10110': 3, '01011': 2, '11001': 5, '00110': 6, '01101': 1} Running 5000 shots on qasm_simulator local simulation 0.134589 seconds spent Jeshcke_Birad_80K_Qband 64 {'111111': 331, '011111': 1918, '010000': 1930, '101111': 78, '100000': 273, '101000': 4, '110000': 114, '001110': 9, '001100': 12, '111100': 6, '100001': 4, '110100': 20, '001001': 15, '010010': 18, '111001': 4, '100101': 4, '011100': 3, '101001': 2, '000000': 35, '011001': 1, '111010': 5, '100110': 9, '010011': 17, '000100': 5, '100010': 6, '111110': 5, '001000': 7, '101011': 11, '110110': 9, '111000': 10, '100100': 9, '010111': 14, '101100': 11, '001101': 4, '011010': 2, '010101': 1, '000111': 11, '110001': 6, '001010': 4, '010110': 2, '001111': 7, '000101': 6, '010001': 2, '101110': 11, '001011': 4, '011000': 5, '100011': 8, '111101': 3, '000011': 5, '011101': 6, '111011': 1, '000001': 1, '000110': 4, '110101': 1, '100111': 2, '110111': 3, '110011': 1, '110010': 1} Running 5000 shots on qasm_simulator local simulation 0.081238 seconds spent TbypT_Birad_RT_Xband 16 {'1100': 1414, '1011': 1517, '0111': 498, '0100': 529, '0010': 295, '0011': 314, '0110': 80, '1101': 71, '1001': 42, '1010': 71, '0001': 10, '0101': 82, '1110': 32, '1111': 17, '1000': 28} Running 5000 shots on qasm_simulator local simulation 0.115829 seconds spent TbypT_Birad_RT_Xband 32 {'10001': 8, '01000': 351, '10111': 1385, '11000': 1424, '00111': 376, '00100': 448, '01111': 348, '00110': 54, '01110': 35, '10100': 29, '00011': 21, '11111': 58, '00000': 72, '10000': 54, '01101': 33, '01010': 36, '10011': 26, '11011': 25, '00001': 13, '01011': 3, '10101': 10, '01001': 46, '11100': 24, '11101': 7, '00101': 53, '11010': 11, '00010': 13, '01100': 2, '10010': 8, '11001': 13, '10110': 10, '11110': 4} Running 5000 shots on qasm_simulator local simulation 0.153629 seconds spent TbypT_Birad_RT_Xband 64 {'010111': 29, '101111': 1208, '001000': 416, '011110': 6, '111111': 142, '110111': 74, '110000': 1141, '001111': 593, '100000': 182, '011111': 194, '010101': 21, '010110': 29, '010000': 228, '011001': 22, '010100': 29, '101110': 16, '101100': 12, '101001': 3, '010010': 8, '000011': 24, '010011': 8, '001010': 16, '110011': 5, '000000': 106, '110001': 39, '110101': 29, '101000': 59, '111110': 38, '000010': 35, '110100': 22, '011011': 30, '100011': 4, '110110': 23, '001001': 17, '011101': 8, '111101': 4, '011000': 17, '100100': 21, '001101': 6, '100101': 8, '101011': 11, '100001': 18, '010001': 18, '001110': 9, '111001': 9, '111100': 6, '111010': 2, '111000': 2, '000111': 8, '011100': 4, '101101': 17, '011010': 1, '000001': 11, '001100': 2, '100010': 1, '000101': 1, '110010': 4, '001011': 2, '111011': 1, '000100': 1} Running 5000 shots on qasm_simulator local simulation 0.078101 seconds spent Test_Birad_80K_Qband 16 {'1100': 1839, '0100': 155, '1000': 102, '1011': 1736, '0111': 143, '0110': 139, '0101': 119, '1111': 90, '0011': 158, '0010': 151, '1001': 114, '1101': 50, '1110': 139, '1010': 54, '0001': 6, '0000': 5} Running 5000 shots on qasm_simulator local simulation 0.137997 seconds spent Test_Birad_80K_Qband 32 {'10111': 1753, '11000': 1779, '01011': 66, '11011': 87, '00101': 28, '00111': 173, '00011': 18, '00100': 172, '10000': 99, '10100': 81, '01000': 116, '00110': 33, '01100': 70, '11111': 97, '10011': 14, '01111': 108, '00000': 42, '01101': 25, '11010': 25, '10101': 30, '11101': 54, '00001': 15, '10010': 50, '01010': 26, '00010': 21, '01001': 3, '11100': 10, '01110': 1, '10110': 3, '11001': 1} Running 5000 shots on qasm_simulator local simulation 0.161888 seconds spent Test_Birad_80K_Qband 64 {'101111': 1832, '110000': 1836, '100111': 1, '000000': 17, '110111': 72, '011011': 15, '001000': 137, '001111': 142, '100000': 99, '011111': 149, '111000': 1, '110010': 7, '111011': 52, '010011': 13, '000011': 5, '000111': 16, '010111': 44, '111111': 91, '010000': 107, '101000': 70, '011101': 15, '010001': 7, '001110': 10, '010110': 4, '100101': 13, '111010': 8, '110110': 4, '011000': 41, '100100': 61, '010010': 14, '011100': 9, '001001': 6, '101110': 12, '011110': 7, '010101': 2, '100011': 6, '101101': 3, '000110': 2, '110001': 5, '010100': 11, '101011': 3, '000100': 7, '110101': 3, '100001': 4, '111001': 3, '110100': 3, '001101': 5, '111101': 2, '101001': 3, '101010': 4, '100010': 5, '101100': 1, '111110': 2, '011010': 2, '100110': 2, '001010': 1, '011001': 3, '000010': 1}
print("============ FFT ================")
show_subplots(fft_graphs, x_ranges=freq_ranges)
print("===== QFT SIMULATION ============")
show_subplots(qft1, x_ranges=freq_ranges)
============ FFT ================
===== QFT SIMULATION ============
def pairwise_average(data):
v = (data[0::2] + data[1::2]) / 2
r = np.zeros(data.shape)
r[::2] = v
r[1::2] = v
return r
circuits2 = {}
for key in keys:
circuits2[key] = {}
for N in NS:
x, y = read_signal_dat(f'oscillations/new_data/{key}.dat')
x, y = subsample(x, y, shift=shifts[key], step=steps[N][key], N=N)
y = pairwise_average(y)
circuits2[key][N] = transpile(get_circuit(y), backend=SIMULATOR)
print(f"\t\t{key} {N} depth: {circuits2[key][N].depth()}")
for key in keys:
for N in NS:
do_clean(circuits2[key][N])
Required qubits: 4 Jeshcke_Birad_80K_Qband 16 depth: 29 Required qubits: 5 Jeshcke_Birad_80K_Qband 32 depth: 76 Required qubits: 6 Jeshcke_Birad_80K_Qband 64 depth: 155 Required qubits: 4 TbypT_Birad_RT_Xband 16 depth: 37 Required qubits: 5 TbypT_Birad_RT_Xband 32 depth: 76 Required qubits: 6 TbypT_Birad_RT_Xband 64 depth: 155 Required qubits: 4 Test_Birad_80K_Qband 16 depth: 37 Required qubits: 5 Test_Birad_80K_Qband 32 depth: 76 Required qubits: 6 Test_Birad_80K_Qband 64 depth: 155 -ry0.111; -ry0.096; -ry-0.114; 25 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 17 Matching CX pair... -cx; Depth: 16 Depth: 16 Depth: 16 Depth: 16 Depth: 16 -ry-0.030; -ry-0.077; -ry0.146; -ry-0.017; -ry-0.020; -ry0.048; 69 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 58 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 52 Matching CX pair... -cx; Depth: 48 Depth: 48 Depth: 48 Depth: 48 -ry0.147; -ry-0.126; -ry-0.065; -ry-0.080; -ry0.040; -ry-0.019; -ry0.116; -ry-0.022; -ry0.011; -ry0.149; -ry0.113; -ry-0.127; -ry0.124; -ry-0.136; -ry-0.022; 139 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 115 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 103 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 95 Matching CX pair... -cx; Depth: 94 Depth: 94 Depth: 94 -ry-0.155; -ry-0.098; 34 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 26 Matching CX pair... -cx; Depth: 22 Depth: 22 Depth: 22 Depth: 22 Depth: 22 -ry0.055; -ry0.067; -ry-0.147; -ry-0.068; -ry-0.025; 70 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 56 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 50 Matching CX pair... -cx; Depth: 46 Depth: 46 Depth: 46 Depth: 46 -ry-0.118; -ry-0.058; -ry-0.003; -ry0.154; -ry-0.064; -ry-0.156; -ry-0.116; -ry-0.030; -ry0.143; -ry0.104; -ry-0.077; -ry-0.132; -ry-0.049; -ry0.061; -ry0.065; 139 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 115 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 103 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 95 Matching CX pair... -cx; Depth: 94 Depth: 94 Depth: 94 36 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 31 Matching CX pair... -cx; Depth: 27 Depth: 27 Depth: 27 Depth: 27 Depth: 27 -ry-0.067; -ry0.140; -ry0.095; -ry0.113; -ry-0.110; -ry0.092; 69 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 58 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 52 Matching CX pair... -cx; Depth: 48 Depth: 48 Depth: 48 Depth: 48 -ry0.011; -ry-0.048; -ry-0.018; -ry0.139; -ry0.139; -ry0.108; -ry-0.073; -ry0.116; -ry-0.022; -ry-0.092; -ry-0.101; -ry0.088; -ry-0.102; -ry0.059; -ry0.036; -ry0.065; -ry0.083; 137 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 113 Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Matching CX pair... -cx; Depth: 101 Matching CX pair... -cx; Matching CX pair... -cx; Depth: 93 Matching CX pair... -cx; Depth: 92 Depth: 92 Depth: 92
import math
qft1_5 = {}
for key in keys:
qft1_5[key] = {}
qft1_5[key]['FFT'] = fft_graphs[key][f'FFT 00 raw']
for N in NS:
result = run_circuit(circuits2[key][N], qpu=QASM, shots=5000).get_counts()
print(key, N)
print(result)
x, y = fft_graphs[key][f'FFT {N}']
fx, vals = to_values(x, result, N=int(math.log2(N)))
qft1_5[key][f"QFT'' QASM {N}"] = fx, vals
Running 5000 shots on qasm_simulator local simulation 0.084301 seconds spent Jeshcke_Birad_80K_Qband 16 {'0100': 1752, '0111': 1691, '0101': 275, '1000': 345, '0110': 290, '1111': 340, '0000': 101, '1011': 65, '1001': 14, '1101': 33, '1100': 45, '1010': 25, '1110': 12, '0011': 4, '0010': 8} Running 5000 shots on qasm_simulator local simulation 0.084697 seconds spent Jeshcke_Birad_80K_Qband 32 {'01111': 1941, '01000': 1905, '11111': 325, '01110': 77, '11000': 115, '10000': 307, '01001': 79, '00000': 36, '01100': 8, '10111': 120, '11001': 16, '00111': 8, '00010': 5, '11100': 1, '00110': 2, '11011': 8, '11101': 2, '10110': 9, '11010': 4, '01101': 1, '10001': 2, '10100': 10, '00100': 8, '10101': 3, '00101': 1, '01011': 2, '00011': 1, '11110': 3, '01010': 1} Running 5000 shots on qasm_simulator local simulation 0.178316 seconds spent Jeshcke_Birad_80K_Qband 64 {'010000': 2002, '011111': 1847, '100111': 1, '010001': 26, '100000': 358, '101000': 15, '111111': 379, '011101': 5, '011110': 25, '010010': 5, '100010': 5, '110000': 87, '111010': 3, '000111': 11, '000000': 40, '000110': 3, '000100': 11, '100100': 12, '101011': 2, '000011': 2, '111011': 11, '101111': 62, '001100': 3, '011100': 9, '010011': 4, '010111': 8, '001111': 1, '111110': 2, '000101': 5, '110001': 2, '001011': 4, '000010': 5, '010101': 1, '001101': 5, '111101': 1, '101001': 2, '100001': 1, '110011': 1, '101110': 1, '011011': 3, '111000': 4, '110111': 9, '010100': 2, '111001': 1, '011001': 1, '011010': 2, '011000': 7, '010110': 2, '100101': 1, '001010': 1} Running 5000 shots on qasm_simulator local simulation 0.053421 seconds spent TbypT_Birad_RT_Xband 16 {'1100': 1091, '1011': 1063, '0111': 686, '0100': 732, '1010': 446, '1101': 479, '0101': 118, '0011': 21, '1000': 101, '0110': 102, '0000': 11, '1111': 113, '0010': 28, '1110': 4, '1001': 5} Running 5000 shots on qasm_simulator local simulation 0.096965 seconds spent TbypT_Birad_RT_Xband 32 {'10111': 1380, '10001': 4, '00111': 320, '01111': 339, '10010': 12, '00100': 336, '11000': 1405, '11001': 134, '00010': 1, '01000': 359, '11111': 80, '00101': 68, '00000': 120, '10000': 104, '10011': 11, '00110': 52, '10100': 15, '10110': 129, '11010': 3, '11011': 19, '01001': 28, '01011': 16, '01110': 23, '01010': 6, '11100': 9, '01100': 11, '11101': 7, '10101': 5, '11110': 2, '00011': 1, '01101': 1} Running 5000 shots on qasm_simulator local simulation 0.172223 seconds spent TbypT_Birad_RT_Xband 64 {'001111': 460, '110000': 1293, '001000': 481, '000111': 6, '101000': 48, '011111': 289, '101111': 1368, '110111': 42, '110101': 6, '000010': 4, '000000': 108, '010000': 263, '100110': 4, '111000': 33, '111111': 136, '100000': 142, '111001': 2, '011110': 2, '101100': 5, '100111': 28, '110001': 27, '010101': 4, '010111': 18, '001010': 8, '101110': 33, '011101': 6, '001110': 13, '011000': 8, '011100': 5, '101011': 8, '010100': 16, '000100': 4, '011010': 4, '011011': 14, '000110': 1, '110100': 9, '000011': 5, '001011': 22, '001100': 9, '100010': 2, '010001': 5, '000101': 1, '001001': 16, '100011': 6, '111101': 3, '010011': 5, '111100': 5, '001101': 6, '101101': 1, '010110': 1, '010010': 4, '101001': 3, '110011': 1, '011001': 1, '100001': 1, '110110': 1, '101010': 2, '111110': 1, '111010': 1} Running 5000 shots on qasm_simulator local simulation 0.078105 seconds spent Test_Birad_80K_Qband 16 {'1100': 1375, '1101': 620, '1010': 636, '0111': 262, '1011': 1440, '1111': 152, '0110': 53, '0100': 241, '1000': 148, '1110': 10, '0101': 42, '1001': 7, '0000': 13, '0010': 1} Running 5000 shots on qasm_simulator local simulation 0.084616 seconds spent Test_Birad_80K_Qband 32 {'11000': 1790, '10110': 187, '00110': 18, '10111': 1842, '11001': 168, '01111': 131, '00100': 111, '10100': 59, '11111': 101, '10000': 96, '01000': 131, '11011': 52, '10101': 17, '00000': 75, '00111': 128, '01101': 6, '01011': 17, '11010': 12, '01001': 7, '00101': 19, '10001': 1, '11100': 4, '01100': 6, '10011': 5, '10010': 4, '01110': 7, '01010': 3, '00011': 2, '00010': 1} Running 5000 shots on qasm_simulator local simulation 0.153651 seconds spent Test_Birad_80K_Qband 64 {'001111': 127, '110000': 1844, '010111': 29, '101111': 1870, '101000': 99, '001000': 133, '111111': 104, '011111': 127, '110111': 87, '010000': 120, '100000': 108, '101110': 39, '110110': 8, '110001': 40, '001100': 19, '001011': 11, '110101': 4, '111011': 15, '111010': 4, '100100': 27, '001101': 15, '011000': 25, '101011': 11, '011011': 5, '111001': 2, '000000': 15, '101101': 2, '110011': 4, '101010': 2, '111100': 7, '111000': 9, '100011': 1, '010100': 4, '110100': 16, '001010': 9, '000100': 4, '011110': 3, '110010': 3, '010110': 2, '000101': 4, '111101': 2, '100101': 5, '001001': 5, '001110': 7, '101100': 3, '101001': 3, '100010': 1, '010011': 2, '010101': 1, '010010': 2, '100111': 6, '011001': 1, '000111': 4}
show_subplots(fft_graphs, x_ranges=freq_ranges)
show_subplots(qft1_5, x_ranges=freq_ranges)
import math
qft2 = {}
for key in keys:
qft2[key] = {}
qft2[key]['FFT'] = fft_graphs[key][f'FFT 00 raw']
for N in NS:
result = run_circuit(circuits2[key][N], qpu=QPU, shots=1000).get_counts()
print(key, N)
print(result)
x, y = fft_graphs[key][f'FFT {N}']
fx, vals = to_values(x, result, N=int(math.log2(N)))
qft2[key][f"QFT QPU {N}"] = fx, vals
Running 1000 shots on ionq.qpu Job id 937113a7-a079-11ec-839c-d4258b36ead3 Job Status: job has successfully run 111.204593 seconds spent Jeshcke_Birad_80K_Qband 16 {'0000': 23, '0001': 5, '0010': 4, '0011': 5, '0100': 354, '0101': 96, '0110': 51, '0111': 260, '1000': 43, '1001': 11, '1010': 5, '1011': 17, '1100': 30, '1101': 20, '1110': 23, '1111': 53} Running 1000 shots on ionq.qpu Job id d6624396-a079-11ec-9bbe-d4258b36ead3 Job Status: job has successfully run 104.624094 seconds spent Jeshcke_Birad_80K_Qband 32 {'00000': 31, '00001': 53, '00010': 23, '00011': 30, '00100': 22, '00101': 22, '00110': 17, '00111': 42, '01000': 49, '01001': 43, '01010': 18, '01011': 39, '01100': 34, '01101': 35, '01110': 14, '01111': 67, '10000': 37, '10001': 37, '10010': 16, '10011': 22, '10100': 25, '10101': 35, '10110': 17, '10111': 18, '11000': 21, '11001': 35, '11010': 16, '11011': 21, '11100': 48, '11101': 49, '11110': 28, '11111': 36} Running 1000 shots on ionq.qpu Job id 155bc921-a07a-11ec-b29e-d4258b36ead3 Job Status: job has successfully run 210.394912 seconds spent Jeshcke_Birad_80K_Qband 64 {'000000': 16, '000001': 23, '000010': 10, '000011': 13, '000100': 14, '000101': 12, '000110': 6, '000111': 9, '001000': 14, '001001': 20, '001010': 10, '001011': 13, '001100': 8, '001101': 11, '001110': 6, '001111': 20, '010000': 18, '010001': 7, '010010': 6, '010011': 9, '010100': 12, '010101': 13, '010110': 13, '010111': 13, '011000': 23, '011001': 6, '011010': 7, '011011': 14, '011100': 21, '011101': 8, '011110': 14, '011111': 14, '100000': 20, '100001': 19, '100010': 8, '100011': 8, '100100': 19, '100101': 21, '100110': 16, '100111': 9, '101000': 33, '101001': 23, '101010': 12, '101011': 20, '101100': 27, '101101': 15, '101110': 9, '101111': 18, '110000': 18, '110001': 12, '110010': 15, '110011': 17, '110100': 26, '110101': 25, '110110': 19, '110111': 27, '111000': 36, '111001': 19, '111010': 14, '111011': 18, '111100': 24, '111101': 16, '111110': 18, '111111': 16} Running 1000 shots on ionq.qpu Job id 93630f5f-a07a-11ec-b41a-d4258b36ead3 Job Status: job has successfully run 84.841376 seconds spent TbypT_Birad_RT_Xband 16 {'0000': 16, '0001': 2, '0010': 15, '0011': 27, '0100': 137, '0101': 68, '0110': 21, '0111': 55, '1000': 86, '1001': 14, '1010': 100, '1011': 285, '1100': 62, '1101': 85, '1110': 11, '1111': 16} Running 1000 shots on ionq.qpu Job id c6a1f9de-a07a-11ec-9c83-d4258b36ead3 Job Status: job has successfully run 88.698110 seconds spent TbypT_Birad_RT_Xband 32 {'00000': 22, '00001': 29, '00010': 18, '00011': 36, '00100': 63, '00101': 57, '00110': 23, '00111': 57, '01000': 38, '01001': 29, '01010': 13, '01011': 26, '01100': 18, '01101': 25, '01110': 22, '01111': 43, '10000': 36, '10001': 35, '10010': 11, '10011': 26, '10100': 19, '10101': 14, '10110': 16, '10111': 57, '11000': 60, '11001': 50, '11010': 13, '11011': 33, '11100': 17, '11101': 22, '11110': 14, '11111': 58} Running 1000 shots on ionq.qpu Job id fc53c6c6-a07a-11ec-a037-d4258b36ead3 Job Status: job has successfully run 164.486788 seconds spent TbypT_Birad_RT_Xband 64 {'000000': 10, '000001': 14, '000010': 7, '000011': 13, '000100': 21, '000101': 9, '000110': 4, '000111': 16, '001000': 10, '001001': 23, '001010': 17, '001011': 13, '001100': 24, '001101': 12, '001110': 14, '001111': 16, '010000': 13, '010001': 17, '010010': 11, '010011': 14, '010100': 17, '010101': 11, '010110': 14, '010111': 16, '011000': 27, '011001': 15, '011010': 8, '011011': 16, '011100': 12, '011101': 14, '011110': 17, '011111': 18, '100000': 21, '100001': 17, '100010': 12, '100011': 19, '100100': 25, '100101': 13, '100110': 12, '100111': 18, '101000': 28, '101001': 12, '101010': 19, '101011': 17, '101100': 27, '101101': 25, '101110': 12, '101111': 23, '110000': 13, '110001': 13, '110010': 12, '110011': 16, '110100': 6, '110101': 13, '110110': 8, '110111': 16, '111000': 19, '111001': 18, '111010': 13, '111011': 18, '111100': 19, '111101': 21, '111110': 19, '111111': 13} Running 1000 shots on ionq.qpu Job id 5efa137e-a07b-11ec-a9be-d4258b36ead3 Job Status: job has successfully run 1066.211010 seconds spent Test_Birad_80K_Qband 16 {'0000': 63, '0001': 5, '0010': 20, '0011': 10, '0100': 49, '0101': 25, '0110': 7, '0111': 37, '1000': 76, '1001': 12, '1010': 113, '1011': 233, '1100': 155, '1101': 124, '1110': 13, '1111': 58} Running 1000 shots on ionq.qpu Job id db1d9da2-a07d-11ec-92b4-d4258b36ead3 Job Status: job has successfully run 354.299915 seconds spent Test_Birad_80K_Qband 32 {'00000': 24, '00001': 19, '00010': 16, '00011': 25, '00100': 29, '00101': 16, '00110': 9, '00111': 30, '01000': 24, '01001': 28, '01010': 13, '01011': 40, '01100': 21, '01101': 23, '01110': 9, '01111': 40, '10000': 38, '10001': 37, '10010': 19, '10011': 46, '10100': 59, '10101': 42, '10110': 18, '10111': 104, '11000': 62, '11001': 33, '11010': 14, '11011': 35, '11100': 27, '11101': 37, '11110': 28, '11111': 35} Running 1000 shots on ionq.qpu Job id aeef82fc-a07e-11ec-8789-d4258b36ead3 Job Status: job has successfully run 436.892359 seconds spent Test_Birad_80K_Qband 64 {'000000': 13, '000001': 14, '000010': 5, '000011': 9, '000100': 12, '000101': 15, '000110': 10, '000111': 10, '001000': 15, '001001': 14, '001010': 5, '001011': 6, '001100': 11, '001101': 8, '001110': 9, '001111': 9, '010000': 17, '010001': 30, '010010': 8, '010011': 13, '010100': 17, '010101': 14, '010110': 12, '010111': 17, '011000': 35, '011001': 16, '011010': 13, '011011': 10, '011100': 24, '011101': 5, '011110': 20, '011111': 13, '100000': 13, '100001': 10, '100010': 16, '100011': 10, '100100': 16, '100101': 17, '100110': 12, '100111': 13, '101000': 28, '101001': 29, '101010': 18, '101011': 22, '101100': 18, '101101': 11, '101110': 9, '101111': 33, '110000': 14, '110001': 17, '110010': 19, '110011': 20, '110100': 24, '110101': 15, '110110': 18, '110111': 18, '111000': 20, '111001': 20, '111010': 14, '111011': 18, '111100': 24, '111101': 20, '111110': 12, '111111': 23}
print("=============== Simulated ==========================")
show_subplots(fft_graphs, x_ranges=freq_ranges)
print("================= QPU ==============================")
show_subplots(qft2, x_ranges=freq_ranges)
=============== Simulated ==========================
================= QPU ==============================