Skip to content

Arch

ArchSpec

ArchSpec(
    inner: ArchSpec,
    words: tuple[Word, ...],
    paths: (
        dict[LaneAddress, tuple[tuple[float, float], ...]]
        | None
    ) = None,
)

Architecture specification for a quantum device.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
42
43
44
45
46
47
48
49
50
51
52
def __init__(
    self,
    inner: _RustArchSpec,
    words: tuple[Word, ...],
    paths: dict[LaneAddress, tuple[tuple[float, float], ...]] | None = None,
):
    self._inner = inner
    self.words = words
    self.paths = MappingProxyType(paths if paths is not None else {})

    self._inner.validate()

atom_reloading property

atom_reloading: bool

Whether the device supports reloading atoms after initial fill.

feed_forward property

feed_forward: bool

Whether the device supports mid-circuit measurement with classical feedback.

max_qubits property

max_qubits: int

Get the maximum number of qubits supported by this architecture.

check_lane_group

check_lane_group(
    lanes: Sequence[LaneAddress],
) -> Sequence[LaneGroupError]

Validate a group of lane addresses via Rust.

Checks individual lane validity, group consistency (direction, bus_id, move_type), bus membership, and AOD geometry constraints. Returns a list of LaneGroupError exceptions (empty if all valid).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
393
394
395
396
397
398
399
400
401
402
403
def check_lane_group(
    self, lanes: Sequence[LaneAddress]
) -> Sequence[LaneGroupError]:
    """Validate a group of lane addresses via Rust.

    Checks individual lane validity, group consistency (direction, bus_id,
    move_type), bus membership, and AOD geometry constraints.
    Returns a list of LaneGroupError exceptions (empty if all valid).
    """
    rust_addrs = [lane._inner for lane in lanes]
    return self._inner.check_lanes(rust_addrs)

check_location_group

check_location_group(
    locations: Sequence[LocationAddress],
) -> Sequence[LocationGroupError]

Validate a group of location addresses via Rust.

Returns a list of LocationGroupError exceptions (empty if all valid).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
383
384
385
386
387
388
389
390
391
def check_location_group(
    self, locations: Sequence[LocationAddress]
) -> Sequence[LocationGroupError]:
    """Validate a group of location addresses via Rust.

    Returns a list of LocationGroupError exceptions (empty if all valid).
    """
    rust_addrs = [loc._inner for loc in locations]
    return self._inner.check_locations(rust_addrs)

compatible_lane_error

compatible_lane_error(
    lane1: LaneAddress, lane2: LaneAddress
) -> set[str]

Get error messages if two lanes are not compatible.

Delegates to Rust group validation.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
405
406
407
408
409
410
411
def compatible_lane_error(self, lane1: LaneAddress, lane2: LaneAddress) -> set[str]:
    """Get error messages if two lanes are not compatible.

    Delegates to Rust group validation.
    """
    errors = self.check_lane_group([lane1, lane2])
    return {str(e) for e in errors}

compatible_lanes

compatible_lanes(
    lane1: LaneAddress, lane2: LaneAddress
) -> bool

Check if two lanes are compatible (can be executed in parallel).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
413
414
415
def compatible_lanes(self, lane1: LaneAddress, lane2: LaneAddress) -> bool:
    """Check if two lanes are compatible (can be executed in parallel)."""
    return len(self.check_lane_group([lane1, lane2])) == 0

from_components classmethod

from_components(
    words: tuple[Word, ...],
    zones: tuple[tuple[int, ...], ...],
    measurement_mode_zones: tuple[int, ...],
    entangling_zones: frozenset[int],
    has_site_buses: frozenset[int],
    has_word_buses: frozenset[int],
    site_buses: tuple[Bus, ...],
    word_buses: tuple[Bus, ...],
    paths: (
        dict[LaneAddress, tuple[tuple[float, float], ...]]
        | None
    ) = None,
    feed_forward: bool = False,
    atom_reloading: bool = False,
) -> ArchSpec

