Skip to content

Compile

compile_squin_to_move

compile_squin_to_move(
    mt: Method,
    no_raise: bool = True,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> ir.Method

Compile a physical squin kernel to the move dialect.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/compile.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def compile_squin_to_move(
    mt: ir.Method,
    no_raise: bool = True,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> ir.Method:
    """Compile a physical squin kernel to the move dialect."""
    arch_spec = get_physical_arch_spec()
    if layout_heuristic is None:
        layout_heuristic = PhysicalLayoutHeuristicGraphPartitionCenterOut(
            arch_spec=arch_spec
        )
    if placement_strategy is None:
        placement_strategy = PhysicalPlacementStrategy(arch_spec=arch_spec)

    return squin_to_move(
        mt,
        layout_heuristic=layout_heuristic,
        placement_strategy=placement_strategy,
        insert_return_moves=insert_return_moves,
        no_raise=no_raise,
    )

compile_squin_to_move_and_visualize

compile_squin_to_move_and_visualize(
    mt: Method,
    interactive: bool = True,
    animated: bool = False,
    no_raise: bool = True,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> None

Compile a physical squin kernel to moves and visualize the program.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/compile.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def compile_squin_to_move_and_visualize(
    mt: ir.Method,
    interactive: bool = True,
    animated: bool = False,
    no_raise: bool = True,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> None:
    """Compile a physical squin kernel to moves and visualize the program."""
    mt = compile_squin_to_move(
        mt,
        no_raise=no_raise,
        layout_heuristic=layout_heuristic,
        placement_strategy=placement_strategy,
        insert_return_moves=insert_return_moves,
    )
    arch_spec = get_physical_arch_spec()
    marker = "o"

    if animated:
        visualize.animated_debugger(
            mt, arch_spec, interactive=interactive, atom_marker=marker
        )
    else:
        visualize.debugger(mt, arch_spec, interactive=interactive, atom_marker=marker)

compile_to_physical_squin_noise_model

compile_to_physical_squin_noise_model(
    mt: Method,
    noise_model: NoiseModelABC | None = None,
    no_raise: bool = True,
    arch_spec=None,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> ir.Method

Compile a physical squin kernel to physical squin with inserted noise channels.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/compile.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
def compile_to_physical_squin_noise_model(
    mt: ir.Method,
    noise_model: NoiseModelABC | None = None,
    no_raise: bool = True,
    arch_spec=None,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> ir.Method:
    """Compile a physical squin kernel to physical squin with inserted noise channels."""
    if noise_model is None:
        noise_model = generate_simple_noise_model()
    if arch_spec is None:
        arch_spec = get_physical_arch_spec()

    move_mt = compile_squin_to_move(
        mt,
        no_raise=no_raise,
        layout_heuristic=layout_heuristic,
        placement_strategy=placement_strategy,
        insert_return_moves=insert_return_moves,
    )
    transformer = MoveToSquinPhysical(
        arch_spec=arch_spec,
        noise_model=noise_model,
        aggressive_unroll=False,
    )

    return transformer.emit(move_mt, no_raise=no_raise)

compile_to_stim_program

compile_to_stim_program(
    mt: Method,
    noise_model: NoiseModelABC | None = None,
    no_raise: bool = True,
    arch_spec=None,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> str

Compile a physical squin kernel to a Stim program string.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/compile.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
def compile_to_stim_program(
    mt: ir.Method,
    noise_model: NoiseModelABC | None = None,
    no_raise: bool = True,
    arch_spec=None,
    layout_heuristic: LayoutHeuristicABC | None = None,
    placement_strategy: PlacementStrategyABC | None = None,
    insert_return_moves: bool = True,
) -> str:
    """Compile a physical squin kernel to a Stim program string."""
    noise_kernel = compile_to_physical_squin_noise_model(
        mt,
        noise_model=noise_model,
        no_raise=no_raise,
        arch_spec=arch_spec,
        layout_heuristic=layout_heuristic,
        placement_strategy=placement_strategy,
        insert_return_moves=insert_return_moves,
    )
    RemoveReturn().rewrite(noise_kernel.code)
    noise_kernel = squin_to_stim(noise_kernel)
    buf = io.StringIO()
    emit = EmitStimMain(dialects=noise_kernel.dialects, io=buf)
    emit.initialize()
    emit.run(node=noise_kernel)
    return buf.getvalue().strip()