Skip to content

Logical

LogicalPipeline dataclass

LogicalPipeline(
    arch_spec: ArchSpec = get_logical_arch_spec(),
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    place_opt_type: type[Pass] = SequentialPlacePass,
    transversal_rewrite: bool = False,
    simulation: bool = True,
)

Compile a logical squin kernel to the move dialect.

Includes Clifford/measurement/no-cloning validation and the full logical initialization sequence (InsertInitialize for LogicalQubits).

arch_spec is the single source of truth: when layout_heuristic or placement_strategy are None (the default), they are constructed in emit using self.arch_spec, guaranteeing consistency. Pass explicit instances only when you need a fully custom heuristic or strategy; in that case the caller is responsible for arch-spec consistency.

resolved_layout_heuristic property

resolved_layout_heuristic: LayoutHeuristicABC

Return the active layout heuristic, constructing it from arch_spec if unset.

Emits a warning if an explicit heuristic is set whose arch_spec differs from the pipeline's arch_spec.

resolved_placement_strategy property

resolved_placement_strategy: PlacementStrategyABC

Return the active placement strategy, constructing it from arch_spec if unset.

Emits a warning if an explicit strategy is set whose arch_spec differs from the pipeline's arch_spec.

transversal_rewrites

transversal_rewrites(
    mt: Method, rewrite_logical_initialize: bool = True
) -> Method

Apply transversal rewrite rules to a squin method.

Expands logical operations into their transversal (physical qubit) equivalents using the Steane [[7,1,3]] transversal map. The method is rewritten in place.

Parameters:

Name Type Description Default
mt Method

The squin method to rewrite.

required
rewrite_logical_initialize bool

Whether to rewrite the logical initialize statements.

True

Returns:

Name Type Description
Method Method

The rewritten method (same object, mutated in place).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/pipeline/logical.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def transversal_rewrites(mt: Method, rewrite_logical_initialize: bool = True) -> Method:
    """Apply transversal rewrite rules to a squin method.

    Expands logical operations into their transversal (physical qubit) equivalents
    using the Steane [[7,1,3]] transversal map. The method is rewritten in place.

    Args:
        mt (Method): The squin method to rewrite.
        rewrite_logical_initialize (bool): Whether to rewrite the logical initialize statements.

    Returns:
        Method: The rewritten method (same object, mutated in place).

    """
    TransversalRewritePass(
        mt.dialects,
        transversal_location_map=steane7_transversal_map,
        rewrite_logical_initialize=rewrite_logical_initialize,
    )(mt)

    return mt