qldpc.experimental.surgery.bridge
Standalone bridge adapter for two-PPM joint surgery.
Swaroop et al. arXiv:2410.03628 §IV / §VII. Handles both intra-code (g1.code is g2.code) and inter-code joints.
Copyright 2026 The qLDPC Authors
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Classes
Universal adapter between two GadgetLayouts (Swaroop et al. arXiv:2410.03628 §IV / §VII). |
Functions
|
Universal-adapter bridge between two gadgets (Swaroop et al. arXiv:2410.03628 §IV). |
Module Contents
- class qldpc.experimental.surgery.bridge.Bridge[source]
Universal adapter between two GadgetLayouts (Swaroop et al. arXiv:2410.03628 §IV / §VII).
gadget notation: V_0 → support; F → incidence; κ → ancilla.
- H_R: numpy.ndarray
- T_l: numpy.ndarray
- T_r: numpy.ndarray
- basis: qldpc.objects.PauliXZ
- extra_ancilla_l: numpy.ndarray
- extra_ancilla_r: numpy.ndarray
- label_l: tuple[int, ...]
- label_r: tuple[int, ...]
- port_l: tuple[int, ...]
- port_r: tuple[int, ...]
- width: int
- qldpc.experimental.surgery.bridge.build_bridge(g_l: qldpc.experimental.surgery.gadget.GadgetLayout, g_r: qldpc.experimental.surgery.gadget.GadgetLayout, *, port_subset_l: tuple[int, ...] | None = None, port_subset_r: tuple[int, ...] | None = None, spanning_tree_root_l: int = 0, spanning_tree_root_r: int = 0, cellulate_max_len: int | None = None) Bridge[source]
Universal-adapter bridge between two gadgets (Swaroop et al. arXiv:2410.03628 §IV).
gadget notation: V_0^(l) → support^(l); F → incidence; extra_kappa → extra_ancilla.
Built on the SkipTree basis transform of the same paper (§III).
- Parameters:
g_l – left gadget.
g_r – right gadget. Must share g_l’s measurement basis.
port_subset_l – indices into
g_l.supportto use as ports. Must be in range and distinct; out-of-range or repeated entries surface as an IndexError. Defaults to all of it.port_subset_r – indices into
g_r.supportto use as ports, same contract as port_subset_l. Defaults to all of it.spanning_tree_root_l – index INTO the left port tuple of the SkipTree root vertex.
spanning_tree_root_r – index INTO the right port tuple of the SkipTree root vertex.
cellulate_max_len – cap on port-subgraph cycle length, enforced by adding chords, which trade qubits for a sparser gauge. Defaults to the larger of the two data codes’ maximum measured-basis stabilizer row weight, floored at 3: a 3-cycle has no chord, so 3 is the smallest cap every port subgraph can meet. That default reads the measured basis while the cycles it governs come from the complementary one, so pass the cap explicitly for a code whose two check matrices differ in maximum row weight.
- Returns:
A Bridge of width
min(|ports_l|, |ports_r|).- Raises:
ValueError – the two gadgets disagree on basis; the resulting width is < 2; a spanning-tree root is out of range; or an explicitly supplied port subset is longer than the width, so that requested ports would be dropped.
RuntimeError – a port-subgraph cycle has no chord available to meet cellulate_max_len, which a cap below 3 forces.