Skip to content

Logical

calc_vertical_shifts

calc_vertical_shifts(offset: int)

Generates a list of shifts to move atoms vertically by the specified offset.

Parameters:

Name Type Description Default
offset int

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

required
Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
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
@tweezer
def calc_vertical_shifts(
    offset: int,
):
    """Generates a list of shifts to move atoms vertically by the specified offset.

    Args:
        offset (int): The offset to apply to the row indices, must be non-negative.
    """
    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")

    sign = 1
    if offset < 0:
        sign = -1
        offset = -offset

    shifts = ilist.IList([])
    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)])

    def multiple_sign(idx: int):
        return (shifts[idx][0], sign * shifts[idx][1])

    return ilist.map(multiple_sign, ilist.range(len(shifts)))

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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@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
 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
105
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 = GL0_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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
@move
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.
    """
    x_tones = ilist.range(spec.get_int_constant(constant_id="code_size"))
    y_tones = ilist.range(len(src_rows))

    device_fn = schedule.device_fn(gr_zero_to_one_impl, x_tones, y_tones)
    device_fn(src_rows)

gr_zero_to_one_impl

gr_zero_to_one_impl(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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
@tweezer
def gr_zero_to_one_impl(
    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)

    shape = grid.shape(start_pos)
    all_cols = ilist.range(shape[0])

    move_by_shift(start_pos, shifts, all_cols, src_rows)

move_by_shift

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

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]

The list of active x indices of start_pos.

required
active_y IList[int, Any]

The list of active y indices of start_pos.

required
Source code in src/bloqade/shuttle/stdlib/layouts/gemini/logical.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@tweezer
def move_by_shift(
    start_pos: grid.Grid[Any, Any],
    shifts: ilist.IList[tuple[float, float], Any],
    active_x: ilist.IList[int, Any],
    active_y: ilist.IList[int, Any],
):
    """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]): The list of active x indices of start_pos.
        active_y (ilist.IList[int, Any]): The list of active y indices of start_pos.
    """
    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

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

Moves the specified rows within the given block.

Parameters:

Name Type Description Default
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
@move
def vertical_shift(
    offset: int,
    src_col: int,
    src_rows: ilist.IList[int, Any],
):
    """Moves the specified rows within the given block.

    Args:
        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.
    """

    x_tones = ilist.range(spec.get_int_constant(constant_id="code_size"))
    y_tones = ilist.range(len(src_rows))

    device_fn = schedule.device_fn(vertical_shift_impl, x_tones, y_tones)
    device_fn(offset, src_col, src_rows)

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
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
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
237
238
239
240
241
242
243
244
245
246
247
@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:
        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.
    """

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

    ilist.for_each(check_row, src_rows)

    assert_sorted(src_rows)

    row_start = 0
    row_end = spec.get_int_constant(constant_id="logical_rows")

    if offset > 0:
        row_end = row_end - offset
    else:
        row_start = row_start - offset

    start_pos = get_block("GL", src_col, ilist.range(row_start, row_end))
    shape = grid.shape(start_pos)
    all_cols = ilist.range(shape[0])

    shifts = calc_vertical_shifts(offset)

    move_by_shift(start_pos, shifts, all_cols, src_rows)