Skip to content

Configuration

Configuration node for the atom move search tree.

ConfigurationNode dataclass

ConfigurationNode(
    configuration: dict[int, LocationAddress],
    parent: ConfigurationNode | None = None,
    parent_moves: frozenset[LaneAddress] | None = None,
    children: dict[
        frozenset[LaneAddress], ConfigurationNode
    ] = dict(),
    depth: int = 0,
)

A node in the configuration tree representing a valid atom placement.

Each node tracks which qubits are at which physical locations, how this configuration was reached (parent + moves), and what configurations are reachable from here (children).

children class-attribute instance-attribute

children: dict[
    frozenset[LaneAddress], ConfigurationNode
] = field(default_factory=dict)

Children keyed by the move set that produced them.

config_key cached property

config_key: Configuration

Canonical hashable key for this configuration.

Two nodes with the same atom placement (regardless of history) produce the same config_key.

configuration instance-attribute

configuration: dict[int, LocationAddress]

Mapping of qubit ID to current physical location.

depth class-attribute instance-attribute

depth: int = 0

Distance from the root node.

occupied_locations cached property

occupied_locations: frozenset[LocationAddress]

The set of physical locations currently occupied by atoms.

parent class-attribute instance-attribute

parent: ConfigurationNode | None = None

The parent node that produced this configuration, or None for the root.

parent_moves class-attribute instance-attribute

parent_moves: frozenset[LaneAddress] | None = None

The move set applied to the parent to produce this configuration.

get_qubit_at

get_qubit_at(location: LocationAddress) -> int | None

Return the qubit ID at a location, or None if empty.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/configuration.py
72
73
74
def get_qubit_at(self, location: LocationAddress) -> int | None:
    """Return the qubit ID at a location, or None if empty."""
    return self._qubit_at_location.get(location)

is_occupied

is_occupied(location: LocationAddress) -> bool

Check whether a physical location has an atom.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/configuration.py
68
69
70
def is_occupied(self, location: LocationAddress) -> bool:
    """Check whether a physical location has an atom."""
    return location in self._occupied_locations

path_to_root

path_to_root() -> list[frozenset[LaneAddress]]

Walk from this node to the root, returning move sets in root-to-leaf order.

The returned list has length equal to this node's depth. Each element is the frozenset of lane addresses applied at that step.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/configuration.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def path_to_root(self) -> list[frozenset[LaneAddress]]:
    """Walk from this node to the root, returning move sets in root-to-leaf order.

    The returned list has length equal to this node's depth. Each element
    is the frozenset of lane addresses applied at that step.
    """
    moves: list[frozenset[LaneAddress]] = []
    node = self
    while node.parent is not None:
        assert node.parent_moves is not None
        moves.append(node.parent_moves)
        node = node.parent
    moves.reverse()
    return moves

to_move_program

to_move_program() -> tuple[tuple[LaneAddress, ...], ...]

Convert the path from root to this node into a move program.

Returns a tuple of tuples, where each inner tuple is a sorted sequence of lane addresses for one move step. Sorting is by encoded lane value for deterministic ordering.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/configuration.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def to_move_program(self) -> tuple[tuple[LaneAddress, ...], ...]:
    """Convert the path from root to this node into a move program.

    Returns a tuple of tuples, where each inner tuple is a sorted
    sequence of lane addresses for one move step. Sorting is by
    encoded lane value for deterministic ordering.
    """
    return tuple(
        tuple(sorted(ms, key=lambda lane: lane.encode()))
        for ms in self.path_to_root()
    )