The Node Registry#

The node registry stores the information about all available nodes: their category, node class, analysis class, documentation page, and, for every variant of a node, its default QOI class, the parameter values that define it, and the calibration parameters it requires and produces.

Why is this needed? Because one Python class can sometimes run more than one calibration, so the class name alone isn’t enough to say exactly which one you get.

Take RabiOscillations as an example. This single class can drive either the qubit’s 0→1 transition or its 1→2 transition — which one actually happens depends on two extra settings you pass in when you build the node: a transition parameter, and which “QOI” class (the class that stores the result) is used. So if someone just tells you “I ran RabiOscillations”, you still don’t know which of the two calibrations they mean — you’d also need to know those extra settings.

A registry variant solves this by bundling all of it together — the class and the settings that pin down one specific calibration — under one short, memorable name. For example, rabi_oscillations means “run RabiOscillations with its normal 0→1 defaults”, while rabi_oscillations_12 means “run that same class, but fixed to the 1→2 transition, with the matching QOI class”. Two different names, same underlying class, no ambiguity.

The Registry YAML file#

bragi_quantum.experiments/nodes.yaml is the single source of truth for every variant bragi_quantum.experiments ships. It is organized in three levels, under a top-level nodes: key:

  • a category, mirroring the folder layout under bragi_quantum.experiments/nodes/. It gives the package that every class path in it is relative to, and its entries;

  • an entry, one per node class: node (the node class), analysis (its analysis class), an optional doc and the list of variants;

  • a variant, one per registry name: name, qoi, and the optional fields below.

nodes:
  qubit_control:
    package: "bragi_quantum.experiments.nodes.qubit_control"
    entries:
      rabi_oscillations:
        node: "rabi_oscillations.node:RabiOscillations"
        analysis: "rabi_oscillations.analysis:RabiAnalysis"
        doc: "rabi_oscillations_node"
        variants:
          - name: "rabi_oscillations"
            parameters: { transition: "01" }
            qoi: "rabi_oscillations.parameters:Rabi01QOI"
            requires:
              measure_gate_class: "Measure"
              calibrated_gates: []
              calibrated_parameters: ["clock_freqs:f01"]
            calibrates: ["rxy:amp180"]
            show_in_graph: true
          - name: "rabi_oscillations_12"
            parameters: { transition: "12" }
            qoi: "rabi_oscillations.parameters:Rabi12QOI"
            requires:
              measure_gate_class: "Measure_RO1"
              calibrated_gates: ["X"]
              calibrated_parameters: ["clock_freqs:f12"]
            calibrates: ["r12:ef_amp180"]
            show_in_graph: true

The two variants share one entry — and therefore one node class and one analysis class — but are two different registry names: rabi_oscillations_12 fixes transition: "12" and swaps in a transition-specific QOI class.

Field

Level

Meaning

package

category

Python package that every module:ClassName path in the category is relative to.

node, analysis

entry

"module:ClassName" of the node class and its analysis class. Required.

doc

entry

Stem of the entry’s page under docs/node-library/nodes/ (e.g. "rabi_oscillations_node"). Omit it while the node has no page yet.

name

variant

The unique registry name. Required.

qoi

variant

"module:ClassName" of the variant’s default QOI class. Required.

parameters

variant

Parameter values that define the variant, fixed for everyone who builds it. Every variant-defining parameter field (see below) must be pinned here.

requires

variant

What must already be calibrated before the variant can run: the measure_gate_class its measurement reads out with, the calibrated_gates it plays and any other calibrated_parameters (Redis keys such as clock_freqs:f01). The gate and measure-gate names are expanded into their own required keys through bragi_quantum.experiments/gates.yaml.

calibrates

variant

The Redis keys that the variant’s QOI writes.

show_in_graph

variant

Whether the variant appears in the dependency graph (default true).

requires and calibrates are what the dependency graph is computed from: a variant depends on whichever other variants calibrates a key that it requires. Keep them accurate when adding or changing a node.

A parameters field marked variant=True (see bragi_quantum.experiments.abstract.parameters) carves out different measurement or analysis code paths and takes only a finite set of values. Every legal combination of such fields must be reachable as its own registry variant, with all of them pinned explicitly in that variant’s parameters — this is checked by a test (see below).

Loading the registry#

At import time, bragi_quantum.experiments.registry.load_node_registry() reads the file, validates it against strict Pydantic models (extra="forbid", strict types and frozen, so a typo’d key such as qio instead of qoi fails loudly instead of silently doing nothing), imports every referenced class, and flattens all categories and entries into one flat mapping from variant name to variant:

{variant_name: ExperimentNodeVariant(name, node_cls, qoi_cls, analysis_cls, category,
                                 parameters, requires, calibrates, doc, show_in_graph)}

