diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3af52d88 --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +fi + +watch_file flake.nix +watch_file flake.lock +if ! use flake . --impure; then + echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 +fi diff --git a/.gitignore b/.gitignore index 68bc17f9..78526dda 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Nix +.devenv/ diff --git a/convert.py b/convert.py new file mode 100644 index 00000000..d71f3d71 --- /dev/null +++ b/convert.py @@ -0,0 +1,381 @@ +"""Converts parameters.json to parameters.json and calibration.json.""" + +import argparse +import ast +import json +from dataclasses import dataclass +from pathlib import Path +from typing import Callable, Optional + +import numpy as np +from pydantic import TypeAdapter +from qibolab._core.serialize import NdArray + +NONSERIAL = lambda: None +"""Raise an error if survives in the final object to be serialized.""" +QM_TIME_OF_FLIGHT = 224 +"""Default time of flight for QM platforms (in 0.1 this was hard-coded in +platform.py).""" + + +def channel_from_pulse(pulse: dict) -> dict: + return {"kind": "iq", "frequency": pulse["frequency"]} + + +@dataclass +class QmConnection: + instrument: str + port: str + output_mode: str = "triggered" + + +def configs( + instruments: dict, + single: dict, + couplers: dict, + characterization: dict, +) -> dict: + return ( + { + f"{k}/bounds": (v["bounds"] | {"kind": "bounds"}) + for k, v in instruments.items() + if "bounds" in v + } + | { + k: (v | {"kind": "oscillator"}) + for k, v in instruments.items() + if "twpa" in k + } + | { + channel(id, pulse["type"], gate=gate): channel_from_pulse(pulse) + for id, gates in single.items() + for gate, pulse in gates.items() + } + | { + channel(id, "ro"): { + "kind": "acquisition", + "delay": 0.0, + "smearing": 0.0, + "threshold": char["threshold"], + "iq_angle": char["iq_angle"], + "kernel": None, + } + for id, char in characterization["single_qubit"].items() + } + | { + channel(id, "qf"): {"kind": "dc", "offset": char["sweetspot"]} + for id, char in characterization["single_qubit"].items() + } + | { + channel(id, "coupler"): {"kind": "dc", "offset": char["sweetspot"]} + for id, char in characterization.get("coupler", {}).items() + } + ) + + +def channel(qubit: str, type_: str, gate: Optional[str] = None) -> str: + kind = ( + "flux" + if type_ == "qf" or type_ == "coupler" + else ( + "probe" + if gate == "MZ" + else ( + "acquisition" + if type_ == "ro" + else "drive12" if gate == "RX12" else "drive" + ) + ) + ) + element = qubit if type_ != "coupler" else f"coupler_{qubit}" + return f"{element}/{kind}" + + +SHAPES = { + "rectangular": {}, + "gaussian": {"rel_sigma": lambda s: 1 / s}, + "drag": {"rel_sigma": lambda s: 1 / s, "beta": lambda s: s}, + "custom": {"i_": lambda s: TypeAdapter(NdArray).dump_json(s).decode()}, +} + + +def envelope(o: str) -> dict: + expr = ast.parse(o).body[0] + assert isinstance(expr, ast.Expr) + call = expr.value + assert isinstance(call, ast.Call) + assert isinstance(call.func, ast.Name) + kind = call.func.id.lower() + kwargs = {} + shape = SHAPES[kind] + for arg, (attr, map_) in zip(call.args, shape.items()): + kwargs[attr] = map_(ast.literal_eval(arg)) + for arg in call.keywords: + assert isinstance(arg.value, ast.Constant) + kwargs[arg.arg] = ast.literal_eval(arg.value) + if kind == "custom" and "q_" not in kwargs: + kwargs["q_"] = ( + TypeAdapter(NdArray).dump_json(np.zeros_like(kwargs["i_"])).decode() + ) + return {"kind": kind, **kwargs} + + +def pulse(o: dict, rescale: float) -> dict: + return { + "kind": "pulse", + "duration": o["duration"], + "amplitude": rescale * o["amplitude"], + "envelope": envelope(o["shape"]), + "relative_phase": o.get("phase", 0.0), + } + + +def acquisition(o: dict, rescale: float) -> dict: + return { + "kind": "readout", + "acquisition": {"kind": "acquisition", "duration": o["duration"]}, + "probe": pulse(o, rescale), + } + + +def virtualz(o: dict) -> dict: + return {"kind": "virtualz", "phase": o["phase"]} + + +def pulse_like(o: dict, rescale: float) -> dict: + return ( + acquisition(o, rescale) + if o["type"] == "ro" + else virtualz(o) if o["type"] == "virtual_z" else pulse(o, rescale) + ) + + +def single_pulse(o: dict, rescale: float) -> dict: + return { + id: { + gid: [(channel(id, gate["type"]), pulse_like(gate, rescale))] + for gid, gate in gates.items() + } + for id, gates in o.items() + } + + +def two_qubit(o: dict, rescale: float) -> dict: + return { + id: { + gid: [ + ( + channel( + pulse.get("qubit", pulse.get("coupler", NONSERIAL)), + pulse["type"], + ), + pulse_like(pulse, rescale), + ) + for pulse in gate + ] + for gid, gate in gates.items() + } + for id, gates in o.items() + } + + +def natives(o: dict, rescale: float) -> dict: + return { + "single_qubit": single_pulse(o["single_qubit"], rescale), + "coupler": { + f"coupler_{k}": v + for k, v in single_pulse(o.get("coupler", {}), rescale).items() + }, + "two_qubit": two_qubit(o["two_qubit"], rescale), + } + + +def qm(conf: dict, instruments: dict, instrument_channels: dict) -> dict: + for channel, conn in instrument_channels.items(): + connection = QmConnection(**conn) + settings = instruments.get(connection.instrument, {}).get(connection.port, {}) + if channel in conf: + kind = conf[channel]["kind"] + if kind == "acquisition": + conf[channel].update( + { + "kind": "qm-acquisition", + "delay": QM_TIME_OF_FLIGHT, + "gain": settings.get("gain", 0), + } + ) + elif kind == "dc": + conf[channel].update( + { + "kind": "opx-output", + "filter": settings.get("filter", {}), + "output_mode": settings.get("output_mode", "direct"), + } + ) + else: + raise NotImplementedError + else: + conf[channel] = { + "kind": "octave-oscillator", + "frequency": settings["lo_frequency"], + "power": settings["gain"], + "output_mode": connection.output_mode, + } + return conf + + +def qblox(configs: dict, instruments: dict) -> dict: + MODS = {"qcm_bb", "qcm_rf", "qrm_rf"} + return ( + configs + | { + f"{inst}/{port}/lo": { + "kind": "oscillator", + "frequency": settings["lo_frequency"], + "power": settings["attenuation"], + } + for inst, ports in instruments.items() + if any(mod in inst for mod in MODS) + for port, settings in ports.items() + if "lo_frequency" in settings + } + | { + f"{inst}/{port}/mixer": { + "kind": "iq-mixer", + "offset_i": settings["mixer_calibration"][0], + "offset_q": settings["mixer_calibration"][1], + } + for inst, ports in instruments.items() + if any(mod in inst for mod in MODS) + for port, settings in ports.items() + if "mixer_calibration" in settings + } + ) + + +def device_specific( + o: dict, configs: dict, connections: Optional[dict] +) -> dict | Callable: + return ( + configs + if connections is None + else ( + qm(configs, o["instruments"], connections["channels"]) + if connections["kind"] == "qm" + else ( + qblox(configs, o["instruments"]) + if connections["kind"] == "qblox" + else NONSERIAL + ) + ) + ) + + +def upgrade(o: dict, connections: Optional[dict] = None) -> dict: + rescale = 2 if connections is not None and connections["kind"] == "qm" else 1 + return { + "settings": o["settings"], + "configs": device_specific( + o, + configs( + o["instruments"], + o["native_gates"]["single_qubit"], + o["native_gates"].get("coupler", {}), + o["characterization"], + ), + connections, + ), + "native_gates": natives(o["native_gates"], rescale), + } + + +def single_qubits_cal(o: dict) -> dict: + return { + q: { + "resonator": { + "bare_frequency": k["bare_resonator_frequency"], + "dressed_frequency": k["readout_frequency"], + }, + "qubit": { + "frequency_01": k["drive_frequency"], + "sweetspot": k["sweetspot"], + }, + "readout": { + "fidelity": k["readout_fidelity"], + "ground_state": k["mean_gnd_states"], + "excited_state": k["mean_exc_states"], + }, + "t1": [k["T1"], None], + "t2": [k["T2"], None], + "t2_spin_echo": [k["T2_spin_echo"], None], + "rb_fidelity": [k["gate_fidelity"], None] if "gate_fidelity" in k else None, + } + for q, k in o.items() + } + + +def two_qubits_cal(o: dict) -> dict: + return { + qq: { + "rb_fidelity": [k["gate_fidelity"], None], + "cz_fidelity": [k["cz_fidelity"], None], + } + for qq, k in o.items() + } + + +def upgrade_cal(o: dict) -> dict: + return { + "single_qubits": single_qubits_cal(o["characterization"]["single_qubit"]), + "two_qubits": ( + two_qubits_cal(o["characterization"]["two_qubit"]) + if "two_qubit" in o["characterization"] + else {} + ), + } + + +def convert(path: Path, args: argparse.Namespace): + params = json.loads(path.read_text()) + connections_path = ( + args.connections + if args.connections is not None + else ( + (path.parent / "connections.json") + if (path.parent / "connections.json").exists() + else None + ) + ) + connections = ( + json.loads(connections_path.read_text()) + if connections_path is not None + else None + ) + new = upgrade(params, connections) + cal = upgrade_cal(params) + path.with_stem(path.stem + "-new").write_text(json.dumps(new, indent=4)) + path.with_stem("calibration").write_text(json.dumps(cal, indent=4)) + + +def parse(): + parser = argparse.ArgumentParser() + parser.add_argument("path", nargs="*", type=Path) + parser.add_argument( + "--connections", + nargs="?", + default=None, + type=Path, + help="path to JSON file with connections", + ) + return parser.parse_args() + + +def main(): + args = parse() + + for p in args.path: + convert(p, args) + + +if __name__ == "__main__": + main() diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..bf265bdc --- /dev/null +++ b/flake.lock @@ -0,0 +1,673 @@ +{ + "nodes": { + "cachix": { + "inputs": { + "devenv": "devenv_2", + "flake-compat": [ + "devenv", + "flake-compat" + ], + "git-hooks": [ + "devenv", + "pre-commit-hooks" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726520618, + "narHash": "sha256-jOsaBmJ/EtX5t/vbylCdS7pWYcKGmWOKg4QKUzKr6dA=", + "owner": "cachix", + "repo": "cachix", + "rev": "695525f9086542dfb09fde0871dbf4174abbf634", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "cachix_2": { + "inputs": { + "devenv": "devenv_3", + "flake-compat": [ + "devenv", + "cachix", + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "pre-commit-hooks": [ + "devenv", + "cachix", + "devenv", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1712055811, + "narHash": "sha256-7FcfMm5A/f02yyzuavJe06zLa9hcMHsagE28ADcmQvk=", + "owner": "cachix", + "repo": "cachix", + "rev": "02e38da89851ec7fec3356a5c04bc8349cae0e30", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat_2", + "nix": "nix_3", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1730551965, + "narHash": "sha256-pZjOiaIW3AZinSmTCubFgoxRQzqmHFiOkHBJYZ1RdnA=", + "owner": "cachix", + "repo": "devenv", + "rev": "d3bb56ceaeef625712b050bd9343dbdb01bf37b1", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_2": { + "inputs": { + "cachix": "cachix_2", + "flake-compat": [ + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix_2", + "nixpkgs": [ + "devenv", + "cachix", + "nixpkgs" + ], + "pre-commit-hooks": [ + "devenv", + "cachix", + "git-hooks" + ] + }, + "locked": { + "lastModified": 1723156315, + "narHash": "sha256-0JrfahRMJ37Rf1i0iOOn+8Z4CLvbcGNwa2ChOAVrp/8=", + "owner": "cachix", + "repo": "devenv", + "rev": "ff5eb4f2accbcda963af67f1a1159e3f6c7f5f91", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_3": { + "inputs": { + "flake-compat": [ + "devenv", + "cachix", + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix", + "pre-commit-hooks": [ + "devenv", + "cachix", + "devenv", + "cachix", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1708704632, + "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", + "owner": "cachix", + "repo": "devenv", + "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "python-rewrite", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "libgit2": { + "flake": false, + "locked": { + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", + "type": "github" + }, + "original": { + "owner": "libgit2", + "repo": "libgit2", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870561, + "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nix_2": { + "inputs": { + "flake-compat": [ + "devenv", + "cachix", + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression_2" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix_3": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-23-11": "nixpkgs-23-11", + "nixpkgs-regression": "nixpkgs-regression_3", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1727438425, + "narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=", + "owner": "domenkozar", + "repo": "nix", + "rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.24", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-23-11": { + "locked": { + "lastModified": 1717159533, + "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1730504152, + "narHash": "sha256-lXvH/vOfb4aGYyvFmZK/HlsNsr/0CVWlwYvo2rxJk3s=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_2": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_3": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1730531603, + "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692876271, + "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "nix" + ], + "flake-utils": "flake-utils_2", + "gitignore": [ + "devenv", + "nix" + ], + "nixpkgs": [ + "devenv", + "nix", + "nixpkgs" + ], + "nixpkgs-stable": [ + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712897695, + "narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_3" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..91df8bed --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + devenv = { + url = "github:cachix/devenv"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = { + self, + nixpkgs, + devenv, + flake-parts, + ... + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [inputs.devenv.flakeModule]; + systems = ["x86_64-linux" "aarch64-darwin"]; + + perSystem = {pkgs, ...}: { + packages.default = pkgs.poetry2nix.mkPoetryApplication { + projectDir = self; + preferWheels = true; + }; + + devenv.shells.default = { + packages = with pkgs; [poethepoet pre-commit stdenv.cc.cc.lib]; + + languages = { + python = { + enable = true; + venv = { + enable = true; + requirements = '' + qibolab [qblox] @ git+https://github.com/qiboteam/qibolab.git@qblox + + # dev deps + ipython + pdbpp + ''; + }; + }; + }; + }; + }; + }; + + nixConfig = { + extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; + extra-substituters = "https://devenv.cachix.org"; + }; +} diff --git a/iqm5q/connections.json b/iqm5q/connections.json new file mode 100644 index 00000000..6b0e2ff4 --- /dev/null +++ b/iqm5q/connections.json @@ -0,0 +1,14 @@ +{ + "kind": "qblox", + "channels": { + "qrm_rf0": { "1": ["q0", "q1"] }, + "qrm_rf1": { "1": ["q2", "q3", "q4"] }, + "qcm_rf0": { "1": ["q1"], "2": ["q2"] }, + "qcm_rf1": { "1": ["q3"], "2": ["q4"] }, + "qcm_rf2": { "1": ["q0"] }, + "qcm0": { "1": ["q0"], "2": ["q1"], "3": ["q2"], "4": ["q3"] }, + "qcm1": { "1": ["q4"], "2": ["c1"], "4": ["c3"] }, + "qcm2": { "2": ["c4"] }, + "qcm3": { "1": ["c0"] } + } +} diff --git a/qw11q/connections.json b/qw11q/connections.json new file mode 100644 index 00000000..8de2d21a --- /dev/null +++ b/qw11q/connections.json @@ -0,0 +1,189 @@ +{ + "kind": "qm", + "channels": { + "A1A4/drive_lo": { + "instrument": "octave4", + "port": "o2" + }, + "A2A3/drive_lo": { + "instrument": "octave4", + "port": "o4" + }, + "A5D5/drive_lo": { + "instrument": "octave6", + "port": "o2" + }, + "A6D4/drive_lo": { + "instrument": "octave6", + "port": "o4" + }, + "B1/drive_lo": { + "instrument": "octave2", + "port": "o2" + }, + "B2/drive_lo": { + "instrument": "octave2", + "port": "o4" + }, + "B3/drive_lo": { + "instrument": "octave3", + "port": "o1" + }, + "B4/drive_lo": { + "instrument": "octave3", + "port": "o4" + }, + "B5/drive_lo": { + "instrument": "octave3", + "port": "o3" + }, + "D1/drive_lo": { + "instrument": "octave5", + "port": "o2" + }, + "D2D3/drive_lo": { + "instrument": "octave5", + "port": "o4" + }, + "A/probe_lo": { + "instrument": "octave4", + "port": "o1" + }, + "B/probe_lo": { + "instrument": "octave2", + "port": "o1" + }, + "D/probe_lo": { + "instrument": "octave5", + "port": "o1" + }, + "A1/flux": { + "instrument": "con7", + "port": "o3" + }, + "A2/flux": { + "instrument": "con7", + "port": "o4" + }, + "A3/flux": { + "instrument": "con7", + "port": "o5" + }, + "A4/flux": { + "instrument": "con7", + "port": "o6" + }, + "A5/flux": { + "instrument": "con7", + "port": "o7" + }, + "A6/flux": { + "instrument": "con7", + "port": "o8" + }, + "B1/flux": { + "instrument": "con4", + "port": "o1" + }, + "B2/flux": { + "instrument": "con4", + "port": "o2" + }, + "B3/flux": { + "instrument": "con4", + "port": "o3" + }, + "B4/flux": { + "instrument": "con4", + "port": "o4" + }, + "B5/flux": { + "instrument": "con4", + "port": "o5" + }, + "D1/flux": { + "instrument": "con9", + "port": "o3" + }, + "D2/flux": { + "instrument": "con9", + "port": "o4" + }, + "D3/flux": { + "instrument": "con9", + "port": "o5" + }, + "D4/flux": { + "instrument": "con9", + "port": "o6" + }, + "D5/flux": { + "instrument": "con9", + "port": "o7" + }, + "A1/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "A2/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "A3/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "A4/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "A5/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "A6/acquisition": { + "instrument": "con5", + "port": "i1" + }, + "B1/acquisition": { + "instrument": "con2", + "port": "i1" + }, + "B2/acquisition": { + "instrument": "con2", + "port": "i1" + }, + "B3/acquisition": { + "instrument": "con2", + "port": "i1" + }, + "B4/acquisition": { + "instrument": "con2", + "port": "i1" + }, + "B5/acquisition": { + "instrument": "con2", + "port": "i1" + }, + "D1/acquisition": { + "instrument": "con6", + "port": "i1" + }, + "D2/acquisition": { + "instrument": "con6", + "port": "i1" + }, + "D3/acquisition": { + "instrument": "con6", + "port": "i1" + }, + "D4/acquisition": { + "instrument": "con6", + "port": "i1" + }, + "D5/acquisition": { + "instrument": "con6", + "port": "i1" + } + } +} diff --git a/qw5q_platinum/connections.json b/qw5q_platinum/connections.json new file mode 100644 index 00000000..c7ada2c8 --- /dev/null +++ b/qw5q_platinum/connections.json @@ -0,0 +1,70 @@ +{ + "kind": "qm", + "channels": { + "01/drive_lo": { + "instrument": "octave1", + "port": "o2", + "output_mode": "always_on" + }, + "2/drive_lo": { + "instrument": "octave1", + "port": "o1", + "output_mode": "always_on" + }, + "3/drive_lo": { + "instrument": "octave1", + "port": "o4", + "output_mode": "always_on" + }, + "4/drive_lo": { + "instrument": "octave2", + "port": "o2", + "output_mode": "always_on" + }, + "probe_lo": { + "instrument": "octave2", + "port": "o1", + "output_mode": "always_on" + }, + "0/flux": { + "instrument": "con1", + "port": "4/o4" + }, + "1/flux": { + "instrument": "con1", + "port": "4/o1" + }, + "2/flux": { + "instrument": "con1", + "port": "4/o3" + }, + "3/flux": { + "instrument": "con1", + "port": "4/o2" + }, + "4/flux": { + "instrument": "con1", + "port": "4/o5" + }, + "0/acquisition": { + "instrument": "con1", + "port": "2/i1" + }, + "1/acquisition": { + "instrument": "con1", + "port": "2/i1" + }, + "2/acquisition": { + "instrument": "con1", + "port": "2/i1" + }, + "3/acquisition": { + "instrument": "con1", + "port": "2/i1" + }, + "4/acquisition": { + "instrument": "con1", + "port": "2/i1" + } + } +}