Skip to content

Logical

get_block

get_block(
    block_id: str,
    col_index: int,
    row_indices: IList[int, Any],
)

Returns the zone corresponding to the specified block and column.

Parameters:

Name Type Description Default
block_id str

The block identifier, either "GL" or "GR".

required
col_index int

The logical column index.

required
row_indices IList[int, Any]

The list of logical row indices.

required

Returns:

Name Type Description
Grid

The grid corresponding to the specified block and column.

Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
@tweezer
def get_block(
    block_id: str,
    col_index: int,
    row_indices: ilist.IList[int, Any],
):
    """Returns the zone corresponding to the specified block and column.

    Args:
        block_id (str): The block identifier, either "GL" or "GR".
        col_index (int): The logical column index.
        row_indices (IList[int, Any]): The list of logical row indices.

    Returns:
        Grid: The grid corresponding to the specified block and column.

    """
    assert block_id in ("GL", "GR"), "block_id must be either 'GL' or 'GR'"

    block = None
    if block_id == "GL":
        block = spec.get_static_trap(zone_id="GL_blocks")
    elif block_id == "GR":
        block = spec.get_static_trap(zone_id="GR_blocks")

    code_size = spec.get_int_constant(constant_id="code_size")
    return block[col_index * code_size : (col_index + 1) * code_size, row_indices]

get_spec

get_spec()

Get the architecture specification for the Gemini logical qubit layout.

Returns:

Name Type Description
ArchSpec

The architecture specification with Gemini logical qubit layout.

Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def get_spec():
    """Get the architecture specification for the Gemini logical qubit layout.

    Returns:
        ArchSpec: The architecture specification with Gemini logical qubit layout.

    """
    arch_spec = get_base_spec()

    gate_zone = arch_spec.layout.static_traps["gate_zone"]
    aom_sites = arch_spec.layout.special_grid["aom_sites"]
    top_reservoir = arch_spec.layout.static_traps["top_reservoir"]
    bottom_reservoir = arch_spec.layout.static_traps["bottom_reservoir"]

    left_traps = gate_zone[::2, :]
    right_traps = gate_zone[1::2, :]
    S_block = top_reservoir[4 : 4 + 7 * 4, 8 : 8 + 5 * 2 : 2]
    M_block = bottom_reservoir[4 : 4 + 7 * 4 :, 2 : 2 + 5 * 2 : 2]

    S0_block = S_block[: 2 * 7, :]
    S1_block = S_block[2 * 7 :, :]
    M0_block = M_block[: 2 * 7, :]
    M1_block = M_block[2 * 7 :, :]

    SL0_block = S0_block[::2, :]
    SR0_block = S0_block[1::2, :]

    SL1_block = S1_block[::2, :]
    SR1_block = S1_block[1::2, :]

    ML0_block = M0_block[::2, :]
    MR0_block = M0_block[1::2, :]
    ML1_block = M1_block[::2, :]
    MR1_block = M1_block[1::2, :]

    GL_blocks = left_traps[2 : 2 + 2 * 7, :]
    GR_blocks = right_traps[2 : 2 + 2 * 7, :]

    GL0_block = GL_blocks[:7, :]
    GR0_block = GR_blocks[:7, :]

    GL1_block = GL_blocks[7 : 2 * 7, :]
    GR1_block = GR_blocks[7 : 2 * 7, :]

    AOM0_block = aom_sites[2 : 2 + 7, :]
    AOM1_block = aom_sites[2 + 7 : 2 + 7 + 7, :]

    additional_static_traps = {
        "left_gate_zone_sites": left_traps,
        "right_gate_zone_sites": right_traps,
        "top_reservoir_sites": top_reservoir,
        "bottom_reservoir_sites": bottom_reservoir,
        "GL_blocks": GL_blocks,
        "GR_blocks": GR_blocks,
        "GL0_block": GL0_block,
        "GL1_block": GL1_block,
        "GR0_block": GR0_block,
        "GR1_block": GR1_block,
        "SL0_block": SL0_block,
        "SL1_block": SL1_block,
        "SR0_block": SR0_block,
        "SR1_block": SR1_block,
        "ML0_block": ML0_block,
        "ML1_block": ML1_block,
        "MR0_block": MR0_block,
        "MR1_block": MR1_block,
    }
    additional_special_grids = {
        "AOM0_block": AOM0_block,
        "AOM1_block": AOM1_block,
    }

    arch_spec.layout.static_traps.update(additional_static_traps)
    arch_spec.layout.special_grid.update(additional_special_grids)
    arch_spec.layout.has_cz.add("gate_zone")
    arch_spec.layout.fillable.update(("GL0_block", "GL1_block"))
    arch_spec.layout.has_local.update(
        ("GL0_block", "GL1_block", "GR0_block", "GR1_block")
    )

    logical_rows, _ = SL0_block.shape
    logical_cols = 2
    code_size = 7

    int_constants = {
        "logical_rows": logical_rows,
        "logical_cols": logical_cols,
        "code_size": code_size,
    }

    arch_spec.int_constants.update(int_constants)

    return arch_spec

gr_zero_to_one

gr_zero_to_one(src_rows: IList[int, Any])

Moves the specified columns within the given block.

Parameters:

Name Type Description Default
src_rows IList[int, Any]

The rows to apply the transformation to.