ExperimentNodeVariant.create(**overrides) is what actually builds a node: it merges your overrides with the variant’s fixed parameters, constructs the Parameters model (the variant’s name is filled in for you), and instantiates node_cls with the injected qoi_cls/analysis_cls. Overrides are free for everything except the variant’s own pinned parameters: because those define the variant’s identity, passing one raises a ExperimentRegistryError rather than being silently discarded. Like any node, this must happen inside an active calibration session — see Core Concepts.

Add a new node to the registry#

  1. Implement the node under packages/experiments/src/bragi_quantum/experiments/nodes/<category>/... following the anatomy described in Core Concepts (Parameters / Measurement / Analysis / QOI classes).

  2. Add an entry to nodes.yaml, under an existing category or a new one:

    my_category:
      package: "bragi_quantum.experiments.nodes.my_category"
      entries:
        my_new_calibration:
          node: "my_new_calibration.node:MyNewCalibration"  # "module:ClassName" relative to package
          analysis: "my_new_calibration.analysis:MyAnalysis"
          doc: "my_new_calibration_node"                    # omit until the page exists
          variants:
            - name: "my_new_calibration"
              qoi: "my_new_calibration.parameters:MyQOI"
              parameters: { some_field: value }  # fixed values that define this variant
              requires:
                measure_gate_class: "Measure"
                calibrated_gates: ["X"]
                calibrated_parameters: []
              calibrates: ["some:redis_key"]
              show_in_graph: true
    

    A node class that implements several variants needs only one entry: add one item to variants per variant, each with its own name, qoi and pinned parameters (e.g. a state or transition), as rabi_oscillations does above. This imports the node and analysis classes once instead of once per variant.

  3. Add a documentation page for the node under docs/node-library/nodes/, add it to the toctree of its category page (for instance readout_characterization.md), and put its stem in doc. Spell out every variant name in the page so it can be searched from the registry.

Variant names must be unique across the whole file, not just within a category: loading the registry fails with Duplicate variant name otherwise. Entry names must be unique within their category (entries is a YAML mapping, so a duplicate key there is a YAML error).

Check calibrates and measure_gate_class against the code#

calibrates and measure_gate_class are copied from the QOI and measurement classes they describe, and utils_scripts/sync_node_metadata.py is the tool that cross-checks them. It is a manual tool, run it by hand:

# Print every variant's computed values, to paste into nodes.yaml for a new node
uv run python utils_scripts/sync_node_metadata.py

# Print only the mismatches and exit non-zero if there are any
uv run python utils_scripts/sync_node_metadata.py --check

calibrated_gates and calibrated_parameters can’t be derived from the code and have to be kept up to date by hand from the node’s measurement.

Test the edit#

Several test suites exercise the registry; run them after editing nodes.yaml:

# Schema-level: catches malformed YAML (missing "node"/"qoi", unknown keys, ...)
# and confirms the real shipped file still loads and imports cleanly (which
# also fails on a duplicate variant name).
pytest packages/experiments/tests/test_registry.py -v

# Coverage: every legal combination of a node's variant-defining parameter
# fields has a registry variant that pins all of them explicitly.
pytest packages/experiments/tests/test_registry_variant_coverage.py -v

# Dependency graph built from requires/calibrates.
pytest packages/experiments/tests/utils/test_node_dependencies.py -v

# Pipeline-level: every registry variant is discovered automatically and run
# end-to-end (compile -> dummy-execute -> shape dataset) against a simulated
# cluster, so a newly added node is covered with zero test-file edits.
pytest tests/test_dummy_measurements.py -v

test_dummy_measurements.py parametrizes over sorted(load_node_registry()), so if your new variant doesn’t show up as its own test case, it isn’t being loaded — check for a typo in the category/entry/variant name or an import error in the class path first. A node whose measurement_cls is None (analysis-only nodes) is skipped rather than run.

Usage#

The registry’s job is to be a factory that produces ready-to-run node objects by name — nothing downstream looks nodes up by name on its own (the api package’s CalibrationOrchestrator.run_node takes an already-built node object). Typical usage, inside an active session:

from bragi_quantum.experiments.registry import load_node_registry

specs = load_node_registry()
node = specs["resonator_spectroscopy_1"].create(qubits=["q16", "q17"], samples=101)

orchestrator.run_node(node)

This is how the test suite’s make_node fixture (packages/experiments/tests/conftest.py) builds real nodes for unit tests, and how test_dummy_measurements.py builds and runs every shipped variant. Reach for the registry whenever you want to select a calibration by its stable name — a config file, a CLI, a test — rather than importing and wiring up its class directly.

Full Example#

examples/scripts/single_qubit_bringup/bring_up_qubits.py shows a full qubit bring-up chain run through the orchestrator. It builds its nodes directly from the node, parameters and QOI classes rather than through the registry; the registry equivalent of each step is specs[<variant name>].create(...).