Skip to content

Commit

Permalink
Add kernel path to Qubit class and update Zurich
Browse files Browse the repository at this point in the history
Controller to use kernel path
  • Loading branch information
Jacfomg committed Dec 5, 2023
1 parent 0859a58 commit 4a920cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 9 additions & 11 deletions src/qibolab/instruments/zhinst.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def __init__(self, name, device_setup, use_emulation=False, time_of_flight=0.0,
self.smearing = smearing
self.chip = "iqm5q"
"Parameters read from the runcard not part of ExecutionParameters"
self.kernels = defaultdict(Path)

self.exp = None
self.experiment = None
Expand Down Expand Up @@ -431,17 +432,16 @@ def register_readout_line(self, qubit, intermediate_frequency, options):
self.signal_map[f"acquire{q}"] = self.device_setup.logical_signal_groups[f"q{q}"].logical_signals[
"acquire_line"
]
# weights_file = KERNELS_FOLDER / str(self.chip) / "weights" / f"kernels_q{q}.npz"
weights_file = qubit.kernel_path / f"kernels_q{q}.npz"
if weights_file.is_file() and options.acquisition_type == AcquisitionType.DISCRIMINATION:
# Remove software modulation as it's already included on the kernels
print("aqui")

if qubit.kernel_path:
self.kernels[q] = qubit.kernel_path / f"kernels_q{q}.npz"
if self.kernels[q].is_file() and options.acquisition_type == AcquisitionType.DISCRIMINATION:
self.calibration[f"/logical_signal_groups/q{q}/acquire_line"] = lo.SignalCalibration(
oscillator=None,
range=qubit.feedback.power_range,
port_delay=self.time_of_flight * NANO_TO_SECONDS,
)
elif weights_file.is_file() and not options.acquisition_type == AcquisitionType.DISCRIMINATION:
elif self.kernels[q].is_file() and not options.acquisition_type == AcquisitionType.DISCRIMINATION:
self.calibration[f"/logical_signal_groups/q{q}/acquire_line"] = lo.SignalCalibration(
oscillator=lo.Oscillator(
frequency=intermediate_frequency,
Expand All @@ -451,7 +451,7 @@ def register_readout_line(self, qubit, intermediate_frequency, options):
port_delay=self.time_of_flight * NANO_TO_SECONDS,
threshold=qubit.threshold, # To keep compatibility with angle and threshold discrimination
)
elif not weights_file.is_file() and not options.acquisition_type == AcquisitionType.DISCRIMINATION:
elif not self.kernels[q].is_file() and not options.acquisition_type == AcquisitionType.DISCRIMINATION:
self.calibration[f"/logical_signal_groups/q{q}/acquire_line"] = lo.SignalCalibration(
oscillator=lo.Oscillator(
frequency=intermediate_frequency,
Expand Down Expand Up @@ -950,10 +950,8 @@ def measure_relax(self, exp, qubits, relaxation_time, acquisition_type):
time=self.smearing * NANO_TO_SECONDS,
)

# weights_file = KERNELS_FOLDER / str(self.chip) / "weights" / f"kernels_q{q}.npz"
weights_file = qubits[q].kernel_path / f"kernels_q{q}.npz"
if weights_file.is_file() and acquisition_type == lo.AcquisitionType.DISCRIMINATION:
kernels = np.load(weights_file)
if self.kernels[q].is_file() and acquisition_type == lo.AcquisitionType.DISCRIMINATION:
kernels = np.load(self.kernels[q])
weight = lo.pulse_library.sampled_pulse_complex(
uid="weight" + str(q),
samples=kernels[str(q)] * np.exp(1j * iq_angle),
Expand Down
3 changes: 1 addition & 2 deletions src/qibolab/qubits.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Qubit:
"""

name: QubitId
kernel_path: Optional[Path] = None

bare_resonator_frequency: int = 0
readout_frequency: int = 0
Expand Down Expand Up @@ -90,8 +91,6 @@ class Qubit:

native_gates: SingleQubitNatives = field(default_factory=SingleQubitNatives)

kernel_path: Optional[Path] = None

@property
def channels(self):
for name in CHANNEL_NAMES:
Expand Down
3 changes: 3 additions & 0 deletions src/qibolab/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def load_qubits(runcard: dict) -> Tuple[QubitMap, CouplerMap, QubitPairMap]:
objects.
"""
qubits = {q: Qubit(q, **char) for q, char in runcard["characterization"]["single_qubit"].items()}
if runcard["kernel_path"]:
for qubit in qubits.values():
qubit.kernel_path = Path(runcard["kernel_path"])

couplers = {}
pairs = {}
Expand Down

0 comments on commit 4a920cc

Please sign in to comment.