Skip to content

Commit

Permalink
feat: Allow instruments to report their names to the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Aug 13, 2024
1 parent 779155e commit 6a8354f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/qibolab/dummy/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@

def create_dummy():
"""Create a dummy platform using the dummy instrument."""
# register the instruments
instrument = DummyInstrument("dummy", "0.0.0.0")
twpa_pump = DummyLocalOscillator("twpa_pump", "0.0.0.0")

twpa_pump_name = "twpa_pump"
twpa_pump = DummyLocalOscillator(twpa_pump_name, "0.0.0.0")
platform = Platform.load(path=FOLDER, instruments=[instrument, twpa_pump])

platform = Platform.load(
path=FOLDER,
instruments={instrument.name: instrument, twpa_pump.name: twpa_pump},
)
# attach the channels
for q, qubit in platform.qubits.items():
acquisition_name = f"qubit_{q}/acquire"
probe_name = f"qubit_{q}/probe"
qubit.probe = IqChannel(
probe_name, mixer=None, lo=None, acquisition=acquisition_name
)
qubit.acquisition = AcquireChannel(
acquisition_name, twpa_pump=twpa_pump_name, probe=probe_name
acquisition_name, twpa_pump=twpa_pump.name, probe=probe_name
)

drive_name = f"qubit_{q}/drive"
Expand Down
12 changes: 10 additions & 2 deletions src/qibolab/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import json
from collections import defaultdict
from collections.abc import Iterable
from dataclasses import dataclass, field
from math import prod
from pathlib import Path
from typing import Any, Literal, Optional, TypeVar
from typing import Any, Literal, Optional, TypeVar, Union

from qibo.config import log, raise_error

Expand Down Expand Up @@ -322,10 +323,17 @@ def execute(
return results

@classmethod
def load(cls, path: Path, instruments: InstrumentMap, name: Optional[str] = None):
def load(
cls,
path: Path,
instruments: Union[InstrumentMap, Iterable[Instrument]],
name: Optional[str] = None,
):
"""Dump platform."""
if name is None:
name = path.name
if not isinstance(instruments, dict):
instruments = {i.name: i for i in instruments}

return cls(
name=name,
Expand Down

0 comments on commit 6a8354f

Please sign in to comment.