Skip to content

Analysis

LayoutAnalysis dataclass

LayoutAnalysis(
    heuristic: LayoutHeuristicABC,
    address_entries: dict[SSAValue, Address],
    all_qubits: tuple[int, ...],
)

Bases: Forward


              flowchart TD
              bloqade.lanes.analysis.layout.analysis.LayoutAnalysis[LayoutAnalysis]

              

              click bloqade.lanes.analysis.layout.analysis.LayoutAnalysis href "" "bloqade.lanes.analysis.layout.analysis.LayoutAnalysis"
            

get_layout

get_layout(method: Method)

Get the layout for a given method.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/analysis/layout/analysis.py
110
111
112
113
def get_layout(self, method: ir.Method):
    """Get the layout for a given method."""
    self.run(method)
    return self.process_results()

get_layout_no_raise

get_layout_no_raise(method: Method)

Get the layout for a given method.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/analysis/layout/analysis.py
105
106
107
108
def get_layout_no_raise(self, method: ir.Method):
    """Get the layout for a given method."""
    self.run_no_raise(method)
    return self.process_results()

LayoutHeuristicABC dataclass

LayoutHeuristicABC(arch_spec: ArchSpec)

Bases: ABC


              flowchart TD
              bloqade.lanes.analysis.layout.analysis.LayoutHeuristicABC[LayoutHeuristicABC]

              

              click bloqade.lanes.analysis.layout.analysis.LayoutHeuristicABC href "" "bloqade.lanes.analysis.layout.analysis.LayoutHeuristicABC"
            

compute_layout abstractmethod

compute_layout(
    all_qubits: tuple[int, ...],
    stages: list[tuple[tuple[int, int], ...]],
    pinned: dict[int, LocationAddress] | None = None,
) -> tuple[LocationAddress, ...]

Compute the initial qubit layout from circuit stages.

Parameters:

Name Type Description Default
all_qubits tuple[int, ...]

Tuple of logical qubit indices to be mapped.

required
stages list[tuple[tuple[int, int], ...]]

List of circuit stages, where each stage is a tuple of (control, target) qubit pairs representing two-qubit gates.

required
pinned dict[int, LocationAddress] | None

Map from logical qubit ID to pre-pinned LocationAddress. Implementations MUST place each pinned qubit at its requested address and MUST NOT use any address in pinned.values() for un-pinned qubits. None or empty preserves previous behavior. All values in pinned MUST be valid home positions for the architecture (i.e. present in arch_spec.home_sites); passing an out-of-arch address raises ValueError.

None

Returns:

Type Description
LocationAddress

A tuple of LocationAddress objects mapping logical qubit indices

...

to physical locations. Pinned IDs return their pinned address;

tuple[LocationAddress, ...]

un-pinned IDs return the heuristic's choice. Raises if no legal

tuple[LocationAddress, ...]

layout exists.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/analysis/layout/analysis.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@abc.abstractmethod
def compute_layout(
    self,
    all_qubits: tuple[int, ...],
    stages: list[tuple[tuple[int, int], ...]],
    pinned: dict[int, LocationAddress] | None = None,
) -> tuple[LocationAddress, ...]:
    """
    Compute the initial qubit layout from circuit stages.

    Args:
        all_qubits: Tuple of logical qubit indices to be mapped.
        stages: List of circuit stages, where each stage is a tuple of
            (control, target) qubit pairs representing two-qubit gates.
        pinned: Map from logical qubit ID to pre-pinned LocationAddress.
            Implementations MUST place each pinned qubit at its requested
            address and MUST NOT use any address in pinned.values() for
            un-pinned qubits. None or empty preserves previous behavior.
            All values in pinned MUST be valid home positions for the
            architecture (i.e. present in arch_spec.home_sites); passing
            an out-of-arch address raises ValueError.

    Returns:
        A tuple of LocationAddress objects mapping logical qubit indices
        to physical locations. Pinned IDs return their pinned address;
        un-pinned IDs return the heuristic's choice. Raises if no legal
        layout exists.
    """
    ...  # pragma: no cover