Skip to content

Commit

Permalink
Fix kernel_folder path in load_qubits function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacfomg committed Dec 5, 2023
1 parent 4c1f0fe commit be0c312
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/qibolab/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def load_settings(runcard: dict) -> Settings:
return Settings(**runcard["settings"])


def load_path(runcard: dict) -> Path:
"""Load platform settings section from the runcard."""
return Path(runcard["kernel_folder"])


def load_qubits(runcard: dict) -> Tuple[QubitMap, CouplerMap, QubitPairMap]:
"""Load qubits and pairs from the runcard.
Expand All @@ -43,8 +48,8 @@ def load_qubits(runcard: dict) -> Tuple[QubitMap, CouplerMap, QubitPairMap]:
qubits = {q: Qubit(q, **char) for q, char in runcard["characterization"]["single_qubit"].items()}
if "kernel_folder" in runcard:
for qubit in qubits.values():
qubit.kernel_path = Path(
runcard["kernel_folder"] + runcard["characterization"]["single_qubit"][qubit.name]["kernel_path"]
qubit.kernel_path = (
Path(runcard["kernel_folder"]) / runcard["characterization"]["single_qubit"][qubit.name]["kernel_path"]
)

couplers = {}
Expand Down Expand Up @@ -115,9 +120,7 @@ def dump_qubits(qubits: QubitMap, pairs: QubitPairMap, couplers: CouplerMap = No
}
if kernel_folder:
for q in qubits:
characterization["single_qubit"][q]["kernel_path"] = str(
characterization["single_qubit"][q]["kernel_path"]
).replace(kernel_folder, "")
characterization["single_qubit"][q]["kernel_path"] = characterization["single_qubit"][q]["kernel_path"].name
if couplers:
characterization["coupler"] = {c.name: {"sweetspot": c.sweetspot} for c in couplers.values()}

Expand Down Expand Up @@ -156,7 +159,7 @@ def dump_runcard(platform: Platform, path: Path):
}

if platform.kernel_folder:
settings["kernel_folder"] = platform.kernel_folder
settings["kernel_folder"] = str(platform.kernel_folder)
if platform.couplers:
settings["couplers"] = list(platform.couplers)
settings["topology"] = {coupler: list(pair) for pair, coupler in zip(platform.pairs, platform.couplers)}
Expand Down
4 changes: 3 additions & 1 deletion tests/dummy_qrc/zurich.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from qibolab.instruments.zhinst import Zurich
from qibolab.serialize import (
load_instrument_settings,
load_path,
load_qubits,
load_runcard,
load_settings,
Expand Down Expand Up @@ -140,6 +141,7 @@ def create(runcard_path=RUNCARD):
runcard = load_runcard(runcard_path)
qubits, couplers, pairs = load_qubits(runcard)
settings = load_settings(runcard)
kernel_folder = load_path(runcard)

# assign channels to qubits and sweetspots(operating points)
for q in range(0, 5):
Expand All @@ -166,5 +168,5 @@ def create(runcard_path=RUNCARD):
settings,
resonator_type="2D",
couplers=couplers,
kernel_folder=KERNEL_FOLDER,
kernel_folder=kernel_folder,
)
2 changes: 1 addition & 1 deletion tests/dummy_qrc/zurich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ settings:
sampling_rate: 2.e+9
relaxation_time: 300_000

kernel_folder: "qibolab_platforms_qrc/iqm5q_kernels/"
kernel_folder: "qibolab_platforms_qrc/iqm5q_kernels"

instruments:
lo_readout:
Expand Down

0 comments on commit be0c312

Please sign in to comment.