Skip to content

Commit

Permalink
fix: Attempt removing couplers hardcoding in qblox platform extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Dec 4, 2024
1 parent a62d812 commit d8c08e5
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/qibolab/_core/instruments/qblox/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
__all__ = ["map_ports"]


def _eltype(el: str):
return "qubits" if el[0] == "q" else "couplers"


def _chtype(mod: str, input: bool) -> tuple[str, type[Channel]]:
if mod.startswith("qcm_rf"):
return "drive", IqChannel
Expand All @@ -39,17 +35,13 @@ def _port_channels(mod: str, port: Union[int, str], slot: int) -> dict:


def _premap(cluster: dict):
d = {
"qubits": defaultdict(lambda: defaultdict(dict)),
"couplers": defaultdict(lambda: defaultdict(dict)),
}
d = defaultdict(lambda: defaultdict(dict))

for mod, props in cluster.items():
slot = props[0]
for port, els in props[1].items():
for el in els:
nel = el[1:]
d[_eltype(el)][nel] |= _port_channels(mod, port, slot)
d[el] |= _port_channels(mod, port, slot)

return d

Expand Down Expand Up @@ -86,12 +78,13 @@ def map_ports(cluster: dict, qubits: dict, couplers: Optional[dict] = None) -> d
premap = _premap(cluster)

channels = {}
for kind, elements in [("qubits", qubits), ("couplers", couplers)]:
for name, el in elements.items():
for chname, ch in premap[kind][name].items():
channels[getattr(el, chname)] = ch
if kind == "qubits":
channels[el.acquisition] = channels[el.acquisition].model_copy(
update={"probe": el.probe}
)
for name, el in (qubits | couplers).items():
for chname, ch in premap[name].items():
channels[getattr(el, chname)] = ch
try:
channels[el.acquisition] = channels[el.acquisition].model_copy(
update={"probe": el.probe}
)
except KeyError:
pass
return channels

0 comments on commit d8c08e5

Please sign in to comment.