quchip.inverse_design.subsystems

Explicit local approximation for fitted observables.

With evaluator="local", each target uses its device(s) and their directly coupled neighbors. The approximation omits more distant devices and their indirect effects. Hilbert-space limits do not select this approximation automatically.

Functions

build_local_subsystem(chip, labels)

Build a reduced Chip that holds only the given device labels.

device_labels_for_local_eval(chip, label)

Return the seed device(s) and every directly coupled neighbor.

quchip.inverse_design.subsystems.build_local_subsystem(chip, labels)[source]

Build a reduced Chip that holds only the given device labels.

A coupling is kept only if both endpoint labels are in labels. The reduced chip inherits the basis, frame, RWA, and backend settings from the parent. Keeping all devices clones the full model. A port whose targets are all in labels is kept with its field subgraph, via restrict().

Parameters:
Returns:

Reduced chip that holds only the kept devices, their mutual couplings, and their ports.

Return type:

Chip

Raises:
  • ValueError – A label is not a device of chip.

  • NotImplementedError – The chip has effective terms, or the network cannot be cut at the subsystem without changing its interactions. This happens when a port targets kept and discarded devices, or when a kept port’s field subgraph or boundary scattering reaches a discarded port. Matrix-form boundary scattering raises unless the subsystem keeps all or none of its planes.

quchip.inverse_design.subsystems.device_labels_for_local_eval(chip, label)[source]

Return the seed device(s) and every directly coupled neighbor.

label can be a single device/label or a tuple of device/labels. All entries are normalized through resolve_label(). The returned tuple is sorted for determinism.

Parameters:
  • chip (Chip)

  • label (Any) – A single device/label or a tuple of devices/labels.

Returns:

Sorted device labels: the seed(s) and every directly coupled neighbor.

Return type:

tuple[str, …]

Examples

A q0 - q1 - q2 chain keeps the seed and its direct neighbors:

>>> from quchip import Chip, DuffingTransmon, Capacitive
>>> from quchip.inverse_design.subsystems import device_labels_for_local_eval
>>> qs = [DuffingTransmon(freq=5.0 + 0.1 * i, anharmonicity=-0.3, levels=3,
...                       label=f"q{i}") for i in range(3)]
>>> chip = Chip(devices=qs, couplings=[Capacitive(qs[0], qs[1], g=0.005),
...                                    Capacitive(qs[1], qs[2], g=0.005)])
>>> device_labels_for_local_eval(chip, "q0")
('q0', 'q1')
>>> device_labels_for_local_eval(chip, ("q0", "q1"))
('q0', 'q1', 'q2')