Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop start() and stop() in each qblox module #740

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions src/qibolab/instruments/qblox/cluster_qcm_bb.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,32 +740,19 @@ def play_sequence(self):
# Start used sequencers
self.device.start_sequencer(sequencer_number)

def start(self):
"""Empty method to comply with Instrument interface."""
pass

def stop(self):
"""Stops all sequencers."""

def disconnect(self):
"""Stops all sequencers, disconnect all the outputs from the AWG paths
of the sequencers."""
if not self.is_connected:
return
for sequencer_number in self._used_sequencers_numbers:
state = self.device.get_sequencer_state(sequencer_number)
if state.status != "STOPPED":
log.warning(
f"Device {self.device.sequencers[sequencer_number].name} did not stop normally\nstate: {state}"
)
try:
self.device.stop_sequencer()
except:
log.warning("Unable to stop sequencers")

try:
for port in self._ports:
self._ports[port].offset = 0

except:
log.warning("Unable to clear offsets")

def disconnect(self):
"""Empty method to comply with Instrument interface."""
self.device.stop_sequencer()
self.device.disconnect_outputs()
self.is_connected = False
self.device = None
23 changes: 9 additions & 14 deletions src/qibolab/instruments/qblox/cluster_qcm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from qblox_instruments.qcodes_drivers.cluster import Cluster as QbloxCluster
from qblox_instruments.qcodes_drivers.qcm_qrm import QcmQrm as QbloxQrmQcm
from qibo.config import log

from qibolab.instruments.qblox.module import ClusterModule
from qibolab.instruments.qblox.q1asm import (
Expand Down Expand Up @@ -739,26 +740,20 @@ def play_sequence(self):
# Start used sequencers
self.device.start_sequencer(sequencer_number)

def start(self):
"""Empty method to comply with Instrument interface."""
pass

def stop(self):
"""Stops all sequencers."""
from qibo.config import log

def disconnect(self):
"""Stops all sequencers, disconnect all the outputs from the AWG paths
of the sequencers."""
if not self.is_connected:
return
for sequencer_number in self._used_sequencers_numbers:
state = self.device.get_sequencer_state(sequencer_number)
if state.status != "STOPPED":
log.warning(
f"Device {self.device.sequencers[sequencer_number].name} did not stop normally\nstate: {state}"
)
try:
self.device.stop_sequencer()
except:
log.warning("Unable to stop sequencers")

def disconnect(self):
"""Empty method to comply with Instrument interface."""
self.device.stop_sequencer()
self.device.disconnect_outputs()

self.is_connected = False
self.device = None
27 changes: 16 additions & 11 deletions src/qibolab/instruments/qblox/cluster_qrm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,18 +1017,23 @@ def acquire(self):
# TODO: to be updated once the functionality of ExecutionResults is extended
return {key: acquisition.data for key, acquisition in acquisitions.items()}

def start(self):
"""Empty method to comply with Instrument interface."""
pass
def disconnect(self):
"""Stops all sequencers, disconnect all the outputs from the AWG paths
of the sequencers and disconnect all the inputs from the acquisition
paths of the sequencers."""

def stop(self):
"""Stops all sequencers."""
try:
self.device.stop_sequencer()
except:
raise RuntimeError(f"Error stopping sequencer for {self.device.name}")
if not self.is_connected:
return

for sequencer_number in self._used_sequencers_numbers:
state = self.device.get_sequencer_state(sequencer_number)
if state.status != "STOPPED":
log.warning(
f"Device {self.device.sequencers[sequencer_number].name} did not stop normally\nstate: {state}"
)
alecandido marked this conversation as resolved.
Show resolved Hide resolved
self.device.stop_sequencer()
self.device.disconnect_outputs()
self.device.disconnect_inputs()

def disconnect(self):
"""Empty method to comply with Instrument interface."""
self.is_connected = False
self.device = None
8 changes: 3 additions & 5 deletions src/qibolab/instruments/qblox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def connect(self):
# Connect modules
for module in self.modules.values():
module.connect(self.cluster)
module.start()
self.is_connected = True
log.info("QbloxController: all modules connected.")

Expand All @@ -69,7 +68,6 @@ def disconnect(self):
"""Disconnects all modules."""
if self.is_connected:
for module in self.modules.values():
module.stop()
module.disconnect()
self.cluster.close()
self.is_connected = False
Expand All @@ -85,11 +83,11 @@ def _termination_handler(self, signum, frame):
"""Calls all modules to stop if the program receives a termination
signal."""

log.warning("Termination signal received, stopping modules.")
log.warning("Termination signal received, disconnecting modules.")
if self.is_connected:
for name in self.modules:
self.modules[name].stop()
log.warning("QbloxController: all modules stopped.")
self.modules[name].disconnect()
log.warning("QbloxController: all modules are disconnected.")
exit(0)

def _set_module_channel_map(self, module: ClusterQRM_RF, qubits: dict):
Expand Down
7 changes: 0 additions & 7 deletions tests/test_instruments_qblox_cluster_qcm_bb.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,3 @@ def test_sweepers(connected_platform, connected_qcm_bb: ClusterQCM_BB):
)
connected_qcm_bb.upload()
connected_qcm_bb.play_sequence()


@pytest.mark.qpu
def test_start_stop(connected_qcm_bb: ClusterQCM_BB):
connected_qcm_bb.start()
connected_qcm_bb.stop()
# check all sequencers are stopped and all offsets = 0
7 changes: 0 additions & 7 deletions tests/test_instruments_qblox_cluster_qcm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,3 @@ def test_sweepers(connected_platform, connected_qcm_rf: ClusterQCM_RF):
)
connected_qcm_rf.upload()
connected_qcm_rf.play_sequence()


@pytest.mark.qpu
def test_start_stop(connected_qcm_rf: ClusterQCM_RF):
connected_qcm_rf.start()
connected_qcm_rf.stop()
# check all sequencers are stopped and all offsets = 0
7 changes: 0 additions & 7 deletions tests/test_instruments_qblox_cluster_qrm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,3 @@ def test_sweepers(connected_platform, connected_qrm_rf: ClusterQRM_RF):

def test_process_acquisition_results():
pass


@pytest.mark.qpu
def test_start_stop(connected_qrm_rf: ClusterQRM_RF):
connected_qrm_rf.start()
connected_qrm_rf.stop()
# check all sequencers are stopped and all offsets = 0