Construct an ArchSpec from Python component types.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
@classmethod
def from_components(
    cls,
    words: tuple[Word, ...],
    zones: tuple[tuple[int, ...], ...],
    measurement_mode_zones: tuple[int, ...],
    entangling_zones: frozenset[int],
    has_site_buses: frozenset[int],
    has_word_buses: frozenset[int],
    site_buses: tuple[Bus, ...],
    word_buses: tuple[Bus, ...],
    paths: dict[LaneAddress, tuple[tuple[float, float], ...]] | None = None,
    feed_forward: bool = False,
    atom_reloading: bool = False,
) -> ArchSpec:
    """Construct an ArchSpec from Python component types."""
    sites_per_word = len(words[0].site_indices) if words else 0
    rust_geometry = _RustGeometry(
        sites_per_word=sites_per_word,
        words=[w._inner for w in words],
    )
    rust_buses = _RustBuses(
        site_buses=list(site_buses),
        word_buses=list(word_buses),
    )
    rust_zones = [_RustZone(words=list(z)) for z in zones]

    rust_paths = None
    if paths:
        rust_paths = [
            _RustTransportPath(
                lane=_RustLaneAddress(
                    lane.move_type,
                    lane.word_id,
                    lane.site_id,
                    lane.bus_id,
                    lane.direction,
                ),
                waypoints=list(waypoints),
            )
            for lane, waypoints in paths.items()
        ]

    inner = _RustArchSpec(
        version=(1, 0),
        geometry=rust_geometry,
        buses=rust_buses,
        words_with_site_buses=sorted(has_site_buses),
        sites_with_word_buses=sorted(has_word_buses),
        zones=rust_zones,
        entangling_zones=sorted(entangling_zones),
        measurement_mode_zones=list(measurement_mode_zones),
        paths=rust_paths,
        feed_forward=feed_forward,
        atom_reloading=atom_reloading,
    )
    return cls(inner, words, paths)

get_blockaded_location

get_blockaded_location(
    location: LocationAddress,
) -> LocationAddress | None

Get the blockaded location (CZ pair) for a given location.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
457
458
459
460
461
def get_blockaded_location(
    self, location: LocationAddress
) -> LocationAddress | None:
    """Get the blockaded location (CZ pair) for a given location."""
    return self.words[location.word_id][location.site_id].cz_pair

get_lane_address

get_lane_address(
    src: LocationAddress, dst: LocationAddress
) -> LaneAddress | None

Given an input tuple of locations, gets the lane (w/direction).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
433
434
435
436
437
def get_lane_address(
    self, src: LocationAddress, dst: LocationAddress
) -> LaneAddress | None:
    """Given an input tuple of locations, gets the lane (w/direction)."""
    return self._lane_map.get((src, dst))

get_zone_index

get_zone_index(
    loc_addr: LocationAddress, zone_id: ZoneAddress
) -> int | None

Get the index of a location address within a zone address.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
245
246
247
248
249
250
251
def get_zone_index(
    self,
    loc_addr: LocationAddress,
    zone_id: ZoneAddress,
) -> int | None:
    """Get the index of a location address within a zone address."""
    return self.zone_address_map[loc_addr].get(zone_id)

validate_lane

validate_lane(lane_address: LaneAddress) -> set[str]

Check if a lane address is valid in this architecture.

Delegates to Rust validation.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
425
426
427
428
429
430
431
def validate_lane(self, lane_address: LaneAddress) -> set[str]:
    """Check if a lane address is valid in this architecture.

    Delegates to Rust validation.
    """
    errors = self.check_lane_group([lane_address])
    return {str(e) for e in errors}

validate_location

validate_location(
    location_address: LocationAddress,
) -> set[str]

Check if a location address is valid in this architecture.

Delegates to Rust validation.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
417
418
419
420
421
422
423
def validate_location(self, location_address: LocationAddress) -> set[str]:
    """Check if a location address is valid in this architecture.

    Delegates to Rust validation.
    """
    errors = self.check_location_group([location_address])
    return {str(e) for e in errors}

yield_zone_locations

yield_zone_locations(
    zone_address: ZoneAddress,
) -> Iterator[LocationAddress]

Yield all location addresses in a given zone address.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/arch.py
225
226
227
228
229
230
231
232
233
234
def yield_zone_locations(
    self, zone_address: ZoneAddress
) -> Iterator[LocationAddress]:
    """Yield all location addresses in a given zone address."""
    zone_id = zone_address.zone_id
    zone = self.zones[zone_id]
    for word_id in zone:
        word = self.words[word_id]
        for site_id, _ in enumerate(word.site_indices):
            yield LocationAddress(word_id, site_id)