From e288bd2c0f996cb3851abe93a63b09fee4fceb42 Mon Sep 17 00:00:00 2001 From: Stavros Efthymiou <35475381+stavros11@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:05:02 +0400 Subject: [PATCH 1/3] fix: close QM when disconnecting --- src/qibolab/instruments/qm/controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qibolab/instruments/qm/controller.py b/src/qibolab/instruments/qm/controller.py index aea41b4cb..eabf518f5 100644 --- a/src/qibolab/instruments/qm/controller.py +++ b/src/qibolab/instruments/qm/controller.py @@ -209,13 +209,14 @@ def connect(self): self.manager = QuantumMachinesManager( host=host, port=int(port), octave=octave, credentials=credentials ) + self.is_connected = True def setup(self): """Deprecated method.""" def disconnect(self): """Disconnect from QM manager.""" - if self.is_connected: + if self.manager is not None: self.manager.close_all_quantum_machines() self.manager.close() self.is_connected = False From 6496316f7da0b8346c847fde841d2c6446f78885 Mon Sep 17 00:00:00 2001 From: Stavros Efthymiou <35475381+stavros11@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:05:23 +0400 Subject: [PATCH 2/3] fix: alignment when sweeping duration of baked pulses --- src/qibolab/instruments/qm/sweepers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qibolab/instruments/qm/sweepers.py b/src/qibolab/instruments/qm/sweepers.py index e23b79ebe..3110e1f3d 100644 --- a/src/qibolab/instruments/qm/sweepers.py +++ b/src/qibolab/instruments/qm/sweepers.py @@ -194,11 +194,12 @@ def _sweep_duration(sweepers, qubits, qmsequence, relaxation_time): qmpulse = qmsequence.pulse_to_qmpulse[pulse.serial] qmpulse.swept_duration = dur # find all pulses that are connected to ``qmpulse`` and align them - to_process = set(qmpulse.next_) - while to_process: - next_qmpulse = to_process.pop() - to_process |= next_qmpulse.next_ - qmpulse.elements_to_align.add(next_qmpulse.element) - next_qmpulse.wait_time -= qmpulse.wait_time + qmpulse.duration // 4 + if not isinstance(qmpulse, BakedPulse): + to_process = set(qmpulse.next_) + while to_process: + next_qmpulse = to_process.pop() + to_process |= next_qmpulse.next_ + qmpulse.elements_to_align.add(next_qmpulse.element) + next_qmpulse.wait_time -= qmpulse.wait_time + qmpulse.duration // 4 _sweep_recursion(sweepers[1:], qubits, qmsequence, relaxation_time) From af91db94027f3e36169e107922212c4843fdef8b Mon Sep 17 00:00:00 2001 From: Stavros Efthymiou <35475381+stavros11@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:33:16 +0400 Subject: [PATCH 3/3] fix: disconnect after circuit execution and remove LO destructors --- src/qibolab/backends.py | 5 +++++ src/qibolab/instruments/erasynth.py | 3 --- src/qibolab/instruments/rohde_schwarz.py | 3 --- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/qibolab/backends.py b/src/qibolab/backends.py index 8c4d49c56..8690e1c1b 100644 --- a/src/qibolab/backends.py +++ b/src/qibolab/backends.py @@ -102,6 +102,9 @@ def execute_circuit(self, circuit, initial_state=None, nshots=1000): sequence, ExecutionParameters(nshots=nshots), ) + + self.platform.disconnect() + result = MeasurementOutcomes(circuit.measurements, self, nshots=nshots) self.assign_measurements(measurement_map, readout) return result @@ -149,6 +152,8 @@ def execute_circuits(self, circuits, initial_state=None, nshots=1000): ExecutionParameters(nshots=nshots), ) + self.platform.disconnect() + results = [] readout = {k: deque(v) for k, v in readout.items()} for circuit, measurement_map in zip(circuits, measurement_maps): diff --git a/src/qibolab/instruments/erasynth.py b/src/qibolab/instruments/erasynth.py index a0dd3dbdd..9f4b13652 100644 --- a/src/qibolab/instruments/erasynth.py +++ b/src/qibolab/instruments/erasynth.py @@ -136,6 +136,3 @@ def create(self): return ERASynthEthernet(self.name, self.address) else: return ERASynthPlusPlus(f"{self.name}", f"TCPIP::{self.address}::INSTR") - - def __del__(self): - self.disconnect() diff --git a/src/qibolab/instruments/rohde_schwarz.py b/src/qibolab/instruments/rohde_schwarz.py index 247cfaea7..3658949fd 100644 --- a/src/qibolab/instruments/rohde_schwarz.py +++ b/src/qibolab/instruments/rohde_schwarz.py @@ -14,6 +14,3 @@ def create(self): return LO_SGS100A.RohdeSchwarz_SGS100A( self.name, f"TCPIP0::{self.address}::5025::SOCKET" ) - - def __del__(self): - self.disconnect()