required
Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
@tweezer
def gr_zero_to_one(
    src_rows: ilist.IList[int, Any],
):
    """Moves the specified columns within the given block.

    Args:
        src_rows (ilist.IList[int, Any]): The rows to apply the transformation to.
    """
    logical_rows = spec.get_int_constant(constant_id="logical_rows")
    row_separation = spec.get_float_constant(constant_id="row_separation")
    col_separation = spec.get_float_constant(constant_id="col_separation")
    shift = col_separation * spec.get_float_constant(constant_id="code_size")

    shifts = ilist.IList(
        [
            (0.0, row_separation * 0.5),
            (shift, 0.0),
            (0.0, -row_separation * 0.5),
        ]
    )

    all_rows = ilist.range(logical_rows)
    start_pos = get_block("GR", 0, all_rows)

    move_by_shift(start_pos, shifts, action.ALL, src_rows)

    # validate the movement
    current_pos = start_pos
    for shift in shifts:
        current_pos = grid.shift(current_pos, shift[0], shift[1])

    expected_last_pos = get_block("GR", 1, all_rows)
    assert (
        current_pos == expected_last_pos
    ), "Final position does not match expected position"

move_by_shift

move_by_shift(
    start_pos: Grid[Any, Any],
    shifts: IList[tuple[float, float], Any],
    active_x: IList[int, Any] | slice,
    active_y: IList[int, Any] | slice,
)

Moves the specified atoms by applying a series of shifts.

Parameters:

Name Type Description Default
start_pos Grid[Any, Any]

The starting position of the atoms.

required
shifts IList[tuple[float, float], Any]

The list of shifts to apply.

required
active_x IList[int, Any] | slice

The list or slice of active x indices.

required
active_y IList[int, Any] | slice

The list or slice of active y indices.

required
Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@tweezer
def move_by_shift(
    start_pos: grid.Grid[Any, Any],
    shifts: ilist.IList[tuple[float, float], Any],
    active_x: ilist.IList[int, Any] | slice,
    active_y: ilist.IList[int, Any] | slice,
):
    """Moves the specified atoms by applying a series of shifts.

    Args:
        start_pos (grid.Grid[Any, Any]): The starting position of the atoms.
        shifts (ilist.IList[tuple[float, float], Any]): The list of shifts to apply.
        active_x (ilist.IList[int, Any] | slice): The list or slice of active x indices.
        active_y (ilist.IList[int, Any] | slice): The list or slice of active y indices.
    """
    action.set_loc(start_pos)
    action.turn_on(active_x, active_y)

    current_pos = start_pos
    for shift in shifts:
        current_pos = grid.shift(current_pos, shift[0], shift[1])
        action.move(current_pos)

    action.turn_off(active_x, active_y)

vertical_shift_impl

vertical_shift_impl(
    offset: int, src_col: int, src_rows: IList[int, Any]
)

Moves the specified rows within the given block.

Parameters:

Name Type Description Default
block_id str

The block identifier, either "GL" or "GR".

required
offset int

The offset to apply to the row indices, must be non-negative.

required
src_col int

The source column index.

required
src_rows IList[int, Any]

The list of source row indices.

required
Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
@tweezer
def vertical_shift_impl(
    offset: int,
    src_col: int,
    src_rows: ilist.IList[int, Any],
):
    """Moves the specified rows within the given block.

    Args:
        block_id (str): The block identifier, either "GL" or "GR".
        offset (int): The offset to apply to the row indices, must be non-negative.
        src_col (int): The source column index.
        src_rows (ilist.IList[int, Any]): The list of source row indices.
    """
    assert offset >= 0, "offset must be non-negative"
    max_row = spec.get_int_constant(constant_id="logical_rows") - offset

    def check_row(row: int):
        assert row + offset < spec.get_int_constant(
            constant_id="logical_rows"
        ), "row index + offset must be less than `logical_rows`"

    ilist.for_each(check_row, src_rows)
    assert (
        len(src_rows) < max_row
    ), "Number of source rows must be less than `logical_rows - offset`"
    assert_sorted(src_rows)

    start_pos = get_block("GL", src_col, ilist.range(max_row))
    row_separation = spec.get_float_constant(constant_id="row_separation")
    col_separation = spec.get_float_constant(constant_id="col_separation")
    gate_spacing = spec.get_float_constant(constant_id="gate_spacing")

    if offset > 1:
        shifts = ilist.IList(
            [
                (0.0, row_separation * 0.5),
                (gate_spacing + col_separation * 0.5, 0.0),
                (0.0, row_separation * (offset - 0.5)),
                (-col_separation * 0.5, 0.0),
            ]
        )
    elif offset == 1:
        shifts = ilist.IList(
            [
                (0.0, row_separation * 0.5),
                (gate_spacing, 0.0),
                (0.0, row_separation * 0.5),
            ]
        )
    else:
        shifts = ilist.IList([(gate_spacing, 0.0)])

    move_by_shift(start_pos, shifts, action.ALL, src_rows)

    # validate the movement
    current_pos = start_pos
    for shift in shifts:
        current_pos = grid.shift(current_pos, shift[0], shift[1])

    expected_last_pos = get_block("GR", src_col, ilist.range(offset, max_row + offset))
    assert (
        current_pos == expected_last_pos
    ), "Final position does not match expected position"