Skip to content

Commit

Permalink
feat: add config for qcs classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
sorewachigauyo committed Nov 1, 2024
1 parent 8c279d1 commit 3a29ffa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/qibolab/_core/instruments/keysight/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from . import qcs
from . import components, qcs
from .components import *
from .qcs import *

__all__ = []
__all__ += qcs.__all__
__all__ += components.__all__
5 changes: 5 additions & 0 deletions src/qibolab/_core/instruments/keysight/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import configs
from .configs import *

__all__ = []
__all__ += configs.__all__
16 changes: 16 additions & 0 deletions src/qibolab/_core/instruments/keysight/components/configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Annotated, Literal, Optional

from pydantic import Field

from qibolab._core.components import AcquisitionConfig
from qibolab._core.serialize import NdArray

__all__ = ["QcsAcquisitionConfig"]


class QcsAcquisitionConfig(AcquisitionConfig):
"""Acquisition config for Keysight QCS."""

kind: Literal["qcs-acquisition"] = "qcs-acquisition"

state_iq_values: Annotated[Optional[NdArray], Field(repr=False)] = None
11 changes: 7 additions & 4 deletions src/qibolab/_core/instruments/keysight/qcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import defaultdict
from functools import reduce
from typing import ClassVar, Optional
from typing import ClassVar

import numpy as np
from keysight import qcs
Expand Down Expand Up @@ -37,8 +37,6 @@ class KeysightQCS(Controller):
"""Map of QCS virtual channels to QCS physical channels."""
virtual_channel_map: dict[ChannelId, qcs.Channels]
"""Map of Qibolab channel IDs to QCS virtual channels."""
classifier_map: Optional[dict[qcs.Channels, qcs.MinimumDistanceClassifier]] = {}
"""Map of QCS virtual acquisition channels to QCS state classifiers."""
sampling_rate: ClassVar[float] = (
qcs.SAMPLE_RATES[qcs.InstrumentEnum.M5300AWG] * NS_TO_S
)
Expand Down Expand Up @@ -86,6 +84,7 @@ def create_program(

if isinstance(channel, AcquisitionChannel):
probe_channel_id = channel.probe
classifier_reference = configs[channel_id].state_iq_values
process_acquisition_channel_pulses(
program=program,
pulses=sequence.channel(channel_id),
Expand All @@ -95,7 +94,11 @@ def create_program(
virtual_channel=virtual_channel,
probe_virtual_channel=self.virtual_channel_map[probe_channel_id],
sweeper_pulse_map=sweeper_pulse_map,
classifier=self.classifier_map.get(virtual_channel, None),
classifier=(
None
if classifier_reference is None
else qcs.MinimumDistanceClassifier(classifier_reference)
),
)

elif isinstance(channel, IqChannel):
Expand Down
6 changes: 3 additions & 3 deletions src/qibolab/instruments/keysight_qcs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Driver for Keysight Quantum Control System (QCS)."""

from qibolab._core.instruments.keysight import qcs
from qibolab._core.instruments.keysight.qcs import * # noqa: F403
from qibolab._core.instruments import keysight
from qibolab._core.instruments.keysight import * # noqa: F403

__all__ = []
__all__ += qcs.__all__
__all__ += keysight.__all__

0 comments on commit 3a29ffa

Please sign in to comment.