Skip to content

Upstream

squin_to_move

squin_to_move(
    mt: Method,
    layout_heuristic: LayoutHeuristicABC,
    placement_strategy: PlacementStrategyABC,
    no_raise: bool = True,
    logical_initialize: bool = True,
    place_opt_type: type[Pass] = SequentialPlacePass,
) -> ir.Method

Compile a squin kernel to move dialect.

Parameters:

Name Type Description Default
mt Method

The Squin kernel to compile.

required
layout_heuristic LayoutHeuristicABC

The layout heuristic to use.

required
placement_strategy PlacementStrategyABC

The placement strategy to use. Wrap with PalindromePlacementStrategy to enable palindrome return moves.

required
no_raise bool

Whether to suppress exceptions during compilation. Defaults to True.

True
logical_initialize bool

Whether to apply rewrites that insert logical qubit initialization operations; when False, these rewrites are skipped. Defaults to True.

True
place_opt_type type[Pass]

Place-dialect optimization pass class. Defaults to SequentialPlacePass.

SequentialPlacePass

Returns:

Type Description
Method

ir.Method: The compiled move dialect method.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/upstream.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
def squin_to_move(
    mt: ir.Method,
    layout_heuristic: layout.LayoutHeuristicABC,
    placement_strategy: placement.PlacementStrategyABC,
    no_raise: bool = True,
    logical_initialize: bool = True,
    place_opt_type: type[passes.Pass] = SequentialPlacePass,
) -> ir.Method:
    """
    Compile a squin kernel to move dialect.

    Args:
        mt (ir.Method): The Squin kernel to compile.
        layout_heuristic (layout.LayoutHeuristicABC): The layout heuristic to use.
        placement_strategy (placement.PlacementStrategyABC): The placement strategy to use.
            Wrap with ``PalindromePlacementStrategy`` to enable palindrome return moves.
        no_raise (bool, optional): Whether to suppress exceptions during compilation. Defaults to True.
        logical_initialize (bool, optional): Whether to apply rewrites that insert logical qubit initialization operations; when False, these rewrites are skipped. Defaults to True.
        place_opt_type (type[passes.Pass], optional): Place-dialect optimization pass class. Defaults to SequentialPlacePass.

    Returns:
        ir.Method: The compiled move dialect method.
    """

    arch_spec: ArchSpec | None = getattr(layout_heuristic, "arch_spec", None)
    out = NativeToPlace(
        logical_initialize=logical_initialize,
        arch_spec=arch_spec,
        place_opt_type=place_opt_type,
    ).emit(mt, no_raise=no_raise)
    out = PlaceToMove(
        layout_heuristic=layout_heuristic,
        placement_strategy=placement_strategy,
        logical_initialize=logical_initialize,
    ).emit(out, no_raise=no_raise)

    passes.TypeInfer(mt.dialects)(out)
    out.verify()
    out.verify_type()

    return out