Skip to content

Commit

Permalink
fix: Scaffold address resolution and sequence processing
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Nov 3, 2024
1 parent 365e2d7 commit 1514f00
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/qibolab/_core/instruments/qblox/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,36 @@
from qibolab._core.identifier import Result
from qibolab._core.instruments.abstract import Controller
from qibolab._core.sequence import PulseSequence
from qibolab._core.serialize import Model
from qibolab._core.sweeper import ParallelSweepers

__all__ = []
from .sequence import Sequence

SAMPLING_RATE = 0
__all__ = ["Cluster"]

SAMPLING_RATE = 1


class PortAddress(Model):
module: int
port: int
input: bool = False

@classmethod
def from_path(cls, path: str):
"""Load address from :attr:`qibolab.Channel.path`."""
els = path.split("/")
assert len(els) == 2
return cls(module=int(els[0]), port=int(els[1][1:]), input=els[1][0] == "i")


class Cluster(Controller):
name: str
"""Device name.
As described in:
https://docs.qblox.com/en/main/getting_started/setup.html#connecting-to-multiple-instruments
"""
bounds: str = "qblox/bounds"

def connect(self):
Expand All @@ -30,4 +52,11 @@ def play(
options: ExecutionParameters,
sweepers: list[ParallelSweepers],
) -> dict[int, Result]:
results = {}
for ps in sequences:
seq = Sequence.from_pulses(ps, sweepers, options)
results |= self._execute([seq])
return results

def _execute(self, sequences: list[Sequence]) -> dict:
return {}
14 changes: 14 additions & 0 deletions src/qibolab/_core/instruments/qblox/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from pydantic import AfterValidator, PlainSerializer, PlainValidator

from qibolab._core.execution_parameters import ExecutionParameters
from qibolab._core.sequence import PulseSequence
from qibolab._core.serialize import ArrayList, Model
from qibolab._core.sweeper import ParallelSweepers

from .ast_ import Program
from .parse import parse
Expand Down Expand Up @@ -30,3 +33,14 @@ class Sequence(Model):
program: Annotated[
Program, PlainSerializer(lambda p: p.asm()), PlainValidator(parse)
]

@classmethod
def from_pulses(
cls,
sequence: PulseSequence,
sweepers: list[ParallelSweepers],
options: ExecutionParameters,
):
return cls(
waveforms={}, weights={}, acquisitions={}, program=Program(elements=[])
)

0 comments on commit 1514f00

Please sign in to comment.