Skip to content

Commit

Permalink
Merge pull request #732 from qiboteam/sampling_rate
Browse files Browse the repository at this point in the history
Sampling rate as platform property
  • Loading branch information
stavros11 authored Jan 3, 2024
2 parents e6441d1 + 4287f8e commit 402f550
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/qibolab/instruments/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def __init__(self, name, address):
super().__init__(name, address)
self._ports = {}

@property
@abstractmethod
def sampling_rate(self):
"""Sampling rate of control electronics in giga samples per second
(GSps)."""

def __getitem__(self, port_name):
return self.ports(port_name)

Expand Down
4 changes: 4 additions & 0 deletions src/qibolab/instruments/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class DummyInstrument(Controller):

PortType = DummyPort

@property
def sampling_rate(self):
return SAMPLING_RATE

def connect(self):
log.info(f"Connecting to {self.name} instrument.")

Expand Down
5 changes: 5 additions & 0 deletions src/qibolab/instruments/qblox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from qibolab.instruments.qblox.cluster_qcm_bb import ClusterQCM_BB
from qibolab.instruments.qblox.cluster_qcm_rf import ClusterQCM_RF
from qibolab.instruments.qblox.cluster_qrm_rf import ClusterQRM_RF
from qibolab.instruments.qblox.sequencer import SAMPLING_RATE
from qibolab.instruments.unrolling import batch_max_sequences
from qibolab.pulses import PulseSequence, PulseType
from qibolab.sweeper import Parameter, Sweeper, SweeperType
Expand Down Expand Up @@ -38,6 +39,10 @@ def __init__(
self._reference_clock = "internal" if internal_reference_clock else "external"
signal.signal(signal.SIGTERM, self._termination_handler)

@property
def sampling_rate(self):
return SAMPLING_RATE

def connect(self):
"""Connects to the modules."""

Expand Down
6 changes: 5 additions & 1 deletion src/qibolab/instruments/qm/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from qibolab import AveragingMode
from qibolab.instruments.abstract import Controller

from .config import IQPortId, QMConfig, QMPort
from .config import SAMPLING_RATE, IQPortId, QMConfig, QMPort
from .sequence import Sequence
from .sweepers import sweep

Expand Down Expand Up @@ -57,6 +57,10 @@ class QMOPX(Controller):
def __post_init__(self):
super().__init__(self.name, self.address)

@property
def sampling_rate(self):
return SAMPLING_RATE

def connect(self):
"""Connect to the QM manager."""
host, port = self.address.split(":")
Expand Down
6 changes: 5 additions & 1 deletion src/qibolab/instruments/rfsoc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def __init__(self, name: str, address: str, port: int, sampling_rate: float = 1.
self.host = address
self.port = port
self.cfg = rfsoc.Config()
self.sampling_rate = sampling_rate
self._sampling_rate = sampling_rate

@property
def sampling_rate(self):
return self._sampling_rate

def connect(self):
"""Empty method to comply with Instrument interface."""
Expand Down
4 changes: 4 additions & 0 deletions src/qibolab/instruments/zhinst.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ def __init__(
self._ports = {}
self.settings = None

@property
def sampling_rate(self):
return SAMPLING_RATE

def connect(self):
if self.is_connected is False:
# To fully remove logging #configure_logging=False
Expand Down
8 changes: 8 additions & 0 deletions src/qibolab/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def nqubits(self) -> int:
]
)

@property
def sampling_rate(self):
"""Sampling rate of control electronics in giga samples per second
(GSps)."""
for instrument in self.instruments.values():
if isinstance(instrument, Controller):
return instrument.sampling_rate

def connect(self):
"""Connect to all instruments."""
if not self.is_connected:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def test_create_platform_error():
platform = create_platform("nonexistent")


def test_platform_sampling_rate(platform):
assert platform.sampling_rate >= 1


@pytest.mark.xfail(reason="Cannot pickle all platforms")
def test_platform_pickle(platform):
serial = pickle.dumps(platform)
Expand Down

0 comments on commit 402f550

Please sign in to comment.