Skip to content

Commit

Permalink
nano second conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerthrower committed May 6, 2024
1 parent 778421a commit 7c1eafa
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
10 changes: 5 additions & 5 deletions src/mqt/bench/calibration_files/iqm_adonis_calibration.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
[2, 4]
],
"error": {
"1q": {
"one_q": {
"0": 0.0006,
"1": 0.0054,
"2": 0.0001,
"3": 0.0,
"4": 0.0005
},
"2q": {
"two_q": {
"0-2": 0.0335,
"1-2": 0.0344,
"3-2": 0.0192,
Expand Down Expand Up @@ -49,8 +49,8 @@
"3": 26000.0,
"4": 7000.0
},
"1q": 0.00000004,
"2q": 0.00000008,
"readout": 0.000015
"one_q": 40.0,
"two_q": 80.0,
"readout": 15000.0
}
}
10 changes: 5 additions & 5 deletions src/mqt/bench/calibration_files/iqm_apollo_calibration.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
[18, 19]
],
"error": {
"1q": {
"one_q": {
"0": 0.00116,
"1": 0.00102,
"2": 0.00182,
Expand All @@ -57,7 +57,7 @@
"18": 0.0016,
"19": 0.00115
},
"2q": {
"two_q": {
"0-1": 0.012,
"0-3": 0.0121,
"1-4": 0.0102,
Expand Down Expand Up @@ -157,8 +157,8 @@
"18": 8200.0,
"19": 12000.0
},
"1q": 0.000000042,
"2q": 0.00000013,
"readout": 0.000015
"one_q": 42.0,
"two_q": 130.0,
"readout": 15000.0
}
}
1 change: 1 addition & 0 deletions src/mqt/bench/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from mqt.bench.devices.rigetti import RigettiProvider
from mqt.bench.devices.iqm import IQMProvider


class NotFoundError(Exception):
"""Raised when a device or provider is not found within the available ones."""

Expand Down
53 changes: 37 additions & 16 deletions src/mqt/bench/devices/iqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@

from mqt.bench.devices import Device, DeviceCalibration, Provider

Fidelity = TypedDict("Fidelity", {"1q": float, "2q": float, "readout": float})
Timing = TypedDict("Timing", {"t1": float, "t2": float, "1q": float, "2q": float, "readout": float})

class Infidelity(TypedDict):
one_q: dict[str, float]
two_q: dict[str, float]
readout: dict[str, float]


class Timing(TypedDict):
t1: dict[str, float]
t2: dict[str, float]
one_q: float
two_q: float
readout: float


class IQMCalibration(TypedDict):
Expand All @@ -20,7 +31,7 @@ class IQMCalibration(TypedDict):
name: str
basis_gates: list[str]
connectivity: list[list[int]]
fidelity: Fidelity
error: Infidelity
num_qubits: int
timing: Timing

Expand Down Expand Up @@ -60,24 +71,34 @@ def import_backend(cls, path: Path) -> Device:
calibration = DeviceCalibration()
for qubit in range(device.num_qubits):
calibration.single_qubit_gate_fidelity[qubit] = dict.fromkeys(
["r"], 1. - iqm_calibration["error"]["1q"][str(qubit)]
["r"], 1.0 - iqm_calibration["error"]["one_q"][str(qubit)]
)
calibration.single_qubit_gate_duration[qubit] = dict.fromkeys(
["r"], iqm_calibration["timing"]["1q"]
["r"],
iqm_calibration["timing"]["one_q"] * 1e-9, # ns to s
)
calibration.readout_fidelity[qubit] = iqm_calibration["error"]["readout"][str(qubit)]
calibration.readout_duration[qubit] = iqm_calibration["timing"]["readout"]
calibration.t1[qubit] = iqm_calibration["timing"]["t1"][str(qubit)]
calibration.t2[qubit] = iqm_calibration["timing"]["t2"][str(qubit)]
calibration.readout_fidelity[qubit] = 1.0 - iqm_calibration["error"]["readout"][str(qubit)]
calibration.readout_duration[qubit] = iqm_calibration["timing"]["readout"] * 1e-9 # ns to s
calibration.t1[qubit] = iqm_calibration["timing"]["t1"][str(qubit)] * 1e-9 # ns to s
calibration.t2[qubit] = iqm_calibration["timing"]["t2"][str(qubit)] * 1e-9 # ns to s

for qubit1, qubit2 in device.coupling_map:
if (qubit1, qubit2) in calibration.two_qubit_gate_fidelity.keys():
continue # Skip reverse direction
calibration.two_qubit_gate_fidelity[(qubit1, qubit2)] = {"cz": 1. - iqm_calibration["error"]["2q"][str(qubit1) + '-' + str(qubit2)]}
calibration.two_qubit_gate_duration[(qubit1, qubit2)] = {"cz": iqm_calibration["timing"]["2q"]}
if (qubit1, qubit2) in calibration.two_qubit_gate_fidelity:
continue # Skip reverse direction
calibration.two_qubit_gate_fidelity[(qubit1, qubit2)] = {
"cz": 1.0 - iqm_calibration["error"]["two_q"][str(qubit1) + "-" + str(qubit2)]
}
calibration.two_qubit_gate_duration[(qubit1, qubit2)] = {
"cz": iqm_calibration["timing"]["two_q"] * 1e-9 # ns to s
}

# Same values for the reverse direction
calibration.two_qubit_gate_fidelity[(qubit2, qubit1)] = calibration.two_qubit_gate_fidelity[(qubit1, qubit2)]
calibration.two_qubit_gate_duration[(qubit2, qubit1)] = calibration.two_qubit_gate_duration[(qubit1, qubit2)]

calibration.two_qubit_gate_fidelity[(qubit2, qubit1)] = calibration.two_qubit_gate_fidelity[
(qubit1, qubit2)
]
calibration.two_qubit_gate_duration[(qubit2, qubit1)] = calibration.two_qubit_gate_duration[
(qubit1, qubit2)
]

device.calibration = calibration
return device

0 comments on commit 7c1eafa

Please sign in to comment.