From dbe2ff5e8a8be14f2f9d9e851183d24d17cac0ab Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Sun, 17 Aug 2025 14:25:18 -0700 Subject: [PATCH 01/16] add draft --- scratch/lower_zair.py | 122 + scratch/qcr_4a8d_quera_circ_code.json | 5170 ++++++++++++++++++++++++ scratch/qcrank.py | 123 + scratch/qcrank_architecture_4_2_v.json | 42 + 4 files changed, 5457 insertions(+) create mode 100644 scratch/lower_zair.py create mode 100644 scratch/qcr_4a8d_quera_circ_code.json create mode 100644 scratch/qcrank.py create mode 100644 scratch/qcrank_architecture_4_2_v.json diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py new file mode 100644 index 00000000..3faf4ea9 --- /dev/null +++ b/scratch/lower_zair.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass, field +import math +from typing import Any, Sequence +from kirin import ir +from kirin.dialects.ilist import IList +from kirin.dialects import py, func +from bloqade.shuttle import gate, init, spec +from bloqade.geometry import grid +from bloqade.shuttle.dialects import gate, filled + + +def _simple_region() -> ir.Region: + return ir.Region(ir.Block()) + + +@dataclass +class ShuttleBuilder: + move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] + num_qubits: int + + body: ir.Region = field(default_factory=_simple_region, init=False) + grid_mapping: dict[int, ir.SSAValue] = field(default_factory=dict) + + def push_stmt(self, stmt: ir.Statement): + self.body.blocks[0].stmts.append(stmt) + return stmt + + def push_constant(self, value: Any) -> ir.SSAValue: + const_stmt = py.Constant(value) + return self.push_stmt(const_stmt).expect_one_result() + + def construct_grid( + self, + grid_id: int, + offset: tuple[int, int], + x_spacing: list[int], + y_spacing: list[int], + dim: tuple[int, int], + ): + x_init = offset[0] + y_init = offset[1] + + grid_ref = self.push_constant( + grid.Grid( + x_spacing=tuple(x_spacing), y_spacing=tuple(y_spacing), x_init=x_init, y_init=y_init + ) + ) + + self.grid_mapping[grid_id] = grid_ref + + return grid_ref + + def insert_move( + self, + srcs: Sequence[tuple[int, int, int, int]], + dsts: Sequence[tuple[int, int, int, int]], + ): + # ignoring zone mapping, + sorted_srcs = sorted(srcs, key=lambda x: x[0]) + sorted_dsts = sorted(dsts, key=lambda x: x[0]) + + x_src = [src[2] for src in sorted_srcs] + y_src = [src[3] for src in sorted_srcs] + x_dst = [dst[2] for dst in sorted_dsts] + y_dst = [dst[3] for dst in sorted_dsts] + + x_src_ref = self.push_constant(x_src) + y_src_ref = self.push_constant(y_src) + x_dst_ref = self.push_constant(x_dst) + y_dst_ref = self.push_constant(y_dst) + + self.push_stmt( + func.Invoke( + inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), + callee=self.move_kernel, + kwargs=(), + ) + ) + + def single_zone_move_impl( + src_x: IList[int, Any], + src_y: IList[int, Any], + dst_x: IList[int, Any], + dst_y: IList[int, Any], + ): + ... + + def entangle(self, grid_id: int): + self.push_stmt(gate.TopHatCZ(self.grid_mapping[grid_id])) + + def r_gate( + self, + axis_angle: float, + rotation_angle: float, + locs: Sequence[tuple[int, int, int, int]], + ): + filled_locs = {} + + for _, grid_id, x, y in locs: + filled_locs.setdefault(grid_id, []).append((x, y)) + + filled_loc_refs: dict[int, ir.SSAValue] = {} + + for grid_id, locs in filled_locs.items(): + locs_ref = self.push_constant(locs) + filled_loc_refs[grid_id] = self.push_stmt( + filled.Fill(self.grid_mapping[grid_id], locs_ref) + ).expect_one_result() + + axis_angle_ref = self.push_constant(axis_angle / (2 * math.pi)) + rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) + + for filled_ref in filled_loc_refs.values(): + self.push_stmt(gate.LocalR(axis_angle_ref, rotation_angle_ref, filled_ref)) + + def lower_h(self, locs: Sequence[tuple[int, int, int, int]]): + assert len(locs) == self.num_qubits, "H gate must be applied to all qubits" + self.push_stmt(gate.GlobalRz(0.25)) + self.push_stmt(gate.GlobalR(0, 0.5)) + self.push_stmt(gate.GlobalRz(0.25)) + + diff --git a/scratch/qcr_4a8d_quera_circ_code.json b/scratch/qcr_4a8d_quera_circ_code.json new file mode 100644 index 00000000..1438ba89 --- /dev/null +++ b/scratch/qcr_4a8d_quera_circ_code.json @@ -0,0 +1,5170 @@ +{ + "name": "qcr_4a8d_quera_circ", + "architecture_spec_path": "scratch/qcrank_architecture_4_2_v.json", + "instructions": [ + { + "type": "init", + "id": 0, + "begin_time": 0, + "end_time": 0, + "init_locs": [ + [ + 4, + 1, + 0, + 2 + ], + [ + 5, + 1, + 0, + 3 + ], + [ + 6, + 1, + 0, + 4 + ], + [ + 7, + 1, + 0, + 5 + ], + [ + 8, + 1, + 1, + 2 + ], + [ + 9, + 1, + 1, + 3 + ], + [ + 10, + 1, + 1, + 4 + ], + [ + 11, + 1, + 1, + 5 + ], + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ] + }, + { + "type": "1qGate", + "unitary": "h", + "id": 1, + "locs": [ + [ + -4, + 1, + 1, + 2 + ], + [ + -3, + 1, + 1, + 3 + ], + [ + -2, + 1, + 1, + 4 + ], + [ + -1, + 1, + 1, + 5 + ], + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ], + [ + 4, + 1, + 0, + 2 + ], + [ + 5, + 1, + 0, + 3 + ], + [ + 6, + 1, + 0, + 4 + ], + [ + 7, + 1, + 0, + 5 + ] + ], + "gates": [ + { + "name": "h", + "q": 0 + }, + { + "name": "h", + "q": 1 + }, + { + "name": "h", + "q": 2 + }, + { + "name": "h", + "q": 3 + }, + { + "name": "h", + "q": 4 + }, + { + "name": "h", + "q": 5 + }, + { + "name": "h", + "q": 6 + }, + { + "name": "h", + "q": 7 + }, + { + "name": "h", + "q": 8 + }, + { + "name": "h", + "q": 9 + }, + { + "name": "h", + "q": 10 + }, + { + "name": "h", + "q": 11 + } + ], + "begin_time": 0, + "end_time": 26.5 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 2, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 26.5, + "end_time": 50.5 + }, + { + "type": "rydberg", + "id": 3, + "zone_id": 0, + "gates": [ + [ + 3, + 4 + ], + [ + 0, + 5 + ], + [ + 1, + 6 + ], + [ + 2, + 7 + ] + ], + "begin_time": 50.5, + "end_time": 50.86 + }, + { + "type": "rearrangeJob", + "id": 4, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 50.86, + "end_time": 65.86 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 30, + 40, + 50, + 20 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 65.86, + "end_time": 131.91782590758163 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 131.91782590758163, + "end_time": 146.91782590758163 + } + ], + "begin_time": 50.86, + "end_time": 146.91782590758163 + }, + { + "type": "rydberg", + "id": 5, + "zone_id": 0, + "gates": [ + [ + 3, + 8 + ], + [ + 0, + 9 + ], + [ + 1, + 10 + ], + [ + 2, + 11 + ] + ], + "begin_time": 146.91782590758163, + "end_time": 147.27782590758164 + }, + { + "type": "rearrangeJob", + "id": 6, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 4 + ], + [ + 1, + 2, + 1, + 5 + ], + [ + 2, + 2, + 1, + 2 + ], + [ + 3, + 2, + 1, + 3 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 147.27782590758164, + "end_time": 162.27782590758164 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 40, + 50, + 60, + 30 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 6 + ], + [ + 2, + 3 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 60, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 162.27782590758164, + "end_time": 222.58009482313437 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 222.58009482313437, + "end_time": 237.58009482313437 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0 + ], + "col_x": [ + 60 + ], + "col_loc": [ + [ + 2, + 6 + ] + ], + "id": 3, + "begin_time": 237.58009482313437, + "end_time": 252.58009482313437 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0 + ], + "col_x_begin": [ + 60 + ], + "col_x_end": [ + 20 + ], + "col_loc_begin": [ + [ + 2, + 6 + ] + ], + "col_loc_end": [ + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 60, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 20, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "id": 4, + "begin_time": 252.58009482313437, + "end_time": 373.1846326542398 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 0 + ], + "id": 5, + "begin_time": 373.1846326542398, + "end_time": 388.1846326542398 + } + ], + "begin_time": 147.27782590758164, + "end_time": 388.1846326542398 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 7, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 388.1846326542398, + "end_time": 412.1846326542398 + }, + { + "type": "rydberg", + "id": 8, + "zone_id": 0, + "gates": [ + [ + 1, + 11 + ], + [ + 0, + 10 + ], + [ + 3, + 9 + ], + [ + 2, + 8 + ] + ], + "begin_time": 412.1846326542398, + "end_time": 412.5446326542398 + }, + { + "type": "rearrangeJob", + "id": 9, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 4 + ], + [ + 1, + 2, + 1, + 5 + ], + [ + 2, + 2, + 1, + 2 + ], + [ + 3, + 2, + 1, + 3 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 4 + ], + [ + 1, + 2, + 0, + 5 + ], + [ + 2, + 2, + 0, + 2 + ], + [ + 3, + 2, + 0, + 3 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x": [ + 40, + 50, + 20, + 30 + ], + "col_loc": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "id": 0, + "begin_time": 412.5446326542398, + "end_time": 427.5446326542398 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x_begin": [ + 40, + 50, + 20, + 30 + ], + "col_x_end": [ + 40, + 50, + 20, + 30 + ], + "col_loc_begin": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "col_loc_end": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 20, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 7 + }, + { + "id": 1, + "x": 50, + "y": 7 + }, + { + "id": 2, + "x": 20, + "y": 7 + }, + { + "id": 3, + "x": 30, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 427.5446326542398, + "end_time": 493.60245856182144 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "id": 2, + "begin_time": 493.60245856182144, + "end_time": 508.60245856182144 + } + ], + "begin_time": 412.5446326542398, + "end_time": 508.60245856182144 + }, + { + "type": "rydberg", + "id": 10, + "zone_id": 0, + "gates": [ + [ + 1, + 7 + ], + [ + 0, + 6 + ], + [ + 3, + 5 + ], + [ + 2, + 4 + ] + ], + "begin_time": 508.60245856182144, + "end_time": 508.96245856182145 + }, + { + "type": "rearrangeJob", + "id": 11, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 4 + ], + [ + 1, + 2, + 0, + 5 + ], + [ + 2, + 2, + 0, + 2 + ], + [ + 3, + 2, + 0, + 3 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x": [ + 40, + 50, + 20, + 30 + ], + "col_loc": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "id": 0, + "begin_time": 508.96245856182145, + "end_time": 523.9624585618214 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x_begin": [ + 40, + 50, + 20, + 30 + ], + "col_x_end": [ + 30, + 40, + 10, + 20 + ], + "col_loc_begin": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 1 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 7 + }, + { + "id": 1, + "x": 50, + "y": 7 + }, + { + "id": 2, + "x": 20, + "y": 7 + }, + { + "id": 3, + "x": 30, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 10, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 523.9624585618214, + "end_time": 584.2647274773742 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "id": 2, + "begin_time": 584.2647274773742, + "end_time": 599.2647274773742 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 0 + ], + "col_x": [ + 10 + ], + "col_loc": [ + [ + 2, + 1 + ] + ], + "id": 3, + "begin_time": 599.2647274773742, + "end_time": 614.2647274773742 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 0 + ], + "col_x_begin": [ + 10 + ], + "col_x_end": [ + 50 + ], + "col_loc_begin": [ + [ + 2, + 1 + ] + ], + "col_loc_end": [ + [ + 2, + 5 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 10, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "id": 4, + "begin_time": 614.2647274773742, + "end_time": 734.8692653084796 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 0 + ], + "id": 5, + "begin_time": 734.8692653084796, + "end_time": 749.8692653084796 + } + ], + "begin_time": 508.96245856182145, + "end_time": 749.8692653084796 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 12, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 749.8692653084796, + "end_time": 773.8692653084796 + }, + { + "type": "rydberg", + "id": 13, + "zone_id": 0, + "gates": [ + [ + 3, + 4 + ], + [ + 0, + 5 + ], + [ + 1, + 6 + ], + [ + 2, + 7 + ] + ], + "begin_time": 773.8692653084796, + "end_time": 774.2292653084796 + }, + { + "type": "rearrangeJob", + "id": 14, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 774.2292653084796, + "end_time": 789.2292653084796 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 30, + 40, + 50, + 20 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 789.2292653084796, + "end_time": 855.2870912160613 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 855.2870912160613, + "end_time": 870.2870912160613 + } + ], + "begin_time": 774.2292653084796, + "end_time": 870.2870912160613 + }, + { + "type": "rydberg", + "id": 15, + "zone_id": 0, + "gates": [ + [ + 3, + 8 + ], + [ + 0, + 9 + ], + [ + 1, + 10 + ], + [ + 2, + 11 + ] + ], + "begin_time": 870.2870912160613, + "end_time": 870.6470912160613 + }, + { + "type": "rearrangeJob", + "id": 16, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 5 + ], + [ + 1, + 2, + 1, + 2 + ], + [ + 2, + 2, + 1, + 3 + ], + [ + 3, + 2, + 1, + 4 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 870.6470912160613, + "end_time": 885.6470912160613 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 50, + 60, + 70, + 40 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 5 + ], + [ + 2, + 6 + ], + [ + 2, + 7 + ], + [ + 2, + 4 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 19 + }, + { + "id": 1, + "x": 60, + "y": 19 + }, + { + "id": 2, + "x": 70, + "y": 19 + }, + { + "id": 3, + "x": 40, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 885.6470912160613, + "end_time": 970.9273777583055 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 970.9273777583055, + "end_time": 985.9273777583055 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0, + 1 + ], + "col_x": [ + 60, + 70 + ], + "col_loc": [ + [ + 2, + 6 + ], + [ + 2, + 7 + ] + ], + "id": 3, + "begin_time": 985.9273777583055, + "end_time": 1000.9273777583055 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0, + 1 + ], + "col_x_begin": [ + 60, + 70 + ], + "col_x_end": [ + 20, + 30 + ], + "col_loc_begin": [ + [ + 2, + 6 + ], + [ + 2, + 7 + ] + ], + "col_loc_end": [ + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 19 + }, + { + "id": 1, + "x": 60, + "y": 19 + }, + { + "id": 2, + "x": 70, + "y": 19 + }, + { + "id": 3, + "x": 40, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 19 + }, + { + "id": 1, + "x": 20, + "y": 19 + }, + { + "id": 2, + "x": 30, + "y": 19 + }, + { + "id": 3, + "x": 40, + "y": 19 + } + ] + ], + "id": 4, + "begin_time": 1000.9273777583055, + "end_time": 1121.531915589411 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 0, + 1 + ], + "id": 5, + "begin_time": 1121.531915589411, + "end_time": 1136.531915589411 + } + ], + "begin_time": 870.6470912160613, + "end_time": 1136.531915589411 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 17, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 1136.531915589411, + "end_time": 1160.531915589411 + }, + { + "type": "rydberg", + "id": 18, + "zone_id": 0, + "gates": [ + [ + 0, + 11 + ], + [ + 3, + 10 + ], + [ + 2, + 9 + ], + [ + 1, + 8 + ] + ], + "begin_time": 1160.531915589411, + "end_time": 1160.891915589411 + }, + { + "type": "rearrangeJob", + "id": 19, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 5 + ], + [ + 1, + 2, + 1, + 2 + ], + [ + 2, + 2, + 1, + 3 + ], + [ + 3, + 2, + 1, + 4 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 5 + ], + [ + 1, + 2, + 0, + 2 + ], + [ + 2, + 2, + 0, + 3 + ], + [ + 3, + 2, + 0, + 4 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "col_x": [ + 50, + 20, + 30, + 40 + ], + "col_loc": [ + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ], + [ + 2, + 4 + ] + ], + "id": 0, + "begin_time": 1160.891915589411, + "end_time": 1175.891915589411 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "col_x_begin": [ + 50, + 20, + 30, + 40 + ], + "col_x_end": [ + 50, + 20, + 30, + 40 + ], + "col_loc_begin": [ + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ], + [ + 2, + 4 + ] + ], + "col_loc_end": [ + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ], + [ + 2, + 4 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 19 + }, + { + "id": 1, + "x": 20, + "y": 19 + }, + { + "id": 2, + "x": 30, + "y": 19 + }, + { + "id": 3, + "x": 40, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 7 + }, + { + "id": 1, + "x": 20, + "y": 7 + }, + { + "id": 2, + "x": 30, + "y": 7 + }, + { + "id": 3, + "x": 40, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 1175.891915589411, + "end_time": 1241.9497414969926 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "id": 2, + "begin_time": 1241.9497414969926, + "end_time": 1256.9497414969926 + } + ], + "begin_time": 1160.891915589411, + "end_time": 1256.9497414969926 + }, + { + "type": "rydberg", + "id": 20, + "zone_id": 0, + "gates": [ + [ + 0, + 7 + ], + [ + 3, + 6 + ], + [ + 2, + 5 + ], + [ + 1, + 4 + ] + ], + "begin_time": 1256.9497414969926, + "end_time": 1257.3097414969925 + }, + { + "type": "rearrangeJob", + "id": 21, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 5 + ], + [ + 1, + 2, + 0, + 2 + ], + [ + 2, + 2, + 0, + 3 + ], + [ + 3, + 2, + 0, + 4 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "col_x": [ + 50, + 20, + 30, + 40 + ], + "col_loc": [ + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ], + [ + 2, + 4 + ] + ], + "id": 0, + "begin_time": 1257.3097414969925, + "end_time": 1272.3097414969925 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "col_x_begin": [ + 50, + 20, + 30, + 40 + ], + "col_x_end": [ + 70, + 40, + 50, + 60 + ], + "col_loc_begin": [ + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ], + [ + 2, + 4 + ] + ], + "col_loc_end": [ + [ + 2, + 7 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 6 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 50, + "y": 7 + }, + { + "id": 1, + "x": 20, + "y": 7 + }, + { + "id": 2, + "x": 30, + "y": 7 + }, + { + "id": 3, + "x": 40, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 70, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 60, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 1272.3097414969925, + "end_time": 1357.5900280392366 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 3, + 0, + 1, + 2 + ], + "id": 2, + "begin_time": 1357.5900280392366, + "end_time": 1372.5900280392366 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 1, + 0 + ], + "col_x": [ + 70, + 60 + ], + "col_loc": [ + [ + 2, + 7 + ], + [ + 2, + 6 + ] + ], + "id": 3, + "begin_time": 1372.5900280392366, + "end_time": 1387.5900280392366 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 1, + 0 + ], + "col_x_begin": [ + 70, + 60 + ], + "col_x_end": [ + 30, + 20 + ], + "col_loc_begin": [ + [ + 2, + 7 + ], + [ + 2, + 6 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 70, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 60, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "id": 4, + "begin_time": 1387.5900280392366, + "end_time": 1508.194565870342 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 0 + ], + "id": 5, + "begin_time": 1508.194565870342, + "end_time": 1523.194565870342 + } + ], + "begin_time": 1257.3097414969925, + "end_time": 1523.194565870342 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 22, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 1523.194565870342, + "end_time": 1547.194565870342 + }, + { + "type": "rydberg", + "id": 23, + "zone_id": 0, + "gates": [ + [ + 3, + 4 + ], + [ + 0, + 5 + ], + [ + 1, + 6 + ], + [ + 2, + 7 + ] + ], + "begin_time": 1547.194565870342, + "end_time": 1547.554565870342 + }, + { + "type": "rearrangeJob", + "id": 24, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 1547.554565870342, + "end_time": 1562.554565870342 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 30, + 40, + 50, + 20 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 1562.554565870342, + "end_time": 1628.6123917779237 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 1628.6123917779237, + "end_time": 1643.6123917779237 + } + ], + "begin_time": 1547.554565870342, + "end_time": 1643.6123917779237 + }, + { + "type": "rydberg", + "id": 25, + "zone_id": 0, + "gates": [ + [ + 3, + 8 + ], + [ + 0, + 9 + ], + [ + 1, + 10 + ], + [ + 2, + 11 + ] + ], + "begin_time": 1643.6123917779237, + "end_time": 1643.9723917779236 + }, + { + "type": "rearrangeJob", + "id": 26, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 3 + ], + [ + 1, + 2, + 1, + 4 + ], + [ + 2, + 2, + 1, + 5 + ], + [ + 3, + 2, + 1, + 2 + ] + ], + "end_locs": [ + [ + 0, + 2, + 1, + 4 + ], + [ + 1, + 2, + 1, + 5 + ], + [ + 2, + 2, + 1, + 2 + ], + [ + 3, + 2, + 1, + 3 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x": [ + 30, + 40, + 50, + 20 + ], + "col_loc": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "id": 0, + "begin_time": 1643.9723917779236, + "end_time": 1658.9723917779236 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "col_x_begin": [ + 30, + 40, + 50, + 20 + ], + "col_x_end": [ + 40, + 50, + 60, + 30 + ], + "col_loc_begin": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ] + ], + "col_loc_end": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 6 + ], + [ + 2, + 3 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 19 + }, + { + "id": 1, + "x": 40, + "y": 19 + }, + { + "id": 2, + "x": 50, + "y": 19 + }, + { + "id": 3, + "x": 20, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 60, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "id": 1, + "begin_time": 1658.9723917779236, + "end_time": 1719.2746606934763 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 1, + 2, + 3, + 0 + ], + "id": 2, + "begin_time": 1719.2746606934763, + "end_time": 1734.2746606934763 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0 + ], + "col_x": [ + 60 + ], + "col_loc": [ + [ + 2, + 6 + ] + ], + "id": 3, + "begin_time": 1734.2746606934763, + "end_time": 1749.2746606934763 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 19 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 0 + ], + "col_x_begin": [ + 60 + ], + "col_x_end": [ + 20 + ], + "col_loc_begin": [ + [ + 2, + 6 + ] + ], + "col_loc_end": [ + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 60, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 20, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "id": 4, + "begin_time": 1749.2746606934763, + "end_time": 1869.8791985245819 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 0 + ], + "id": 5, + "begin_time": 1869.8791985245819, + "end_time": 1884.8791985245819 + } + ], + "begin_time": 1643.9723917779236, + "end_time": 1884.8791985245819 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 27, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 1884.8791985245819, + "end_time": 1908.8791985245819 + }, + { + "type": "rydberg", + "id": 28, + "zone_id": 0, + "gates": [ + [ + 1, + 11 + ], + [ + 0, + 10 + ], + [ + 3, + 9 + ], + [ + 2, + 8 + ] + ], + "begin_time": 1908.8791985245819, + "end_time": 1909.2391985245818 + }, + { + "type": "rearrangeJob", + "id": 29, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 1, + 4 + ], + [ + 1, + 2, + 1, + 5 + ], + [ + 2, + 2, + 1, + 2 + ], + [ + 3, + 2, + 1, + 3 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 4 + ], + [ + 1, + 2, + 0, + 5 + ], + [ + 2, + 2, + 0, + 2 + ], + [ + 3, + 2, + 0, + 3 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 19 + ], + "row_loc": [ + [ + 2, + 1 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x": [ + 40, + 50, + 20, + 30 + ], + "col_loc": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "id": 0, + "begin_time": 1909.2391985245818, + "end_time": 1924.2391985245818 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 19 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 1 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x_begin": [ + 40, + 50, + 20, + 30 + ], + "col_x_end": [ + 40, + 50, + 20, + 30 + ], + "col_loc_begin": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "col_loc_end": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 19 + }, + { + "id": 1, + "x": 50, + "y": 19 + }, + { + "id": 2, + "x": 20, + "y": 19 + }, + { + "id": 3, + "x": 30, + "y": 19 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 7 + }, + { + "id": 1, + "x": 50, + "y": 7 + }, + { + "id": 2, + "x": 20, + "y": 7 + }, + { + "id": 3, + "x": 30, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 1924.2391985245818, + "end_time": 1990.2970244321634 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "id": 2, + "begin_time": 1990.2970244321634, + "end_time": 2005.2970244321634 + } + ], + "begin_time": 1909.2391985245818, + "end_time": 2005.2970244321634 + }, + { + "type": "rydberg", + "id": 30, + "zone_id": 0, + "gates": [ + [ + 1, + 7 + ], + [ + 0, + 6 + ], + [ + 3, + 5 + ], + [ + 2, + 4 + ] + ], + "begin_time": 2005.2970244321634, + "end_time": 2005.6570244321633 + }, + { + "type": "rearrangeJob", + "id": 31, + "aod_id": 0, + "aod_qubits": [ + 0, + 1, + 2, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 4 + ], + [ + 1, + 2, + 0, + 5 + ], + [ + 2, + 2, + 0, + 2 + ], + [ + 3, + 2, + 0, + 3 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 1, + 2, + 0, + 4 + ], + [ + 2, + 2, + 0, + 5 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "insts": [ + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x": [ + 40, + 50, + 20, + 30 + ], + "col_loc": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "id": 0, + "begin_time": 2005.6570244321633, + "end_time": 2020.6570244321633 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "col_x_begin": [ + 40, + 50, + 20, + 30 + ], + "col_x_end": [ + 30, + 40, + 10, + 20 + ], + "col_loc_begin": [ + [ + 2, + 4 + ], + [ + 2, + 5 + ], + [ + 2, + 2 + ], + [ + 2, + 3 + ] + ], + "col_loc_end": [ + [ + 2, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 1 + ], + [ + 2, + 2 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 40, + "y": 7 + }, + { + "id": 1, + "x": 50, + "y": 7 + }, + { + "id": 2, + "x": 20, + "y": 7 + }, + { + "id": 3, + "x": 30, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 10, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "id": 1, + "begin_time": 2020.6570244321633, + "end_time": 2080.959293347716 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 2, + 3, + 0, + 1 + ], + "id": 2, + "begin_time": 2080.959293347716, + "end_time": 2095.959293347716 + }, + { + "type": "activate", + "row_id": [ + 0 + ], + "row_y": [ + 7 + ], + "row_loc": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 0 + ], + "col_x": [ + 10 + ], + "col_loc": [ + [ + 2, + 1 + ] + ], + "id": 3, + "begin_time": 2095.959293347716, + "end_time": 2110.959293347716 + }, + { + "type": "move:big", + "move_type": "big", + "row_id": [ + 0 + ], + "row_y_begin": [ + 7 + ], + "row_y_end": [ + 7 + ], + "row_loc_begin": [ + [ + 2, + 0 + ] + ], + "row_loc_end": [ + [ + 2, + 0 + ] + ], + "col_id": [ + 0 + ], + "col_x_begin": [ + 10 + ], + "col_x_end": [ + 50 + ], + "col_loc_begin": [ + [ + 2, + 1 + ] + ], + "col_loc_end": [ + [ + 2, + 5 + ] + ], + "begin_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 10, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "end_coord": [ + [ + { + "id": 0, + "x": 30, + "y": 7 + }, + { + "id": 1, + "x": 40, + "y": 7 + }, + { + "id": 2, + "x": 50, + "y": 7 + }, + { + "id": 3, + "x": 20, + "y": 7 + } + ] + ], + "id": 4, + "begin_time": 2110.959293347716, + "end_time": 2231.5638311788216 + }, + { + "type": "deactivate", + "row_id": [ + 0 + ], + "col_id": [ + 0 + ], + "id": 5, + "begin_time": 2231.5638311788216, + "end_time": 2246.5638311788216 + } + ], + "begin_time": 2005.6570244321633, + "end_time": 2246.5638311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "id": 32, + "locs": [ + [ + 0, + 1, + 0, + 2 + ], + [ + 1, + 1, + 0, + 3 + ], + [ + 2, + 1, + 0, + 4 + ], + [ + 3, + 1, + 0, + 5 + ], + [ + 4, + 1, + 1, + 2 + ], + [ + 5, + 1, + 1, + 3 + ], + [ + 6, + 1, + 1, + 4 + ], + [ + 7, + 1, + 1, + 5 + ] + ], + "gates": [ + { + "name": "ry", + "q": 4 + }, + { + "name": "ry", + "q": 5 + }, + { + "name": "ry", + "q": 6 + }, + { + "name": "ry", + "q": 7 + }, + { + "name": "ry", + "q": 8 + }, + { + "name": "ry", + "q": 9 + }, + { + "name": "ry", + "q": 10 + }, + { + "name": "ry", + "q": 11 + } + ], + "begin_time": 2246.5638311788216, + "end_time": 2270.5638311788216 + }, + { + "type": "rydberg", + "id": 33, + "zone_id": 0, + "gates": [ + [ + 3, + 4 + ], + [ + 0, + 5 + ], + [ + 1, + 6 + ], + [ + 2, + 7 + ] + ], + "begin_time": 2270.5638311788216, + "end_time": 2270.9238311788217 + } + ], + "runtime": 2270.9238311788217 +} \ No newline at end of file diff --git a/scratch/qcrank.py b/scratch/qcrank.py new file mode 100644 index 00000000..b3d71abc --- /dev/null +++ b/scratch/qcrank.py @@ -0,0 +1,123 @@ +from typing import Any, Literal, TypeVar + +from bloqade.geometry.dialects import grid +from kirin.dialects import ilist + +from bloqade.shuttle import action, gate, init, measure, schedule, spec +from bloqade.shuttle.prelude import move, tweezer +from bloqade.shuttle.visualizer import MatplotlibRenderer, PathVisualizer +from lower_zair import ShuttleBuilder +import json +import numpy as np + +@move +def lower_zair(shuttle_builder, insts: list): + for inst in insts: + if inst["type"] == "1qGate": + if inst["unitary"] == "ry": + for loc in inst["locs"]: + rotation_angle = np.random.random() + shuttle_builder.r_gate(0, rotation_angle, [loc]) + pass + elif inst["unitary"] == "h": + pass + shuttle_builder.lower_h(inst["locs"]) + else: + raise NotImplementedError + + elif inst["type"] == "rydberg": + shuttle_builder.entangle(inst["zone_id"]) + elif inst["type"] == "rearrangeJob": + shuttle_builder.insert_move(inst["begin_locs", inst["end_locs"]]) + else: + raise NotImplementedError + +def run_qcrank(filename: str): + with open(filename, 'r') as f: + compiled_qcrank = json.load(f) + + arch_filename = compiled_qcrank["architecture_spec_path"] + + with open(arch_filename, 'r') as f: + architecture_spec = json.load(f) + + # set architecture + # assume single entagnlement zone + entanglement_zone_spec = architecture_spec["entanglement_zones"] + slms = entanglement_zone_spec["slms"] + assert len(slms) == 2 + slm0 = slms[0] + slm1 = slms[1] + assert slm0["r"] == slm1["r"] + assert slm0["c"] == slm1["c"] + assert slm0["site_seperation"] == slm1["site_seperation"] + put_vertical = True + if slm0["location"][1] == slm1["location"][1]: + put_vertical = False + if put_vertical: + dis_trap = abs(slm0["location"][1] - slm1["location"][1]) + dis_site = slm0["site_seperation"][1] - dis_trap + x_spacing = [slm0["site_seperation"][0] * (slm0["r"] - 1)] + y_spacing = [] + for _ in slm0["c"]: + y_spacing.append(dis_trap) + y_spacing.append(dis_site) + else: + dis_trap = abs(slm0["location"][0] - slm1["location"][0]) + dis_site = slm0["site_seperation"][0] - dis_trap + y_spacing = [slm0["site_seperation"][1] * (slm0["r"] - 1)] + x_spacing = [] + for _ in slm0["c"]: + x_spacing.append(dis_trap) + x_spacing.append(dis_site) + x_spacing = x_spacing + + inst_init = compiled_qcrank["instructions"][0] + init_quibt_location = inst_init["init_locs"] + + shuttle_builder = ShuttleBuilder(num_qubits = len(init_quibt_location)) + shuttle_builder.construct_grid(entanglement_zone_spec['zone_id'], + entanglement_zone_spec["offset"], + x_spacing, + y_spacing, + entanglement_zone_spec["dimension"]) + + spec_value = spec.ArchSpec( + layout=spec.Layout( + static_traps={ + "mem": shuttle_builder.grid_mapping[0], + }, + fillable=set(["mem"]), + ) + ) + + grid_init_quibt_location = [] + for loc in init_quibt_location: + x = loc[2] + y = loc[3] + if put_vertical: + y *= 2 + else: + x *= 2 + grid_init_quibt_location.append((x,y)) + + @move + def main(): + init.fill(grid_init_quibt_location) + insts = compiled_qcrank["instructions"][1:] + lower_zair(shuttle_builder, insts) + + return measure.measure(shuttle_builder.grid_mapping[0]) + + return main, spec_value + + +def run_plotter(filename: str): + main, spec_value = run_qcrank(filename) + renderer = MatplotlibRenderer() + PathVisualizer(main.dialects, renderer=renderer, arch_spec=spec_value).run(main, ()) + + +if __name__ == "__main__": + filename = "scratch/qcr_4a8d_quera_circ_code.json" + run_plotter(filename) \ No newline at end of file diff --git a/scratch/qcrank_architecture_4_2_v.json b/scratch/qcrank_architecture_4_2_v.json new file mode 100644 index 00000000..7856393b --- /dev/null +++ b/scratch/qcrank_architecture_4_2_v.json @@ -0,0 +1,42 @@ +{ + "name": "qcrank_zoned_architecture", + "operation_duration": { + "rydberg": 0.36, + "raman": 11, + "atom_transfer": 15 + }, + "operation_fidelity": { + "two_qubit_gate": 0.995, + "single_qubit_gate": 0.9997, + "atom_transfer": 0.999 + }, + "qubit_spec":{ + "T": 1.5e6 + }, + "storage_zones": [{}], + "entanglement_zones": [{ + "zone_id": 0, + "slms": [ + { + "id": 1, + "site_seperation": [10, 12], + "r": 2, + "c": 8, + "location": [0, 5] + }, + { + "id": 2, + "site_seperation": [10, 12], + "r": 2, + "c": 8, + "location": [0, 7] + }], + "offset": [0, 5], + "dimension": [70, 3] + }], + "aods":[ + {"id": 0, "site_seperation": 2, "r": 3, "c": 8} + ], + "arch_range": [[0, 5], [70, 21]], + "rydberg_range": [[[0, 5], [70, 21]]] +} \ No newline at end of file From 343235c84eb941ee252eca45dc0351e9ec6e5929 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Sun, 17 Aug 2025 20:18:14 -0700 Subject: [PATCH 02/16] construct structure --- scratch/lower_zair.py | 87 ++++++++++++++++++++++++++++++++++--------- scratch/qcrank.py | 56 +++++++++++++--------------- 2 files changed, 95 insertions(+), 48 deletions(-) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index 3faf4ea9..8bfd8da3 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -3,11 +3,11 @@ from typing import Any, Sequence from kirin import ir from kirin.dialects.ilist import IList -from kirin.dialects import py, func +from kirin.dialects import py, func, ilist from bloqade.shuttle import gate, init, spec from bloqade.geometry import grid from bloqade.shuttle.dialects import gate, filled - +from bloqade.shuttle.stdlib.waypoints import move_by_waypoints def _simple_region() -> ir.Region: return ir.Region(ir.Block()) @@ -15,11 +15,11 @@ def _simple_region() -> ir.Region: @dataclass class ShuttleBuilder: - move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] + # move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] num_qubits: int body: ir.Region = field(default_factory=_simple_region, init=False) - grid_mapping: dict[int, ir.SSAValue] = field(default_factory=dict) + grid_mapping: ir.SSAValue = None def push_stmt(self, stmt: ir.Statement): self.body.blocks[0].stmts.append(stmt) @@ -46,7 +46,7 @@ def construct_grid( ) ) - self.grid_mapping[grid_id] = grid_ref + self.grid_mapping = grid_ref return grid_ref @@ -61,23 +61,76 @@ def insert_move( x_src = [src[2] for src in sorted_srcs] y_src = [src[3] for src in sorted_srcs] - x_dst = [dst[2] for dst in sorted_dsts] - y_dst = [dst[3] for dst in sorted_dsts] + # assume only address qubits will move + x_dst = [dst[2] * 2 for dst in sorted_dsts] + y_dst = [dst[3] * 2 for dst in sorted_dsts] x_src_ref = self.push_constant(x_src) y_src_ref = self.push_constant(y_src) x_dst_ref = self.push_constant(x_dst) y_dst_ref = self.push_constant(y_dst) - self.push_stmt( - func.Invoke( - inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), - callee=self.move_kernel, - kwargs=(), - ) - ) + # horizontal move + is_horizontal_move = True + for x0, x1 in zip(x_src, x_dst): + if x0 != x1: + is_horizontal_move = False + break + if is_horizontal_move: + self.entangle_cols(x_src, x_dst) + else: + self.entangle_rows(y_src, y_dst) + + # self.push_stmt( + # func.Invoke( + # inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), + # callee=self.move_kernel, + # kwargs=(), + # ) + # ) + def entangle_cols(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, Any]): + + # set up zone layout + entangling_pair_dist = 2.0 + path_shift_dist = 3.0 + zone = spec.get_static_trap(zone_id="traps") + traps_shape = grid.shape(zone) + all_rows = ilist.range(traps_shape[1]) + + src = grid.sub_grid(zone, ctrls, all_rows) + dst = grid.sub_grid(zone, qargs, all_rows) + path_shift_dist = abs(src - dst) + # define the moves + first_waypoint = grid.shift(src, 0.0, -path_shift_dist) + second_waypoint = grid.shift(dst, -entangling_pair_dist, -path_shift_dist) + third_waypoint = grid.shift(dst, -entangling_pair_dist, 0.0) + + waypoints = ilist.IList([src, first_waypoint, second_waypoint, third_waypoint]) + + move_by_waypoints(waypoints, True, False) + + def entangle_rows(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, Any]): + + # set up zone layout + entangling_pair_dist = 2.0 + path_shift_dist = 3.0 + traps_shape = grid.shape(self.grid_mapping) + all_cols = ilist.range(traps_shape[0]) + + src = grid.sub_grid(self.grid_mapping, all_cols, ctrls) + dst = grid.sub_grid(self.grid_mapping, all_cols, qargs) + + # define the moves + first_waypoint = grid.shift(src, entangling_pair_dist, 0.0) + second_waypoint = grid.shift(dst, entangling_pair_dist, 0.0) + + waypoints = ilist.IList([src, first_waypoint, second_waypoint]) + + move_by_waypoints(waypoints, True, False) + def single_zone_move_impl( + self, src_x: IList[int, Any], src_y: IList[int, Any], dst_x: IList[int, Any], @@ -92,12 +145,12 @@ def r_gate( self, axis_angle: float, rotation_angle: float, - locs: Sequence[tuple[int, int, int, int]], + locs: Sequence[tuple[int, int, int]], ): filled_locs = {} - for _, grid_id, x, y in locs: - filled_locs.setdefault(grid_id, []).append((x, y)) + for _, x, y in locs: + filled_locs.setdefault(0, []).append((x, y)) filled_loc_refs: dict[int, ir.SSAValue] = {} diff --git a/scratch/qcrank.py b/scratch/qcrank.py index b3d71abc..5eb5fe92 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -10,28 +10,6 @@ import json import numpy as np -@move -def lower_zair(shuttle_builder, insts: list): - for inst in insts: - if inst["type"] == "1qGate": - if inst["unitary"] == "ry": - for loc in inst["locs"]: - rotation_angle = np.random.random() - shuttle_builder.r_gate(0, rotation_angle, [loc]) - pass - elif inst["unitary"] == "h": - pass - shuttle_builder.lower_h(inst["locs"]) - else: - raise NotImplementedError - - elif inst["type"] == "rydberg": - shuttle_builder.entangle(inst["zone_id"]) - elif inst["type"] == "rearrangeJob": - shuttle_builder.insert_move(inst["begin_locs", inst["end_locs"]]) - else: - raise NotImplementedError - def run_qcrank(filename: str): with open(filename, 'r') as f: compiled_qcrank = json.load(f) @@ -43,7 +21,7 @@ def run_qcrank(filename: str): # set architecture # assume single entagnlement zone - entanglement_zone_spec = architecture_spec["entanglement_zones"] + entanglement_zone_spec = architecture_spec["entanglement_zones"][0] slms = entanglement_zone_spec["slms"] assert len(slms) == 2 slm0 = slms[0] @@ -59,7 +37,7 @@ def run_qcrank(filename: str): dis_site = slm0["site_seperation"][1] - dis_trap x_spacing = [slm0["site_seperation"][0] * (slm0["r"] - 1)] y_spacing = [] - for _ in slm0["c"]: + for _ in range(slm0["c"]): y_spacing.append(dis_trap) y_spacing.append(dis_site) else: @@ -67,7 +45,7 @@ def run_qcrank(filename: str): dis_site = slm0["site_seperation"][0] - dis_trap y_spacing = [slm0["site_seperation"][1] * (slm0["r"] - 1)] x_spacing = [] - for _ in slm0["c"]: + for _ in range(slm0["c"]): x_spacing.append(dis_trap) x_spacing.append(dis_site) x_spacing = x_spacing @@ -85,7 +63,7 @@ def run_qcrank(filename: str): spec_value = spec.ArchSpec( layout=spec.Layout( static_traps={ - "mem": shuttle_builder.grid_mapping[0], + "mem": shuttle_builder.grid_mapping, }, fillable=set(["mem"]), ) @@ -100,14 +78,30 @@ def run_qcrank(filename: str): else: x *= 2 grid_init_quibt_location.append((x,y)) - + @move def main(): - init.fill(grid_init_quibt_location) + # init.fill([spec.get_static_trap(zone_id="mem")]) + init.fill(shuttle_builder.grid_mapping) # ! insts = compiled_qcrank["instructions"][1:] - lower_zair(shuttle_builder, insts) - - return measure.measure(shuttle_builder.grid_mapping[0]) + for inst in insts: + if inst["type"] == "1qGate": + if inst["unitary"] == "ry": + for loc in inst["locs"]: + rotation_angle = np.random.random() + if loc[1] == 1: + locs = [(loc[0], 2 * loc[2], loc[3])] + else: + locs = [(loc[0], loc[2], loc[3])] + shuttle_builder.r_gate(0, rotation_angle, locs) + elif inst["unitary"] == "h": + shuttle_builder.lower_h(inst["locs"]) + + elif inst["type"] == "rydberg": + shuttle_builder.entangle(inst["zone_id"]) + elif inst["type"] == "rearrangeJob": + shuttle_builder.insert_move(inst["begin_locs"], inst["end_locs"]) + return measure.measure((shuttle_builder.grid_mapping,)) return main, spec_value From ea63c9499b623f99a6f5bcdd7a11d678019e292a Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Tue, 19 Aug 2025 14:07:14 -0700 Subject: [PATCH 03/16] add back stmt --- scratch/lower_zair.py | 21 +++++++++++---------- scratch/qcrank.py | 1 - 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index 8bfd8da3..8e69151b 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -15,7 +15,7 @@ def _simple_region() -> ir.Region: @dataclass class ShuttleBuilder: - # move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] + move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] num_qubits: int body: ir.Region = field(default_factory=_simple_region, init=False) @@ -81,13 +81,13 @@ def insert_move( else: self.entangle_rows(y_src, y_dst) - # self.push_stmt( - # func.Invoke( - # inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), - # callee=self.move_kernel, - # kwargs=(), - # ) - # ) + self.push_stmt( + func.Invoke( + inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), + callee=self.move_kernel, + kwargs=(), + ) + ) def entangle_cols(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, Any]): @@ -106,7 +106,7 @@ def entangle_cols(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, An second_waypoint = grid.shift(dst, -entangling_pair_dist, -path_shift_dist) third_waypoint = grid.shift(dst, -entangling_pair_dist, 0.0) - waypoints = ilist.IList([src, first_waypoint, second_waypoint, third_waypoint]) + waypoints = ilist.IList([src, first_waypoint, second_waypoint, third_waypoint]) # need to do push constant and get reference to make it runtime move_by_waypoints(waypoints, True, False) @@ -172,4 +172,5 @@ def lower_h(self, locs: Sequence[tuple[int, int, int, int]]): self.push_stmt(gate.GlobalR(0, 0.5)) self.push_stmt(gate.GlobalRz(0.25)) - + +# todo: make all lists to IList diff --git a/scratch/qcrank.py b/scratch/qcrank.py index 5eb5fe92..221a4528 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -79,7 +79,6 @@ def run_qcrank(filename: str): x *= 2 grid_init_quibt_location.append((x,y)) - @move def main(): # init.fill([spec.get_static_trap(zone_id="mem")]) init.fill(shuttle_builder.grid_mapping) # ! From 7e1ac51b98fce183dea44f47a6a0f73fda55b439 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Tue, 19 Aug 2025 14:14:52 -0700 Subject: [PATCH 04/16] change list to IList & change move kernal to rearrange --- scratch/lower_zair.py | 71 +++---------------------------------------- scratch/qcrank.py | 12 ++------ 2 files changed, 7 insertions(+), 76 deletions(-) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index 8e69151b..01077015 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -4,10 +4,8 @@ from kirin import ir from kirin.dialects.ilist import IList from kirin.dialects import py, func, ilist -from bloqade.shuttle import gate, init, spec from bloqade.geometry import grid from bloqade.shuttle.dialects import gate, filled -from bloqade.shuttle.stdlib.waypoints import move_by_waypoints def _simple_region() -> ir.Region: return ir.Region(ir.Block()) @@ -59,27 +57,16 @@ def insert_move( sorted_srcs = sorted(srcs, key=lambda x: x[0]) sorted_dsts = sorted(dsts, key=lambda x: x[0]) - x_src = [src[2] for src in sorted_srcs] - y_src = [src[3] for src in sorted_srcs] + x_src = IList([src[2] for src in sorted_srcs]) + y_src = IList([src[3] for src in sorted_srcs]) # assume only address qubits will move - x_dst = [dst[2] * 2 for dst in sorted_dsts] - y_dst = [dst[3] * 2 for dst in sorted_dsts] + x_dst = IList([dst[2] * 2 for dst in sorted_dsts]) + y_dst = IList([dst[3] * 2 for dst in sorted_dsts]) x_src_ref = self.push_constant(x_src) y_src_ref = self.push_constant(y_src) x_dst_ref = self.push_constant(x_dst) y_dst_ref = self.push_constant(y_dst) - - # horizontal move - is_horizontal_move = True - for x0, x1 in zip(x_src, x_dst): - if x0 != x1: - is_horizontal_move = False - break - if is_horizontal_move: - self.entangle_cols(x_src, x_dst) - else: - self.entangle_rows(y_src, y_dst) self.push_stmt( func.Invoke( @@ -88,56 +75,7 @@ def insert_move( kwargs=(), ) ) - - def entangle_cols(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, Any]): - - # set up zone layout - entangling_pair_dist = 2.0 - path_shift_dist = 3.0 - zone = spec.get_static_trap(zone_id="traps") - traps_shape = grid.shape(zone) - all_rows = ilist.range(traps_shape[1]) - - src = grid.sub_grid(zone, ctrls, all_rows) - dst = grid.sub_grid(zone, qargs, all_rows) - path_shift_dist = abs(src - dst) - # define the moves - first_waypoint = grid.shift(src, 0.0, -path_shift_dist) - second_waypoint = grid.shift(dst, -entangling_pair_dist, -path_shift_dist) - third_waypoint = grid.shift(dst, -entangling_pair_dist, 0.0) - - waypoints = ilist.IList([src, first_waypoint, second_waypoint, third_waypoint]) # need to do push constant and get reference to make it runtime - - move_by_waypoints(waypoints, True, False) - - def entangle_rows(self, ctrls: ilist.IList[int, Any], qargs: ilist.IList[int, Any]): - - # set up zone layout - entangling_pair_dist = 2.0 - path_shift_dist = 3.0 - traps_shape = grid.shape(self.grid_mapping) - all_cols = ilist.range(traps_shape[0]) - - src = grid.sub_grid(self.grid_mapping, all_cols, ctrls) - dst = grid.sub_grid(self.grid_mapping, all_cols, qargs) - - # define the moves - first_waypoint = grid.shift(src, entangling_pair_dist, 0.0) - second_waypoint = grid.shift(dst, entangling_pair_dist, 0.0) - - waypoints = ilist.IList([src, first_waypoint, second_waypoint]) - - move_by_waypoints(waypoints, True, False) - def single_zone_move_impl( - self, - src_x: IList[int, Any], - src_y: IList[int, Any], - dst_x: IList[int, Any], - dst_y: IList[int, Any], - ): - ... - def entangle(self, grid_id: int): self.push_stmt(gate.TopHatCZ(self.grid_mapping[grid_id])) @@ -173,4 +111,3 @@ def lower_h(self, locs: Sequence[tuple[int, int, int, int]]): self.push_stmt(gate.GlobalRz(0.25)) -# todo: make all lists to IList diff --git a/scratch/qcrank.py b/scratch/qcrank.py index 221a4528..77069629 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -4,6 +4,7 @@ from kirin.dialects import ilist from bloqade.shuttle import action, gate, init, measure, schedule, spec +from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange from bloqade.shuttle.prelude import move, tweezer from bloqade.shuttle.visualizer import MatplotlibRenderer, PathVisualizer from lower_zair import ShuttleBuilder @@ -53,7 +54,7 @@ def run_qcrank(filename: str): inst_init = compiled_qcrank["instructions"][0] init_quibt_location = inst_init["init_locs"] - shuttle_builder = ShuttleBuilder(num_qubits = len(init_quibt_location)) + shuttle_builder = ShuttleBuilder(num_qubits = len(init_quibt_location), move_kernel=rearrange) shuttle_builder.construct_grid(entanglement_zone_spec['zone_id'], entanglement_zone_spec["offset"], x_spacing, @@ -105,12 +106,5 @@ def main(): return main, spec_value -def run_plotter(filename: str): - main, spec_value = run_qcrank(filename) - renderer = MatplotlibRenderer() - PathVisualizer(main.dialects, renderer=renderer, arch_spec=spec_value).run(main, ()) - - if __name__ == "__main__": - filename = "scratch/qcr_4a8d_quera_circ_code.json" - run_plotter(filename) \ No newline at end of file + filename = "scratch/qcr_4a8d_quera_circ_code.json" \ No newline at end of file From 6c9b76cdc59dcc98864f9e70811eed9f96953a23 Mon Sep 17 00:00:00 2001 From: Phillip Weinberg Date: Thu, 21 Aug 2025 13:32:55 -0400 Subject: [PATCH 05/16] sketching more of the lowering --- scratch/lower_zair.py | 192 +++++++++++++++++++++++++++++------------- scratch/qcrank.py | 51 ++++++----- 2 files changed, 160 insertions(+), 83 deletions(-) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index 01077015..daec04b9 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -1,11 +1,15 @@ -from dataclasses import dataclass, field +import json import math -from typing import Any, Sequence -from kirin import ir +from dataclasses import dataclass, field +from typing import Any, Generic, Sequence, TypeVar + +from kirin import ir, types +from kirin.dialects import func, ilist, py from kirin.dialects.ilist import IList -from kirin.dialects import py, func, ilist -from bloqade.geometry import grid -from bloqade.shuttle.dialects import gate, filled + +from bloqade.shuttle.dialects import filled, gate, init, spec +from bloqade.shuttle.prelude import move + def _simple_region() -> ir.Region: return ir.Region(ir.Block()) @@ -13,11 +17,14 @@ def _simple_region() -> ir.Region: @dataclass class ShuttleBuilder: - move_kernel: ir.Method[[IList[tuple[int, int]], IList[tuple[int, int]]], None] - num_qubits: int + spec_mapping: dict[int, str] + move_kernel: ir.Method[ + [IList[int, Any], IList[int, Any], IList[int, Any], IList[int, Any]], None + ] + + num_qubits: int = field(init=False) body: ir.Region = field(default_factory=_simple_region, init=False) - grid_mapping: ir.SSAValue = None def push_stmt(self, stmt: ir.Statement): self.body.blocks[0].stmts.append(stmt) @@ -27,47 +34,35 @@ def push_constant(self, value: Any) -> ir.SSAValue: const_stmt = py.Constant(value) return self.push_stmt(const_stmt).expect_one_result() - def construct_grid( + def get_zone(self, zone_id: int) -> ir.SSAValue: + return self.push_stmt( + spec.GetStaticTrap(zone_id=self.spec_mapping[zone_id]) + ).expect_one_result() + + def get_slm( self, - grid_id: int, - offset: tuple[int, int], - x_spacing: list[int], - y_spacing: list[int], - dim: tuple[int, int], + slm_id: int, ): - x_init = offset[0] - y_init = offset[1] - - grid_ref = self.push_constant( - grid.Grid( - x_spacing=tuple(x_spacing), y_spacing=tuple(y_spacing), x_init=x_init, y_init=y_init - ) - ) - - self.grid_mapping = grid_ref - - return grid_ref + return self.push_stmt( + spec.GetStaticTrap(zone_id=self.spec_mapping[slm_id]) + ).expect_one_result() - def insert_move( + def lower_rearrange( self, - srcs: Sequence[tuple[int, int, int, int]], - dsts: Sequence[tuple[int, int, int, int]], + begin_locs: Sequence[tuple[int, int, int, int]], + end_locs: Sequence[tuple[int, int, int, int]], ): - # ignoring zone mapping, - sorted_srcs = sorted(srcs, key=lambda x: x[0]) - sorted_dsts = sorted(dsts, key=lambda x: x[0]) - - x_src = IList([src[2] for src in sorted_srcs]) - y_src = IList([src[3] for src in sorted_srcs]) - # assume only address qubits will move - x_dst = IList([dst[2] * 2 for dst in sorted_dsts]) - y_dst = IList([dst[3] * 2 for dst in sorted_dsts]) + # ignoring zone mapping, only include all unique x and y positions + x_src = IList(sorted(set(src[2] for src in begin_locs))) + y_src = IList(sorted(set(src[3] for src in begin_locs))) + x_dst = IList(sorted(set(dst[2] for dst in end_locs))) + y_dst = IList(sorted(set(dst[3] for dst in end_locs))) x_src_ref = self.push_constant(x_src) y_src_ref = self.push_constant(y_src) x_dst_ref = self.push_constant(x_dst) y_dst_ref = self.push_constant(y_dst) - + self.push_stmt( func.Invoke( inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), @@ -75,39 +70,116 @@ def insert_move( kwargs=(), ) ) - - def entangle(self, grid_id: int): - self.push_stmt(gate.TopHatCZ(self.grid_mapping[grid_id])) - def r_gate( + def rydberg(self, zone_id: int): + self.push_stmt(gate.TopHatCZ(self.get_zone(zone_id))) + + def lower_r_gate( self, axis_angle: float, rotation_angle: float, - locs: Sequence[tuple[int, int, int]], + locs: Sequence[tuple[int, int, int, int]], ): - filled_locs = {} + filled_locs: dict[int, list[tuple[int, int]]] = {} - for _, x, y in locs: - filled_locs.setdefault(0, []).append((x, y)) + for _, grid_id, x, y in locs: + filled_locs.setdefault(grid_id, []).append((x, y)) - filled_loc_refs: dict[int, ir.SSAValue] = {} + filled_loc_refs: list[ir.SSAValue] = [] - for grid_id, locs in filled_locs.items(): - locs_ref = self.push_constant(locs) - filled_loc_refs[grid_id] = self.push_stmt( - filled.Fill(self.grid_mapping[grid_id], locs_ref) - ).expect_one_result() + for grid_id, coords in filled_locs.items(): + locs_ref = self.push_constant(ilist.IList(coords)) + filled_loc_refs.append( + self.push_stmt( + filled.Fill(self.get_slm(grid_id), locs_ref) + ).expect_one_result() + ) axis_angle_ref = self.push_constant(axis_angle / (2 * math.pi)) rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) - for filled_ref in filled_loc_refs.values(): + for filled_ref in filled_loc_refs: self.push_stmt(gate.LocalR(axis_angle_ref, rotation_angle_ref, filled_ref)) + def lower_rz_gate( + self, rotation_angle: float, locations: Sequence[tuple[int, int, int, int]] + ): + filled_locs: dict[int, list[tuple[int, int]]] = {} + + for _, grid_id, x, y in locations: + filled_locs.setdefault(grid_id, []).append((x, y)) + + filled_loc_refs: list[ir.SSAValue] = [] + + for grid_id, coords in filled_locs.items(): + locs_ref = self.push_constant(ilist.IList(coords)) + filled_loc_refs.append( + self.push_stmt( + filled.Fill(self.get_slm(grid_id), locs_ref) + ).expect_one_result() + ) + + rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) + + for filled_ref in filled_loc_refs: + self.push_stmt(gate.LocalRz(rotation_angle_ref, filled_ref)) + def lower_h(self, locs: Sequence[tuple[int, int, int, int]]): - assert len(locs) == self.num_qubits, "H gate must be applied to all qubits" - self.push_stmt(gate.GlobalRz(0.25)) - self.push_stmt(gate.GlobalR(0, 0.5)) - self.push_stmt(gate.GlobalRz(0.25)) + quarter_rotation = self.push_constant(0.25) + zero = self.push_constant(0.0) + half_rotation = self.push_constant(0.5) + if len(locs) == self.num_qubits: + + self.push_stmt(gate.GlobalRz(quarter_rotation)) + self.push_stmt(gate.GlobalR(zero, half_rotation)) + self.push_stmt(gate.GlobalRz(quarter_rotation)) + + def lower_init(self, locs: Sequence[tuple[int, int, int, int]]): + filled_locs: dict[int, list[tuple[int, int]]] = {} + + for _, grid_id, x, y in locs: + filled_locs.setdefault(grid_id, []).append((x, y)) - + filled_loc_refs: list[ir.SSAValue] = [] + + for grid_id, coords in filled_locs.items(): + locs_ref = self.push_constant(ilist.IList(coords)) + filled_loc_refs.append( + self.push_stmt( + filled.Fill(self.get_slm(grid_id), locs_ref) + ).expect_one_result() + ) + + locations = self.push_constant(ilist.IList(filled_loc_refs)) + self.push_stmt(init.Fill(locations)) + + def lower_instruction(self, instruction: dict[str, Any]): + match instruction: + case {"type": "init", "locs": locs}: + self.lower_init(locs) + case {"type": "1qGate", "unitary": "ry", "locs": locs}: + raise NotImplementedError + case {"type": "1qGate", "unitary": "h", "locs": locs}: + self.lower_h(locs) + case {"type": "rydberg", "zone_id": zone_id}: + self.rydberg(zone_id) + case { + "type": "rearrangeJob", + "begin_locs": begin_locs, + "end_locs": end_locs, + }: + self.lower_rearrange(begin_locs, end_locs) + + def lower(self, program: dict[str, Any]) -> ir.Method: + sym_name = program["name"] + signature = func.Signature((), types.NoneType) + + for inst in program["instructions"]: + self.lower_instruction(inst) + + code = func.Function( + sym_name=sym_name, + signature=signature, + body=self.body, + ) + return ir.Method(None, None, sym_name, [], move, code) diff --git a/scratch/qcrank.py b/scratch/qcrank.py index 77069629..bf20db13 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -1,28 +1,29 @@ +import json from typing import Any, Literal, TypeVar +import numpy as np from bloqade.geometry.dialects import grid from kirin.dialects import ilist +from lower_zair import ShuttleBuilder from bloqade.shuttle import action, gate, init, measure, schedule, spec -from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange from bloqade.shuttle.prelude import move, tweezer +from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange from bloqade.shuttle.visualizer import MatplotlibRenderer, PathVisualizer -from lower_zair import ShuttleBuilder -import json -import numpy as np + def run_qcrank(filename: str): - with open(filename, 'r') as f: + with open(filename, "r") as f: compiled_qcrank = json.load(f) - + arch_filename = compiled_qcrank["architecture_spec_path"] - with open(arch_filename, 'r') as f: + with open(arch_filename, "r") as f: architecture_spec = json.load(f) # set architecture # assume single entagnlement zone - entanglement_zone_spec = architecture_spec["entanglement_zones"][0] + entanglement_zone_spec = architecture_spec["entanglement_zones"][0] slms = entanglement_zone_spec["slms"] assert len(slms) == 2 slm0 = slms[0] @@ -50,21 +51,25 @@ def run_qcrank(filename: str): x_spacing.append(dis_trap) x_spacing.append(dis_site) x_spacing = x_spacing - + inst_init = compiled_qcrank["instructions"][0] init_quibt_location = inst_init["init_locs"] - - shuttle_builder = ShuttleBuilder(num_qubits = len(init_quibt_location), move_kernel=rearrange) - shuttle_builder.construct_grid(entanglement_zone_spec['zone_id'], - entanglement_zone_spec["offset"], - x_spacing, - y_spacing, - entanglement_zone_spec["dimension"]) + + shuttle_builder = ShuttleBuilder( + num_qubits=len(init_quibt_location), move_kernel=rearrange + ) + shuttle_builder.construct_grid( + entanglement_zone_spec["zone_id"], + entanglement_zone_spec["offset"], + x_spacing, + y_spacing, + entanglement_zone_spec["dimension"], + ) spec_value = spec.ArchSpec( layout=spec.Layout( static_traps={ - "mem": shuttle_builder.grid_mapping, + "mem": shuttle_builder.spec_mapping, }, fillable=set(["mem"]), ) @@ -78,11 +83,11 @@ def run_qcrank(filename: str): y *= 2 else: x *= 2 - grid_init_quibt_location.append((x,y)) - + grid_init_quibt_location.append((x, y)) + def main(): # init.fill([spec.get_static_trap(zone_id="mem")]) - init.fill(shuttle_builder.grid_mapping) # ! + init.fill(shuttle_builder.spec_mapping) # ! insts = compiled_qcrank["instructions"][1:] for inst in insts: if inst["type"] == "1qGate": @@ -93,7 +98,7 @@ def main(): locs = [(loc[0], 2 * loc[2], loc[3])] else: locs = [(loc[0], loc[2], loc[3])] - shuttle_builder.r_gate(0, rotation_angle, locs) + shuttle_builder.lower_r_gate(0, rotation_angle, locs) elif inst["unitary"] == "h": shuttle_builder.lower_h(inst["locs"]) @@ -101,10 +106,10 @@ def main(): shuttle_builder.entangle(inst["zone_id"]) elif inst["type"] == "rearrangeJob": shuttle_builder.insert_move(inst["begin_locs"], inst["end_locs"]) - return measure.measure((shuttle_builder.grid_mapping,)) + return measure.measure((shuttle_builder.spec_mapping,)) return main, spec_value if __name__ == "__main__": - filename = "scratch/qcr_4a8d_quera_circ_code.json" \ No newline at end of file + filename = "scratch/qcr_4a8d_quera_circ_code.json" From a4683b5eb50a36b5f3a863d42c6e23864c21ad26 Mon Sep 17 00:00:00 2001 From: Phillip Weinberg Date: Thu, 21 Aug 2025 13:36:07 -0400 Subject: [PATCH 06/16] Adding doc string --- scratch/lower_zair.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index daec04b9..1935da42 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -171,6 +171,14 @@ def lower_instruction(self, instruction: dict[str, Any]): self.lower_rearrange(begin_locs, end_locs) def lower(self, program: dict[str, Any]) -> ir.Method: + """Entry point for lowering a ZAIR program + + Args: + program (dict[str, Any]): JSON representation of the ZAIR program + + Returns: + ir.Method: Lowered IR method + """ sym_name = program["name"] signature = func.Signature((), types.NoneType) From 2f36e02812a10577e1213a65c349bb353da7fa36 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Thu, 21 Aug 2025 17:06:49 -0700 Subject: [PATCH 07/16] add ry --- scratch/lower_zair.py | 13 +- scratch/qcr_4a8d_quera_circ_code.json | 1277 +++++++++++++++---------- scratch/qcrank.py | 120 +-- 3 files changed, 827 insertions(+), 583 deletions(-) diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py index 1935da42..9fe1b45c 100644 --- a/scratch/lower_zair.py +++ b/scratch/lower_zair.py @@ -22,8 +22,8 @@ class ShuttleBuilder: move_kernel: ir.Method[ [IList[int, Any], IList[int, Any], IList[int, Any], IList[int, Any]], None ] + num_qubits: int - num_qubits: int = field(init=False) body: ir.Region = field(default_factory=_simple_region, init=False) def push_stmt(self, stmt: ir.Statement): @@ -74,9 +74,8 @@ def lower_rearrange( def rydberg(self, zone_id: int): self.push_stmt(gate.TopHatCZ(self.get_zone(zone_id))) - def lower_r_gate( + def lower_ry_gate( self, - axis_angle: float, rotation_angle: float, locs: Sequence[tuple[int, int, int, int]], ): @@ -95,11 +94,11 @@ def lower_r_gate( ).expect_one_result() ) - axis_angle_ref = self.push_constant(axis_angle / (2 * math.pi)) + axis_angle = self.push_constant(0.5) rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) for filled_ref in filled_loc_refs: - self.push_stmt(gate.LocalR(axis_angle_ref, rotation_angle_ref, filled_ref)) + self.push_stmt(gate.LocalR(axis_angle, rotation_angle_ref, filled_ref)) def lower_rz_gate( self, rotation_angle: float, locations: Sequence[tuple[int, int, int, int]] @@ -157,8 +156,8 @@ def lower_instruction(self, instruction: dict[str, Any]): match instruction: case {"type": "init", "locs": locs}: self.lower_init(locs) - case {"type": "1qGate", "unitary": "ry", "locs": locs}: - raise NotImplementedError + case {"type": "1qGate", "unitary": "ry", "locs": locs, "angle": angle}: + self.lower_ry_gate(angle, locs) case {"type": "1qGate", "unitary": "h", "locs": locs}: self.lower_h(locs) case {"type": "rydberg", "zone_id": zone_id}: diff --git a/scratch/qcr_4a8d_quera_circ_code.json b/scratch/qcr_4a8d_quera_circ_code.json index 1438ba89..45e32761 100644 --- a/scratch/qcr_4a8d_quera_circ_code.json +++ b/scratch/qcr_4a8d_quera_circ_code.json @@ -163,51 +163,63 @@ "gates": [ { "name": "h", - "q": 0 + "q": 0, + "angle": 0 }, { "name": "h", - "q": 1 + "q": 1, + "angle": 0 }, { "name": "h", - "q": 2 + "q": 2, + "angle": 0 }, { "name": "h", - "q": 3 + "q": 3, + "angle": 0 }, { "name": "h", - "q": 4 + "q": 4, + "angle": 0 }, { "name": "h", - "q": 5 + "q": 5, + "angle": 0 }, { "name": "h", - "q": 6 + "q": 6, + "angle": 0 }, { "name": "h", - "q": 7 + "q": 7, + "angle": 0 }, { "name": "h", - "q": 8 + "q": 8, + "angle": 0 }, { "name": "h", - "q": 9 + "q": 9, + "angle": 0 }, { "name": "h", - "q": 10 + "q": 10, + "angle": 0 }, { "name": "h", - "q": 11 + "q": 11, + "angle": 0 } ], "begin_time": 0, @@ -216,6 +228,7 @@ { "type": "1qGate", "unitary": "ry", + "angle": 0.9728764459611823, "id": 2, "locs": [ [ @@ -223,43 +236,113 @@ 1, 0, 2 - ], + ] + ], + "begin_time": 26.5, + "end_time": 46.125 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.41775814709829173, + "id": 3, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 46.125, + "end_time": 65.75 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6663321264692436, + "id": 4, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 65.75, + "end_time": 85.375 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.32351121554355267, + "id": 5, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 85.375, + "end_time": 105.0 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6733003535129568, + "id": 6, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 105.0, + "end_time": 124.625 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.30206885247214277, + "id": 7, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 124.625, + "end_time": 144.25 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.7210451785067075, + "id": 8, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 144.25, + "end_time": 163.875 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.04661000097449375, + "id": 9, + "locs": [ [ 7, 1, @@ -267,46 +350,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 26.5, - "end_time": 50.5 + "begin_time": 163.875, + "end_time": 183.5 }, { "type": "rydberg", - "id": 3, + "id": 10, "zone_id": 0, "gates": [ [ @@ -326,12 +375,12 @@ 7 ] ], - "begin_time": 50.5, - "end_time": 50.86 + "begin_time": 183.5, + "end_time": 183.86 }, { "type": "rearrangeJob", - "id": 4, + "id": 11, "aod_id": 0, "aod_qubits": [ 0, @@ -437,8 +486,8 @@ ] ], "id": 0, - "begin_time": 50.86, - "end_time": 65.86 + "begin_time": 183.86, + "end_time": 198.86 }, { "type": "move:big", @@ -567,8 +616,8 @@ ] ], "id": 1, - "begin_time": 65.86, - "end_time": 131.91782590758163 + "begin_time": 198.86, + "end_time": 264.9178259075817 }, { "type": "deactivate", @@ -582,16 +631,16 @@ 0 ], "id": 2, - "begin_time": 131.91782590758163, - "end_time": 146.91782590758163 + "begin_time": 264.9178259075817, + "end_time": 279.9178259075817 } ], - "begin_time": 50.86, - "end_time": 146.91782590758163 + "begin_time": 183.86, + "end_time": 279.9178259075817 }, { "type": "rydberg", - "id": 5, + "id": 12, "zone_id": 0, "gates": [ [ @@ -611,12 +660,12 @@ 11 ] ], - "begin_time": 146.91782590758163, - "end_time": 147.27782590758164 + "begin_time": 279.9178259075817, + "end_time": 280.2778259075817 }, { "type": "rearrangeJob", - "id": 6, + "id": 13, "aod_id": 0, "aod_qubits": [ 0, @@ -722,8 +771,8 @@ ] ], "id": 0, - "begin_time": 147.27782590758164, - "end_time": 162.27782590758164 + "begin_time": 280.2778259075817, + "end_time": 295.2778259075817 }, { "type": "move:big", @@ -852,8 +901,8 @@ ] ], "id": 1, - "begin_time": 162.27782590758164, - "end_time": 222.58009482313437 + "begin_time": 295.2778259075817, + "end_time": 355.5800948231344 }, { "type": "deactivate", @@ -867,8 +916,8 @@ 0 ], "id": 2, - "begin_time": 222.58009482313437, - "end_time": 237.58009482313437 + "begin_time": 355.5800948231344, + "end_time": 370.5800948231344 }, { "type": "activate", @@ -897,8 +946,8 @@ ] ], "id": 3, - "begin_time": 237.58009482313437, - "end_time": 252.58009482313437 + "begin_time": 370.5800948231344, + "end_time": 385.5800948231344 }, { "type": "move:big", @@ -994,8 +1043,8 @@ ] ], "id": 4, - "begin_time": 252.58009482313437, - "end_time": 373.1846326542398 + "begin_time": 385.5800948231344, + "end_time": 506.18463265423986 }, { "type": "deactivate", @@ -1006,60 +1055,131 @@ 0 ], "id": 5, - "begin_time": 373.1846326542398, - "end_time": 388.1846326542398 + "begin_time": 506.18463265423986, + "end_time": 521.1846326542399 } ], - "begin_time": 147.27782590758164, - "end_time": 388.1846326542398 + "begin_time": 280.2778259075817, + "end_time": 521.1846326542399 }, { "type": "1qGate", "unitary": "ry", - "id": 7, + "angle": 0.6813611442387034, + "id": 14, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 521.1846326542399, + "end_time": 540.8096326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.2836120193512349, + "id": 15, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 540.8096326542399, + "end_time": 560.4346326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.254616115097106, + "id": 16, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 560.4346326542399, + "end_time": 580.0596326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6421215212295661, + "id": 17, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 580.0596326542399, + "end_time": 599.6846326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.5143008696304473, + "id": 18, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 599.6846326542399, + "end_time": 619.3096326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6180087541303749, + "id": 19, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 619.3096326542399, + "end_time": 638.9346326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.8354001838563577, + "id": 20, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 638.9346326542399, + "end_time": 658.5596326542399 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.3124219392856846, + "id": 21, + "locs": [ [ 7, 1, @@ -1067,46 +1187,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 388.1846326542398, - "end_time": 412.1846326542398 + "begin_time": 658.5596326542399, + "end_time": 678.1846326542399 }, { "type": "rydberg", - "id": 8, + "id": 22, "zone_id": 0, "gates": [ [ @@ -1126,12 +1212,12 @@ 8 ] ], - "begin_time": 412.1846326542398, - "end_time": 412.5446326542398 + "begin_time": 678.1846326542399, + "end_time": 678.5446326542399 }, { "type": "rearrangeJob", - "id": 9, + "id": 23, "aod_id": 0, "aod_qubits": [ 0, @@ -1237,8 +1323,8 @@ ] ], "id": 0, - "begin_time": 412.5446326542398, - "end_time": 427.5446326542398 + "begin_time": 678.5446326542399, + "end_time": 693.5446326542399 }, { "type": "move:big", @@ -1367,8 +1453,8 @@ ] ], "id": 1, - "begin_time": 427.5446326542398, - "end_time": 493.60245856182144 + "begin_time": 693.5446326542399, + "end_time": 759.6024585618215 }, { "type": "deactivate", @@ -1382,16 +1468,16 @@ 1 ], "id": 2, - "begin_time": 493.60245856182144, - "end_time": 508.60245856182144 + "begin_time": 759.6024585618215, + "end_time": 774.6024585618215 } ], - "begin_time": 412.5446326542398, - "end_time": 508.60245856182144 + "begin_time": 678.5446326542399, + "end_time": 774.6024585618215 }, { "type": "rydberg", - "id": 10, + "id": 24, "zone_id": 0, "gates": [ [ @@ -1411,12 +1497,12 @@ 4 ] ], - "begin_time": 508.60245856182144, - "end_time": 508.96245856182145 + "begin_time": 774.6024585618215, + "end_time": 774.9624585618216 }, { "type": "rearrangeJob", - "id": 11, + "id": 25, "aod_id": 0, "aod_qubits": [ 0, @@ -1522,8 +1608,8 @@ ] ], "id": 0, - "begin_time": 508.96245856182145, - "end_time": 523.9624585618214 + "begin_time": 774.9624585618216, + "end_time": 789.9624585618216 }, { "type": "move:big", @@ -1652,8 +1738,8 @@ ] ], "id": 1, - "begin_time": 523.9624585618214, - "end_time": 584.2647274773742 + "begin_time": 789.9624585618216, + "end_time": 850.2647274773743 }, { "type": "deactivate", @@ -1667,8 +1753,8 @@ 1 ], "id": 2, - "begin_time": 584.2647274773742, - "end_time": 599.2647274773742 + "begin_time": 850.2647274773743, + "end_time": 865.2647274773743 }, { "type": "activate", @@ -1697,8 +1783,8 @@ ] ], "id": 3, - "begin_time": 599.2647274773742, - "end_time": 614.2647274773742 + "begin_time": 865.2647274773743, + "end_time": 880.2647274773743 }, { "type": "move:big", @@ -1794,8 +1880,8 @@ ] ], "id": 4, - "begin_time": 614.2647274773742, - "end_time": 734.8692653084796 + "begin_time": 880.2647274773743, + "end_time": 1000.8692653084797 }, { "type": "deactivate", @@ -1806,60 +1892,131 @@ 0 ], "id": 5, - "begin_time": 734.8692653084796, - "end_time": 749.8692653084796 + "begin_time": 1000.8692653084797, + "end_time": 1015.8692653084797 } ], - "begin_time": 508.96245856182145, - "end_time": 749.8692653084796 + "begin_time": 774.9624585618216, + "end_time": 1015.8692653084797 }, { "type": "1qGate", "unitary": "ry", - "id": 12, + "angle": 0.196172489039663, + "id": 26, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 1015.8692653084797, + "end_time": 1035.4942653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.9328341463113734, + "id": 27, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 1035.4942653084797, + "end_time": 1055.1192653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.9176827880106695, + "id": 28, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 1055.1192653084797, + "end_time": 1074.7442653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.024278565236902305, + "id": 29, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 1074.7442653084797, + "end_time": 1094.3692653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.2511971251592853, + "id": 30, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 1094.3692653084797, + "end_time": 1113.9942653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.5747693418047549, + "id": 31, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 1113.9942653084797, + "end_time": 1133.6192653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.565733876498433, + "id": 32, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 1133.6192653084797, + "end_time": 1153.2442653084797 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.9746566547127251, + "id": 33, + "locs": [ [ 7, 1, @@ -1867,46 +2024,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 749.8692653084796, - "end_time": 773.8692653084796 + "begin_time": 1153.2442653084797, + "end_time": 1172.8692653084797 }, { "type": "rydberg", - "id": 13, + "id": 34, "zone_id": 0, "gates": [ [ @@ -1926,12 +2049,12 @@ 7 ] ], - "begin_time": 773.8692653084796, - "end_time": 774.2292653084796 + "begin_time": 1172.8692653084797, + "end_time": 1173.2292653084796 }, { "type": "rearrangeJob", - "id": 14, + "id": 35, "aod_id": 0, "aod_qubits": [ 0, @@ -2037,8 +2160,8 @@ ] ], "id": 0, - "begin_time": 774.2292653084796, - "end_time": 789.2292653084796 + "begin_time": 1173.2292653084796, + "end_time": 1188.2292653084796 }, { "type": "move:big", @@ -2167,8 +2290,8 @@ ] ], "id": 1, - "begin_time": 789.2292653084796, - "end_time": 855.2870912160613 + "begin_time": 1188.2292653084796, + "end_time": 1254.2870912160613 }, { "type": "deactivate", @@ -2182,16 +2305,16 @@ 0 ], "id": 2, - "begin_time": 855.2870912160613, - "end_time": 870.2870912160613 + "begin_time": 1254.2870912160613, + "end_time": 1269.2870912160613 } ], - "begin_time": 774.2292653084796, - "end_time": 870.2870912160613 + "begin_time": 1173.2292653084796, + "end_time": 1269.2870912160613 }, { "type": "rydberg", - "id": 15, + "id": 36, "zone_id": 0, "gates": [ [ @@ -2211,12 +2334,12 @@ 11 ] ], - "begin_time": 870.2870912160613, - "end_time": 870.6470912160613 + "begin_time": 1269.2870912160613, + "end_time": 1269.6470912160612 }, { "type": "rearrangeJob", - "id": 16, + "id": 37, "aod_id": 0, "aod_qubits": [ 0, @@ -2322,8 +2445,8 @@ ] ], "id": 0, - "begin_time": 870.6470912160613, - "end_time": 885.6470912160613 + "begin_time": 1269.6470912160612, + "end_time": 1284.6470912160612 }, { "type": "move:big", @@ -2452,8 +2575,8 @@ ] ], "id": 1, - "begin_time": 885.6470912160613, - "end_time": 970.9273777583055 + "begin_time": 1284.6470912160612, + "end_time": 1369.9273777583053 }, { "type": "deactivate", @@ -2467,8 +2590,8 @@ 0 ], "id": 2, - "begin_time": 970.9273777583055, - "end_time": 985.9273777583055 + "begin_time": 1369.9273777583053, + "end_time": 1384.9273777583053 }, { "type": "activate", @@ -2503,8 +2626,8 @@ ] ], "id": 3, - "begin_time": 985.9273777583055, - "end_time": 1000.9273777583055 + "begin_time": 1384.9273777583053, + "end_time": 1399.9273777583053 }, { "type": "move:big", @@ -2611,8 +2734,8 @@ ] ], "id": 4, - "begin_time": 1000.9273777583055, - "end_time": 1121.531915589411 + "begin_time": 1399.9273777583053, + "end_time": 1520.5319155894108 }, { "type": "deactivate", @@ -2624,60 +2747,131 @@ 1 ], "id": 5, - "begin_time": 1121.531915589411, - "end_time": 1136.531915589411 + "begin_time": 1520.5319155894108, + "end_time": 1535.5319155894108 } ], - "begin_time": 870.6470912160613, - "end_time": 1136.531915589411 + "begin_time": 1269.6470912160612, + "end_time": 1535.5319155894108 }, { "type": "1qGate", "unitary": "ry", - "id": 17, + "angle": 0.5897402376101286, + "id": 38, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 1535.5319155894108, + "end_time": 1555.1569155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6289974169797188, + "id": 39, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 1555.1569155894108, + "end_time": 1574.7819155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.7829845397950053, + "id": 40, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 1574.7819155894108, + "end_time": 1594.4069155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6337013520609717, + "id": 41, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 1594.4069155894108, + "end_time": 1614.0319155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.664199238607709, + "id": 42, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 1614.0319155894108, + "end_time": 1633.6569155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.8270404769093707, + "id": 43, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 1633.6569155894108, + "end_time": 1653.2819155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.06715931946317755, + "id": 44, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 1653.2819155894108, + "end_time": 1672.9069155894108 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6185622712304147, + "id": 45, + "locs": [ [ 7, 1, @@ -2685,46 +2879,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 1136.531915589411, - "end_time": 1160.531915589411 + "begin_time": 1672.9069155894108, + "end_time": 1692.5319155894108 }, { "type": "rydberg", - "id": 18, + "id": 46, "zone_id": 0, "gates": [ [ @@ -2744,12 +2904,12 @@ 8 ] ], - "begin_time": 1160.531915589411, - "end_time": 1160.891915589411 + "begin_time": 1692.5319155894108, + "end_time": 1692.8919155894107 }, { "type": "rearrangeJob", - "id": 19, + "id": 47, "aod_id": 0, "aod_qubits": [ 0, @@ -2855,8 +3015,8 @@ ] ], "id": 0, - "begin_time": 1160.891915589411, - "end_time": 1175.891915589411 + "begin_time": 1692.8919155894107, + "end_time": 1707.8919155894107 }, { "type": "move:big", @@ -2985,8 +3145,8 @@ ] ], "id": 1, - "begin_time": 1175.891915589411, - "end_time": 1241.9497414969926 + "begin_time": 1707.8919155894107, + "end_time": 1773.9497414969924 }, { "type": "deactivate", @@ -3000,16 +3160,16 @@ 2 ], "id": 2, - "begin_time": 1241.9497414969926, - "end_time": 1256.9497414969926 + "begin_time": 1773.9497414969924, + "end_time": 1788.9497414969924 } ], - "begin_time": 1160.891915589411, - "end_time": 1256.9497414969926 + "begin_time": 1692.8919155894107, + "end_time": 1788.9497414969924 }, { "type": "rydberg", - "id": 20, + "id": 48, "zone_id": 0, "gates": [ [ @@ -3029,12 +3189,12 @@ 4 ] ], - "begin_time": 1256.9497414969926, - "end_time": 1257.3097414969925 + "begin_time": 1788.9497414969924, + "end_time": 1789.3097414969923 }, { "type": "rearrangeJob", - "id": 21, + "id": 49, "aod_id": 0, "aod_qubits": [ 0, @@ -3140,8 +3300,8 @@ ] ], "id": 0, - "begin_time": 1257.3097414969925, - "end_time": 1272.3097414969925 + "begin_time": 1789.3097414969923, + "end_time": 1804.3097414969923 }, { "type": "move:big", @@ -3270,8 +3430,8 @@ ] ], "id": 1, - "begin_time": 1272.3097414969925, - "end_time": 1357.5900280392366 + "begin_time": 1804.3097414969923, + "end_time": 1889.5900280392364 }, { "type": "deactivate", @@ -3285,8 +3445,8 @@ 2 ], "id": 2, - "begin_time": 1357.5900280392366, - "end_time": 1372.5900280392366 + "begin_time": 1889.5900280392364, + "end_time": 1904.5900280392364 }, { "type": "activate", @@ -3321,8 +3481,8 @@ ] ], "id": 3, - "begin_time": 1372.5900280392366, - "end_time": 1387.5900280392366 + "begin_time": 1904.5900280392364, + "end_time": 1919.5900280392364 }, { "type": "move:big", @@ -3429,8 +3589,8 @@ ] ], "id": 4, - "begin_time": 1387.5900280392366, - "end_time": 1508.194565870342 + "begin_time": 1919.5900280392364, + "end_time": 2040.1945658703419 }, { "type": "deactivate", @@ -3442,60 +3602,131 @@ 0 ], "id": 5, - "begin_time": 1508.194565870342, - "end_time": 1523.194565870342 + "begin_time": 2040.1945658703419, + "end_time": 2055.1945658703416 } ], - "begin_time": 1257.3097414969925, - "end_time": 1523.194565870342 + "begin_time": 1789.3097414969923, + "end_time": 2055.1945658703416 }, { "type": "1qGate", "unitary": "ry", - "id": 22, + "angle": 0.2791144433467644, + "id": 50, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 2055.1945658703416, + "end_time": 2074.8195658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.33551635535479407, + "id": 51, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 2074.8195658703416, + "end_time": 2094.4445658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.8788439445641223, + "id": 52, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 2094.4445658703416, + "end_time": 2114.0695658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.09634919995667235, + "id": 53, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 2114.0695658703416, + "end_time": 2133.6945658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.993681707321558, + "id": 54, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 2133.6945658703416, + "end_time": 2153.3195658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.22442592143739715, + "id": 55, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 2153.3195658703416, + "end_time": 2172.9445658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.9301353937113377, + "id": 56, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 2172.9445658703416, + "end_time": 2192.5695658703416 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.16981932342710426, + "id": 57, + "locs": [ [ 7, 1, @@ -3503,46 +3734,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 1523.194565870342, - "end_time": 1547.194565870342 + "begin_time": 2192.5695658703416, + "end_time": 2212.1945658703416 }, { "type": "rydberg", - "id": 23, + "id": 58, "zone_id": 0, "gates": [ [ @@ -3562,12 +3759,12 @@ 7 ] ], - "begin_time": 1547.194565870342, - "end_time": 1547.554565870342 + "begin_time": 2212.1945658703416, + "end_time": 2212.554565870342 }, { "type": "rearrangeJob", - "id": 24, + "id": 59, "aod_id": 0, "aod_qubits": [ 0, @@ -3673,8 +3870,8 @@ ] ], "id": 0, - "begin_time": 1547.554565870342, - "end_time": 1562.554565870342 + "begin_time": 2212.554565870342, + "end_time": 2227.554565870342 }, { "type": "move:big", @@ -3803,8 +4000,8 @@ ] ], "id": 1, - "begin_time": 1562.554565870342, - "end_time": 1628.6123917779237 + "begin_time": 2227.554565870342, + "end_time": 2293.612391777923 }, { "type": "deactivate", @@ -3818,16 +4015,16 @@ 0 ], "id": 2, - "begin_time": 1628.6123917779237, - "end_time": 1643.6123917779237 + "begin_time": 2293.612391777923, + "end_time": 2308.612391777923 } ], - "begin_time": 1547.554565870342, - "end_time": 1643.6123917779237 + "begin_time": 2212.554565870342, + "end_time": 2308.612391777923 }, { "type": "rydberg", - "id": 25, + "id": 60, "zone_id": 0, "gates": [ [ @@ -3847,12 +4044,12 @@ 11 ] ], - "begin_time": 1643.6123917779237, - "end_time": 1643.9723917779236 + "begin_time": 2308.612391777923, + "end_time": 2308.9723917779233 }, { "type": "rearrangeJob", - "id": 26, + "id": 61, "aod_id": 0, "aod_qubits": [ 0, @@ -3958,8 +4155,8 @@ ] ], "id": 0, - "begin_time": 1643.9723917779236, - "end_time": 1658.9723917779236 + "begin_time": 2308.9723917779233, + "end_time": 2323.9723917779233 }, { "type": "move:big", @@ -4088,8 +4285,8 @@ ] ], "id": 1, - "begin_time": 1658.9723917779236, - "end_time": 1719.2746606934763 + "begin_time": 2323.9723917779233, + "end_time": 2384.274660693476 }, { "type": "deactivate", @@ -4103,8 +4300,8 @@ 0 ], "id": 2, - "begin_time": 1719.2746606934763, - "end_time": 1734.2746606934763 + "begin_time": 2384.274660693476, + "end_time": 2399.274660693476 }, { "type": "activate", @@ -4133,8 +4330,8 @@ ] ], "id": 3, - "begin_time": 1734.2746606934763, - "end_time": 1749.2746606934763 + "begin_time": 2399.274660693476, + "end_time": 2414.274660693476 }, { "type": "move:big", @@ -4230,8 +4427,8 @@ ] ], "id": 4, - "begin_time": 1749.2746606934763, - "end_time": 1869.8791985245819 + "begin_time": 2414.274660693476, + "end_time": 2534.8791985245816 }, { "type": "deactivate", @@ -4242,60 +4439,131 @@ 0 ], "id": 5, - "begin_time": 1869.8791985245819, - "end_time": 1884.8791985245819 + "begin_time": 2534.8791985245816, + "end_time": 2549.8791985245816 } ], - "begin_time": 1643.9723917779236, - "end_time": 1884.8791985245819 + "begin_time": 2308.9723917779233, + "end_time": 2549.8791985245816 }, { "type": "1qGate", "unitary": "ry", - "id": 27, + "angle": 0.1949874869297219, + "id": 62, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 2549.8791985245816, + "end_time": 2569.5041985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.7581300491063969, + "id": 63, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 2569.5041985245816, + "end_time": 2589.1291985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.002706911086739372, + "id": 64, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 2589.1291985245816, + "end_time": 2608.7541985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.038995806129997534, + "id": 65, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 2608.7541985245816, + "end_time": 2628.3791985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.7167427480769936, + "id": 66, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 2628.3791985245816, + "end_time": 2648.0041985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.31562377714199674, + "id": 67, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 2648.0041985245816, + "end_time": 2667.6291985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.41642045395398297, + "id": 68, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 2667.6291985245816, + "end_time": 2687.2541985245816 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.20944485379973599, + "id": 69, + "locs": [ [ 7, 1, @@ -4303,46 +4571,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 1884.8791985245819, - "end_time": 1908.8791985245819 + "begin_time": 2687.2541985245816, + "end_time": 2706.8791985245816 }, { "type": "rydberg", - "id": 28, + "id": 70, "zone_id": 0, "gates": [ [ @@ -4362,12 +4596,12 @@ 8 ] ], - "begin_time": 1908.8791985245819, - "end_time": 1909.2391985245818 + "begin_time": 2706.8791985245816, + "end_time": 2707.2391985245818 }, { "type": "rearrangeJob", - "id": 29, + "id": 71, "aod_id": 0, "aod_qubits": [ 0, @@ -4473,8 +4707,8 @@ ] ], "id": 0, - "begin_time": 1909.2391985245818, - "end_time": 1924.2391985245818 + "begin_time": 2707.2391985245818, + "end_time": 2722.2391985245818 }, { "type": "move:big", @@ -4603,8 +4837,8 @@ ] ], "id": 1, - "begin_time": 1924.2391985245818, - "end_time": 1990.2970244321634 + "begin_time": 2722.2391985245818, + "end_time": 2788.297024432163 }, { "type": "deactivate", @@ -4618,16 +4852,16 @@ 1 ], "id": 2, - "begin_time": 1990.2970244321634, - "end_time": 2005.2970244321634 + "begin_time": 2788.297024432163, + "end_time": 2803.297024432163 } ], - "begin_time": 1909.2391985245818, - "end_time": 2005.2970244321634 + "begin_time": 2707.2391985245818, + "end_time": 2803.297024432163 }, { "type": "rydberg", - "id": 30, + "id": 72, "zone_id": 0, "gates": [ [ @@ -4647,12 +4881,12 @@ 4 ] ], - "begin_time": 2005.2970244321634, - "end_time": 2005.6570244321633 + "begin_time": 2803.297024432163, + "end_time": 2803.6570244321633 }, { "type": "rearrangeJob", - "id": 31, + "id": 73, "aod_id": 0, "aod_qubits": [ 0, @@ -4758,8 +4992,8 @@ ] ], "id": 0, - "begin_time": 2005.6570244321633, - "end_time": 2020.6570244321633 + "begin_time": 2803.6570244321633, + "end_time": 2818.6570244321633 }, { "type": "move:big", @@ -4888,8 +5122,8 @@ ] ], "id": 1, - "begin_time": 2020.6570244321633, - "end_time": 2080.959293347716 + "begin_time": 2818.6570244321633, + "end_time": 2878.959293347716 }, { "type": "deactivate", @@ -4903,8 +5137,8 @@ 1 ], "id": 2, - "begin_time": 2080.959293347716, - "end_time": 2095.959293347716 + "begin_time": 2878.959293347716, + "end_time": 2893.959293347716 }, { "type": "activate", @@ -4933,8 +5167,8 @@ ] ], "id": 3, - "begin_time": 2095.959293347716, - "end_time": 2110.959293347716 + "begin_time": 2893.959293347716, + "end_time": 2908.959293347716 }, { "type": "move:big", @@ -5030,8 +5264,8 @@ ] ], "id": 4, - "begin_time": 2110.959293347716, - "end_time": 2231.5638311788216 + "begin_time": 2908.959293347716, + "end_time": 3029.5638311788216 }, { "type": "deactivate", @@ -5042,60 +5276,131 @@ 0 ], "id": 5, - "begin_time": 2231.5638311788216, - "end_time": 2246.5638311788216 + "begin_time": 3029.5638311788216, + "end_time": 3044.5638311788216 } ], - "begin_time": 2005.6570244321633, - "end_time": 2246.5638311788216 + "begin_time": 2803.6570244321633, + "end_time": 3044.5638311788216 }, { "type": "1qGate", "unitary": "ry", - "id": 32, + "angle": 0.6683967136466561, + "id": 74, "locs": [ [ 0, 1, 0, 2 - ], + ] + ], + "begin_time": 3044.5638311788216, + "end_time": 3064.1888311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.9944881360948566, + "id": 75, + "locs": [ [ 1, 1, 0, 3 - ], + ] + ], + "begin_time": 3064.1888311788216, + "end_time": 3083.8138311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.3826396033010553, + "id": 76, + "locs": [ [ 2, 1, 0, 4 - ], + ] + ], + "begin_time": 3083.8138311788216, + "end_time": 3103.4388311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.0694954489371632, + "id": 77, + "locs": [ [ 3, 1, 0, 5 - ], + ] + ], + "begin_time": 3103.4388311788216, + "end_time": 3123.0638311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.8386078052085775, + "id": 78, + "locs": [ [ 4, 1, 1, 2 - ], + ] + ], + "begin_time": 3123.0638311788216, + "end_time": 3142.6888311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6390444668921844, + "id": 79, + "locs": [ [ 5, 1, 1, 3 - ], + ] + ], + "begin_time": 3142.6888311788216, + "end_time": 3162.3138311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.11841039617711824, + "id": 80, + "locs": [ [ 6, 1, 1, 4 - ], + ] + ], + "begin_time": 3162.3138311788216, + "end_time": 3181.9388311788216 + }, + { + "type": "1qGate", + "unitary": "ry", + "angle": 0.6181232766931545, + "id": 81, + "locs": [ [ 7, 1, @@ -5103,46 +5408,12 @@ 5 ] ], - "gates": [ - { - "name": "ry", - "q": 4 - }, - { - "name": "ry", - "q": 5 - }, - { - "name": "ry", - "q": 6 - }, - { - "name": "ry", - "q": 7 - }, - { - "name": "ry", - "q": 8 - }, - { - "name": "ry", - "q": 9 - }, - { - "name": "ry", - "q": 10 - }, - { - "name": "ry", - "q": 11 - } - ], - "begin_time": 2246.5638311788216, - "end_time": 2270.5638311788216 + "begin_time": 3181.9388311788216, + "end_time": 3201.5638311788216 }, { "type": "rydberg", - "id": 33, + "id": 82, "zone_id": 0, "gates": [ [ @@ -5162,9 +5433,9 @@ 7 ] ], - "begin_time": 2270.5638311788216, - "end_time": 2270.9238311788217 + "begin_time": 3201.5638311788216, + "end_time": 3201.9238311788217 } ], - "runtime": 2270.9238311788217 + "runtime": 3201.9238311788217 } \ No newline at end of file diff --git a/scratch/qcrank.py b/scratch/qcrank.py index bf20db13..4c5ea7e9 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -26,90 +26,64 @@ def run_qcrank(filename: str): entanglement_zone_spec = architecture_spec["entanglement_zones"][0] slms = entanglement_zone_spec["slms"] assert len(slms) == 2 - slm0 = slms[0] - slm1 = slms[1] - assert slm0["r"] == slm1["r"] - assert slm0["c"] == slm1["c"] - assert slm0["site_seperation"] == slm1["site_seperation"] - put_vertical = True - if slm0["location"][1] == slm1["location"][1]: - put_vertical = False - if put_vertical: - dis_trap = abs(slm0["location"][1] - slm1["location"][1]) - dis_site = slm0["site_seperation"][1] - dis_trap - x_spacing = [slm0["site_seperation"][0] * (slm0["r"] - 1)] - y_spacing = [] - for _ in range(slm0["c"]): - y_spacing.append(dis_trap) - y_spacing.append(dis_site) - else: - dis_trap = abs(slm0["location"][0] - slm1["location"][0]) - dis_site = slm0["site_seperation"][0] - dis_trap - y_spacing = [slm0["site_seperation"][1] * (slm0["r"] - 1)] - x_spacing = [] - for _ in range(slm0["c"]): - x_spacing.append(dis_trap) - x_spacing.append(dis_site) - x_spacing = x_spacing - - inst_init = compiled_qcrank["instructions"][0] - init_quibt_location = inst_init["init_locs"] - - shuttle_builder = ShuttleBuilder( - num_qubits=len(init_quibt_location), move_kernel=rearrange + slm1 = slms[0] + slm2 = slms[1] + assert slm1["r"] == slm2["r"] + assert slm1["c"] == slm2["c"] + assert slm1["site_seperation"] == slm2["site_seperation"] + assert slm1["location"][0] == slm2["location"][0] + dis_trap = abs(slm1["location"][1] - slm1["location"][1]) + dis_site = slm1["site_seperation"][1] - dis_trap + x_spacing = [slm1["site_seperation"][0] * (slm1["r"] - 1)] + y_spacing = [] + for _ in range(slm1["c"]): + y_spacing.append(dis_trap) + y_spacing.append(dis_site) + + slm0 = grid.Grid( + x_spacing=tuple(x_spacing), + y_spacing=tuple(y_spacing), + x_init=slm1["location"][0], + y_init=slm1["location"][1], ) - shuttle_builder.construct_grid( - entanglement_zone_spec["zone_id"], - entanglement_zone_spec["offset"], - x_spacing, - y_spacing, - entanglement_zone_spec["dimension"], + + slm1 = grid.Grid( + x_spacing=tuple(x_spacing), + y_spacing=tuple(y_spacing), + x_init=slm1["location"][0], + y_init=slm1["location"][1], + ) + + x_spacing = [slm2["site_seperation"][0]] * (slm2["c"] - 1) + y_spacing = [slm2["site_seperation"][1]] * (slm2["r"] - 1) + slm2 = grid.Grid( + x_spacing=tuple(x_spacing), + y_spacing=tuple(y_spacing), + x_init=slm2["location"][0], + y_init=slm2["location"][1], ) spec_value = spec.ArchSpec( layout=spec.Layout( static_traps={ - "mem": shuttle_builder.spec_mapping, + "slm0": slm0, + "slm1": slm1, + "slm2": slm2, }, - fillable=set(["mem"]), + fillable=set(["slm1", "slm2"]), ) ) - grid_init_quibt_location = [] - for loc in init_quibt_location: - x = loc[2] - y = loc[3] - if put_vertical: - y *= 2 - else: - x *= 2 - grid_init_quibt_location.append((x, y)) - - def main(): - # init.fill([spec.get_static_trap(zone_id="mem")]) - init.fill(shuttle_builder.spec_mapping) # ! - insts = compiled_qcrank["instructions"][1:] - for inst in insts: - if inst["type"] == "1qGate": - if inst["unitary"] == "ry": - for loc in inst["locs"]: - rotation_angle = np.random.random() - if loc[1] == 1: - locs = [(loc[0], 2 * loc[2], loc[3])] - else: - locs = [(loc[0], loc[2], loc[3])] - shuttle_builder.lower_r_gate(0, rotation_angle, locs) - elif inst["unitary"] == "h": - shuttle_builder.lower_h(inst["locs"]) - - elif inst["type"] == "rydberg": - shuttle_builder.entangle(inst["zone_id"]) - elif inst["type"] == "rearrangeJob": - shuttle_builder.insert_move(inst["begin_locs"], inst["end_locs"]) - return measure.measure((shuttle_builder.spec_mapping,)) - - return main, spec_value + spec_mapping = {0: "slms", 1: "slm1", 2: "slm2"} + num_qubits = len(compiled_qcrank["instructions"][0]["init_locs"]) + shuttle_builder = ShuttleBuilder( + spec_mapping=spec_mapping, + move_kernel=rearrange, + num_qubits=num_qubits + ) + shuttle_builder.lower(compiled_qcrank) if __name__ == "__main__": filename = "scratch/qcr_4a8d_quera_circ_code.json" + run_qcrank(filename) From d886d302003aa83b95f895009816c0ee3738ce1b Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Mon, 25 Aug 2025 18:15:25 -0700 Subject: [PATCH 08/16] fix bug in arch construction and update zair --- scratch/qcr_4a8d_quera_circ_code.json | 538 +++++++++++++++++--------- scratch/qcrank.py | 16 +- 2 files changed, 366 insertions(+), 188 deletions(-) diff --git a/scratch/qcr_4a8d_quera_circ_code.json b/scratch/qcr_4a8d_quera_circ_code.json index 45e32761..b7176504 100644 --- a/scratch/qcr_4a8d_quera_circ_code.json +++ b/scratch/qcr_4a8d_quera_circ_code.json @@ -228,7 +228,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9728764459611823, + "angle": 0.44482036261982016, "id": 2, "locs": [ [ @@ -244,7 +244,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.41775814709829173, + "angle": 0.6243114745412531, "id": 3, "locs": [ [ @@ -260,7 +260,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6663321264692436, + "angle": 0.48851645943035393, "id": 4, "locs": [ [ @@ -276,7 +276,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.32351121554355267, + "angle": 0.7075977375401195, "id": 5, "locs": [ [ @@ -292,7 +292,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6733003535129568, + "angle": 0.1264210841830885, "id": 6, "locs": [ [ @@ -308,7 +308,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.30206885247214277, + "angle": 0.21193045723521453, "id": 7, "locs": [ [ @@ -324,7 +324,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.7210451785067075, + "angle": 0.09935359277523925, "id": 8, "locs": [ [ @@ -340,7 +340,7 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.04661000097449375, + "angle": 0.6317419308676328, "id": 9, "locs": [ [ @@ -716,7 +716,7 @@ 2, 2, 1, - 2 + 6 ], [ 3, @@ -770,7 +770,6 @@ 2 ] ], - "id": 0, "begin_time": 280.2778259075817, "end_time": 295.2778259075817 }, @@ -900,7 +899,6 @@ } ] ], - "id": 1, "begin_time": 295.2778259075817, "end_time": 355.5800948231344 }, @@ -915,10 +913,37 @@ 3, 0 ], - "id": 2, "begin_time": 355.5800948231344, "end_time": 370.5800948231344 - }, + } + ], + "begin_time": 280.2778259075817, + "end_time": 370.5800948231344 + }, + { + "type": "rearrangeJob", + "id": 14, + "aod_id": 0, + "aod_qubits": [ + 2 + ], + "begin_locs": [ + [ + 2, + 2, + 1, + 6 + ] + ], + "end_locs": [ + [ + 2, + 2, + 1, + 2 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -945,7 +970,7 @@ 6 ] ], - "id": 3, + "id": 0, "begin_time": 370.5800948231344, "end_time": 385.5800948231344 }, @@ -1042,7 +1067,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 385.5800948231344, "end_time": 506.18463265423986 }, @@ -1054,19 +1079,19 @@ "col_id": [ 0 ], - "id": 5, + "id": 2, "begin_time": 506.18463265423986, "end_time": 521.1846326542399 } ], - "begin_time": 280.2778259075817, + "begin_time": 370.5800948231344, "end_time": 521.1846326542399 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.6813611442387034, - "id": 14, + "angle": 0.8554446921353213, + "id": 15, "locs": [ [ 0, @@ -1081,8 +1106,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.2836120193512349, - "id": 15, + "angle": 0.9629412504473308, + "id": 16, "locs": [ [ 1, @@ -1097,8 +1122,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.254616115097106, - "id": 16, + "angle": 0.3183283424742377, + "id": 17, "locs": [ [ 2, @@ -1113,8 +1138,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6421215212295661, - "id": 17, + "angle": 0.3570684717669246, + "id": 18, "locs": [ [ 3, @@ -1129,8 +1154,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.5143008696304473, - "id": 18, + "angle": 0.5708857494908607, + "id": 19, "locs": [ [ 4, @@ -1145,8 +1170,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6180087541303749, - "id": 19, + "angle": 0.039890072710002555, + "id": 20, "locs": [ [ 5, @@ -1161,8 +1186,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.8354001838563577, - "id": 20, + "angle": 0.2687504476209268, + "id": 21, "locs": [ [ 6, @@ -1177,8 +1202,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.3124219392856846, - "id": 21, + "angle": 0.9850699851801968, + "id": 22, "locs": [ [ 7, @@ -1192,7 +1217,7 @@ }, { "type": "rydberg", - "id": 22, + "id": 23, "zone_id": 0, "gates": [ [ @@ -1217,7 +1242,7 @@ }, { "type": "rearrangeJob", - "id": 23, + "id": 24, "aod_id": 0, "aod_qubits": [ 0, @@ -1477,7 +1502,7 @@ }, { "type": "rydberg", - "id": 24, + "id": 25, "zone_id": 0, "gates": [ [ @@ -1502,7 +1527,7 @@ }, { "type": "rearrangeJob", - "id": 25, + "id": 26, "aod_id": 0, "aod_qubits": [ 0, @@ -1553,7 +1578,7 @@ 2, 2, 0, - 5 + 1 ], [ 3, @@ -1607,7 +1632,6 @@ 3 ] ], - "id": 0, "begin_time": 774.9624585618216, "end_time": 789.9624585618216 }, @@ -1737,7 +1761,6 @@ } ] ], - "id": 1, "begin_time": 789.9624585618216, "end_time": 850.2647274773743 }, @@ -1752,10 +1775,37 @@ 0, 1 ], - "id": 2, "begin_time": 850.2647274773743, "end_time": 865.2647274773743 - }, + } + ], + "begin_time": 774.9624585618216, + "end_time": 865.2647274773743 + }, + { + "type": "rearrangeJob", + "id": 27, + "aod_id": 0, + "aod_qubits": [ + 2 + ], + "begin_locs": [ + [ + 2, + 2, + 0, + 1 + ] + ], + "end_locs": [ + [ + 2, + 2, + 0, + 5 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -1782,7 +1832,7 @@ 1 ] ], - "id": 3, + "id": 0, "begin_time": 865.2647274773743, "end_time": 880.2647274773743 }, @@ -1879,7 +1929,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 880.2647274773743, "end_time": 1000.8692653084797 }, @@ -1891,19 +1941,19 @@ "col_id": [ 0 ], - "id": 5, + "id": 2, "begin_time": 1000.8692653084797, "end_time": 1015.8692653084797 } ], - "begin_time": 774.9624585618216, + "begin_time": 865.2647274773743, "end_time": 1015.8692653084797 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.196172489039663, - "id": 26, + "angle": 0.20486859973509242, + "id": 28, "locs": [ [ 0, @@ -1918,8 +1968,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9328341463113734, - "id": 27, + "angle": 0.864858860380752, + "id": 29, "locs": [ [ 1, @@ -1934,8 +1984,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9176827880106695, - "id": 28, + "angle": 0.11418393870717058, + "id": 30, "locs": [ [ 2, @@ -1950,8 +2000,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.024278565236902305, - "id": 29, + "angle": 0.23093895165734868, + "id": 31, "locs": [ [ 3, @@ -1966,8 +2016,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.2511971251592853, - "id": 30, + "angle": 0.13047349548716525, + "id": 32, "locs": [ [ 4, @@ -1982,8 +2032,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.5747693418047549, - "id": 31, + "angle": 0.2594701401226652, + "id": 33, "locs": [ [ 5, @@ -1998,8 +2048,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.565733876498433, - "id": 32, + "angle": 0.8123550180563659, + "id": 34, "locs": [ [ 6, @@ -2014,8 +2064,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9746566547127251, - "id": 33, + "angle": 0.769097981013622, + "id": 35, "locs": [ [ 7, @@ -2029,7 +2079,7 @@ }, { "type": "rydberg", - "id": 34, + "id": 36, "zone_id": 0, "gates": [ [ @@ -2054,7 +2104,7 @@ }, { "type": "rearrangeJob", - "id": 35, + "id": 37, "aod_id": 0, "aod_qubits": [ 0, @@ -2314,7 +2364,7 @@ }, { "type": "rydberg", - "id": 36, + "id": 38, "zone_id": 0, "gates": [ [ @@ -2339,7 +2389,7 @@ }, { "type": "rearrangeJob", - "id": 37, + "id": 39, "aod_id": 0, "aod_qubits": [ 0, @@ -2384,13 +2434,13 @@ 1, 2, 1, - 2 + 6 ], [ 2, 2, 1, - 3 + 7 ], [ 3, @@ -2444,7 +2494,6 @@ 2 ] ], - "id": 0, "begin_time": 1269.6470912160612, "end_time": 1284.6470912160612 }, @@ -2574,7 +2623,6 @@ } ] ], - "id": 1, "begin_time": 1284.6470912160612, "end_time": 1369.9273777583053 }, @@ -2589,10 +2637,50 @@ 3, 0 ], - "id": 2, "begin_time": 1369.9273777583053, "end_time": 1384.9273777583053 - }, + } + ], + "begin_time": 1269.6470912160612, + "end_time": 1384.9273777583053 + }, + { + "type": "rearrangeJob", + "id": 40, + "aod_id": 0, + "aod_qubits": [ + 1, + 2 + ], + "begin_locs": [ + [ + 1, + 2, + 1, + 6 + ], + [ + 2, + 2, + 1, + 7 + ] + ], + "end_locs": [ + [ + 1, + 2, + 1, + 2 + ], + [ + 2, + 2, + 1, + 3 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -2625,7 +2713,7 @@ 7 ] ], - "id": 3, + "id": 0, "begin_time": 1384.9273777583053, "end_time": 1399.9273777583053 }, @@ -2733,7 +2821,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 1399.9273777583053, "end_time": 1520.5319155894108 }, @@ -2746,19 +2834,19 @@ 0, 1 ], - "id": 5, + "id": 2, "begin_time": 1520.5319155894108, "end_time": 1535.5319155894108 } ], - "begin_time": 1269.6470912160612, + "begin_time": 1384.9273777583053, "end_time": 1535.5319155894108 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.5897402376101286, - "id": 38, + "angle": 0.4497895402504003, + "id": 41, "locs": [ [ 0, @@ -2773,8 +2861,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6289974169797188, - "id": 39, + "angle": 0.9726899827641711, + "id": 42, "locs": [ [ 1, @@ -2789,8 +2877,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.7829845397950053, - "id": 40, + "angle": 0.7497893204477966, + "id": 43, "locs": [ [ 2, @@ -2805,8 +2893,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6337013520609717, - "id": 41, + "angle": 0.7733599572058976, + "id": 44, "locs": [ [ 3, @@ -2821,8 +2909,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.664199238607709, - "id": 42, + "angle": 0.9684007516841149, + "id": 45, "locs": [ [ 4, @@ -2837,8 +2925,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.8270404769093707, - "id": 43, + "angle": 0.7254772134505297, + "id": 46, "locs": [ [ 5, @@ -2853,8 +2941,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.06715931946317755, - "id": 44, + "angle": 0.7123155565685442, + "id": 47, "locs": [ [ 6, @@ -2869,8 +2957,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6185622712304147, - "id": 45, + "angle": 0.07830956110351617, + "id": 48, "locs": [ [ 7, @@ -2884,7 +2972,7 @@ }, { "type": "rydberg", - "id": 46, + "id": 49, "zone_id": 0, "gates": [ [ @@ -2909,7 +2997,7 @@ }, { "type": "rearrangeJob", - "id": 47, + "id": 50, "aod_id": 0, "aod_qubits": [ 0, @@ -3169,7 +3257,7 @@ }, { "type": "rydberg", - "id": 48, + "id": 51, "zone_id": 0, "gates": [ [ @@ -3194,7 +3282,7 @@ }, { "type": "rearrangeJob", - "id": 49, + "id": 52, "aod_id": 0, "aod_qubits": [ 0, @@ -3233,7 +3321,7 @@ 0, 2, 0, - 3 + 7 ], [ 1, @@ -3251,7 +3339,7 @@ 3, 2, 0, - 2 + 6 ] ], "insts": [ @@ -3299,7 +3387,6 @@ 4 ] ], - "id": 0, "begin_time": 1789.3097414969923, "end_time": 1804.3097414969923 }, @@ -3429,7 +3516,6 @@ } ] ], - "id": 1, "begin_time": 1804.3097414969923, "end_time": 1889.5900280392364 }, @@ -3444,10 +3530,50 @@ 1, 2 ], - "id": 2, "begin_time": 1889.5900280392364, "end_time": 1904.5900280392364 - }, + } + ], + "begin_time": 1789.3097414969923, + "end_time": 1904.5900280392364 + }, + { + "type": "rearrangeJob", + "id": 53, + "aod_id": 0, + "aod_qubits": [ + 0, + 3 + ], + "begin_locs": [ + [ + 0, + 2, + 0, + 7 + ], + [ + 3, + 2, + 0, + 6 + ] + ], + "end_locs": [ + [ + 0, + 2, + 0, + 3 + ], + [ + 3, + 2, + 0, + 2 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -3480,7 +3606,7 @@ 6 ] ], - "id": 3, + "id": 0, "begin_time": 1904.5900280392364, "end_time": 1919.5900280392364 }, @@ -3588,7 +3714,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 1919.5900280392364, "end_time": 2040.1945658703419 }, @@ -3601,19 +3727,19 @@ 1, 0 ], - "id": 5, + "id": 2, "begin_time": 2040.1945658703419, "end_time": 2055.1945658703416 } ], - "begin_time": 1789.3097414969923, + "begin_time": 1904.5900280392364, "end_time": 2055.1945658703416 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.2791144433467644, - "id": 50, + "angle": 0.17796426297818568, + "id": 54, "locs": [ [ 0, @@ -3628,8 +3754,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.33551635535479407, - "id": 51, + "angle": 0.9103625211859183, + "id": 55, "locs": [ [ 1, @@ -3644,8 +3770,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.8788439445641223, - "id": 52, + "angle": 0.7509979216074734, + "id": 56, "locs": [ [ 2, @@ -3660,8 +3786,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.09634919995667235, - "id": 53, + "angle": 0.8685286518346035, + "id": 57, "locs": [ [ 3, @@ -3676,8 +3802,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.993681707321558, - "id": 54, + "angle": 0.01435387873378624, + "id": 58, "locs": [ [ 4, @@ -3692,8 +3818,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.22442592143739715, - "id": 55, + "angle": 0.14855941671487083, + "id": 59, "locs": [ [ 5, @@ -3708,8 +3834,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9301353937113377, - "id": 56, + "angle": 0.6449625728520407, + "id": 60, "locs": [ [ 6, @@ -3724,8 +3850,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.16981932342710426, - "id": 57, + "angle": 0.5028408409056974, + "id": 61, "locs": [ [ 7, @@ -3739,7 +3865,7 @@ }, { "type": "rydberg", - "id": 58, + "id": 62, "zone_id": 0, "gates": [ [ @@ -3764,7 +3890,7 @@ }, { "type": "rearrangeJob", - "id": 59, + "id": 63, "aod_id": 0, "aod_qubits": [ 0, @@ -4024,7 +4150,7 @@ }, { "type": "rydberg", - "id": 60, + "id": 64, "zone_id": 0, "gates": [ [ @@ -4049,7 +4175,7 @@ }, { "type": "rearrangeJob", - "id": 61, + "id": 65, "aod_id": 0, "aod_qubits": [ 0, @@ -4100,7 +4226,7 @@ 2, 2, 1, - 2 + 6 ], [ 3, @@ -4154,7 +4280,6 @@ 2 ] ], - "id": 0, "begin_time": 2308.9723917779233, "end_time": 2323.9723917779233 }, @@ -4284,7 +4409,6 @@ } ] ], - "id": 1, "begin_time": 2323.9723917779233, "end_time": 2384.274660693476 }, @@ -4299,10 +4423,37 @@ 3, 0 ], - "id": 2, "begin_time": 2384.274660693476, "end_time": 2399.274660693476 - }, + } + ], + "begin_time": 2308.9723917779233, + "end_time": 2399.274660693476 + }, + { + "type": "rearrangeJob", + "id": 66, + "aod_id": 0, + "aod_qubits": [ + 2 + ], + "begin_locs": [ + [ + 2, + 2, + 1, + 6 + ] + ], + "end_locs": [ + [ + 2, + 2, + 1, + 2 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -4329,7 +4480,7 @@ 6 ] ], - "id": 3, + "id": 0, "begin_time": 2399.274660693476, "end_time": 2414.274660693476 }, @@ -4426,7 +4577,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 2414.274660693476, "end_time": 2534.8791985245816 }, @@ -4438,19 +4589,19 @@ "col_id": [ 0 ], - "id": 5, + "id": 2, "begin_time": 2534.8791985245816, "end_time": 2549.8791985245816 } ], - "begin_time": 2308.9723917779233, + "begin_time": 2399.274660693476, "end_time": 2549.8791985245816 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.1949874869297219, - "id": 62, + "angle": 0.19268032441473948, + "id": 67, "locs": [ [ 0, @@ -4465,8 +4616,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.7581300491063969, - "id": 63, + "angle": 0.6823970945461502, + "id": 68, "locs": [ [ 1, @@ -4481,8 +4632,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.002706911086739372, - "id": 64, + "angle": 0.34374268372529426, + "id": 69, "locs": [ [ 2, @@ -4497,8 +4648,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.038995806129997534, - "id": 65, + "angle": 0.9893082586958559, + "id": 70, "locs": [ [ 3, @@ -4513,8 +4664,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.7167427480769936, - "id": 66, + "angle": 0.6761686602967548, + "id": 71, "locs": [ [ 4, @@ -4529,8 +4680,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.31562377714199674, - "id": 67, + "angle": 0.27493447082336897, + "id": 72, "locs": [ [ 5, @@ -4545,8 +4696,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.41642045395398297, - "id": 68, + "angle": 0.2741776925997004, + "id": 73, "locs": [ [ 6, @@ -4561,8 +4712,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.20944485379973599, - "id": 69, + "angle": 0.5052805165190674, + "id": 74, "locs": [ [ 7, @@ -4576,7 +4727,7 @@ }, { "type": "rydberg", - "id": 70, + "id": 75, "zone_id": 0, "gates": [ [ @@ -4601,7 +4752,7 @@ }, { "type": "rearrangeJob", - "id": 71, + "id": 76, "aod_id": 0, "aod_qubits": [ 0, @@ -4861,7 +5012,7 @@ }, { "type": "rydberg", - "id": 72, + "id": 77, "zone_id": 0, "gates": [ [ @@ -4886,7 +5037,7 @@ }, { "type": "rearrangeJob", - "id": 73, + "id": 78, "aod_id": 0, "aod_qubits": [ 0, @@ -4937,7 +5088,7 @@ 2, 2, 0, - 5 + 1 ], [ 3, @@ -4991,7 +5142,6 @@ 3 ] ], - "id": 0, "begin_time": 2803.6570244321633, "end_time": 2818.6570244321633 }, @@ -5121,7 +5271,6 @@ } ] ], - "id": 1, "begin_time": 2818.6570244321633, "end_time": 2878.959293347716 }, @@ -5136,10 +5285,37 @@ 0, 1 ], - "id": 2, "begin_time": 2878.959293347716, "end_time": 2893.959293347716 - }, + } + ], + "begin_time": 2803.6570244321633, + "end_time": 2893.959293347716 + }, + { + "type": "rearrangeJob", + "id": 79, + "aod_id": 0, + "aod_qubits": [ + 2 + ], + "begin_locs": [ + [ + 2, + 2, + 0, + 1 + ] + ], + "end_locs": [ + [ + 2, + 2, + 0, + 5 + ] + ], + "insts": [ { "type": "activate", "row_id": [ @@ -5166,7 +5342,7 @@ 1 ] ], - "id": 3, + "id": 0, "begin_time": 2893.959293347716, "end_time": 2908.959293347716 }, @@ -5263,7 +5439,7 @@ } ] ], - "id": 4, + "id": 1, "begin_time": 2908.959293347716, "end_time": 3029.5638311788216 }, @@ -5275,19 +5451,19 @@ "col_id": [ 0 ], - "id": 5, + "id": 2, "begin_time": 3029.5638311788216, "end_time": 3044.5638311788216 } ], - "begin_time": 2803.6570244321633, + "begin_time": 2893.959293347716, "end_time": 3044.5638311788216 }, { "type": "1qGate", "unitary": "ry", - "angle": 0.6683967136466561, - "id": 74, + "angle": 0.06221884132610567, + "id": 80, "locs": [ [ 0, @@ -5302,8 +5478,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.9944881360948566, - "id": 75, + "angle": 0.47984909838638656, + "id": 81, "locs": [ [ 1, @@ -5318,8 +5494,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.3826396033010553, - "id": 76, + "angle": 0.28128919513734174, + "id": 82, "locs": [ [ 2, @@ -5334,8 +5510,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.0694954489371632, - "id": 77, + "angle": 0.046831045633477064, + "id": 83, "locs": [ [ 3, @@ -5350,8 +5526,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.8386078052085775, - "id": 78, + "angle": 0.6759701921298618, + "id": 84, "locs": [ [ 4, @@ -5366,8 +5542,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6390444668921844, - "id": 79, + "angle": 0.2675913446883964, + "id": 85, "locs": [ [ 5, @@ -5382,8 +5558,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.11841039617711824, - "id": 80, + "angle": 0.9797944935017265, + "id": 86, "locs": [ [ 6, @@ -5398,8 +5574,8 @@ { "type": "1qGate", "unitary": "ry", - "angle": 0.6181232766931545, - "id": 81, + "angle": 0.4511743159081828, + "id": 87, "locs": [ [ 7, @@ -5413,7 +5589,7 @@ }, { "type": "rydberg", - "id": 82, + "id": 88, "zone_id": 0, "gates": [ [ diff --git a/scratch/qcrank.py b/scratch/qcrank.py index 4c5ea7e9..1123fcab 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -32,11 +32,11 @@ def run_qcrank(filename: str): assert slm1["c"] == slm2["c"] assert slm1["site_seperation"] == slm2["site_seperation"] assert slm1["location"][0] == slm2["location"][0] - dis_trap = abs(slm1["location"][1] - slm1["location"][1]) + dis_trap = abs(slm1["location"][1] - slm2["location"][1]) dis_site = slm1["site_seperation"][1] - dis_trap - x_spacing = [slm1["site_seperation"][0] * (slm1["r"] - 1)] + x_spacing = [slm1["site_seperation"][0] * (slm1["c"] - 1)] y_spacing = [] - for _ in range(slm1["c"]): + for _ in range(slm1["r"]): y_spacing.append(dis_trap) y_spacing.append(dis_site) @@ -46,14 +46,15 @@ def run_qcrank(filename: str): x_init=slm1["location"][0], y_init=slm1["location"][1], ) - + + x_spacing = [slm1["site_seperation"][0]] * (slm1["c"] - 1) + y_spacing = [slm1["site_seperation"][1]] * (slm1["r"] - 1) slm1 = grid.Grid( x_spacing=tuple(x_spacing), y_spacing=tuple(y_spacing), x_init=slm1["location"][0], y_init=slm1["location"][1], ) - x_spacing = [slm2["site_seperation"][0]] * (slm2["c"] - 1) y_spacing = [slm2["site_seperation"][1]] * (slm2["r"] - 1) slm2 = grid.Grid( @@ -62,7 +63,6 @@ def run_qcrank(filename: str): x_init=slm2["location"][0], y_init=slm2["location"][1], ) - spec_value = spec.ArchSpec( layout=spec.Layout( static_traps={ @@ -73,6 +73,7 @@ def run_qcrank(filename: str): fillable=set(["slm1", "slm2"]), ) ) + # print(spec_value) spec_mapping = {0: "slms", 1: "slm1", 2: "slm2"} num_qubits = len(compiled_qcrank["instructions"][0]["init_locs"]) @@ -81,7 +82,8 @@ def run_qcrank(filename: str): move_kernel=rearrange, num_qubits=num_qubits ) - shuttle_builder.lower(compiled_qcrank) + method = shuttle_builder.lower(compiled_qcrank) + # print(method.print()) if __name__ == "__main__": From 4eb24e20e90268a76d44840c60001e2e51ad0796 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Wed, 24 Sep 2025 13:11:32 -0700 Subject: [PATCH 09/16] add rearrange_impl_horizontal_vertical --- .../shuttle/stdlib/layouts/two_col_zone.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index 3fdf12e0..8774478c 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -109,6 +109,66 @@ def parking_y_end(index: int): action.move(end) action.turn_off(action.ALL, action.ALL) +@tweezer +def rearrange_impl_horizontal_vertical( + src_x: ilist.IList[int, NumX], + src_y: ilist.IList[int, NumY], + dst_x: ilist.IList[int, NumX], + dst_y: ilist.IList[int, NumY], +): + assert len(src_x) == len( + dst_x + ), "Source and destination x indices must have the same length." + assert len(src_y) == len( + dst_y + ), "Source and destination y indices must have the same length." + + assert_sorted(src_x) + assert_sorted(src_y) + assert_sorted(dst_x) + assert_sorted(dst_y) + + zone = spec.get_static_trap(zone_id="traps") + + start = grid.sub_grid(zone, src_x, src_y) + end = grid.sub_grid(zone, dst_x, dst_y) + + # the direction for x displacement is decided based on the left (index % 2 == 0) or right site (index % 2 == 1) + def parking_x(index: int): + x_positions = grid.get_xpos(zone) + return x_positions[index] + 3.0 * (2 * (index % 2) - 1) + + def parking_y_end(index: int): + start_y = grid.get_ypos(start)[index] + end_y = grid.get_ypos(end)[index] + if start_y < end_y: + end_y = end_y - 3.0 + else: + end_y = end_y + 3.0 + + return end_y + + num_y = len(src_y) + + src_horizontal_parking = grid.from_positions( + ilist.map(parking_x, src_x), src_y + ) + parking_y = ilist.map(parking_y_end, ilist.range(num_y)) + mid_pos_after_vertical_move = grid.from_positions( + grid.get_xpos(src_horizontal_parking), parking_y + ) + mid_pos_after_horizontal_move = grid.from_positions( + dst_x, parking_y + ) + + action.set_loc(start) + action.turn_on(action.ALL, action.ALL) + action.move(src_horizontal_parking) + action.move(mid_pos_after_vertical_move) + action.move(mid_pos_after_horizontal_move) + action.move(end) + action.turn_off(action.ALL, action.ALL) + @move def rearrange( @@ -125,3 +185,19 @@ def rearrange( device_fn = schedule.device_fn(rearrange_impl, x_tones, y_tones) device_fn(src_x, src_y, dst_x, dst_y) + +@move +def rearrange_horizontal_vertical_move( + src_x: ilist.IList[int, NumX], + src_y: ilist.IList[int, NumY], + dst_x: ilist.IList[int, NumX], + dst_y: ilist.IList[int, NumY], +): + if len(src_x) < 1 or len(dst_x) < 1: + return + + x_tones = ilist.range(len(src_x)) + y_tones = ilist.range(len(src_y)) + + device_fn = schedule.device_fn(rearrange_impl_horizontal_vertical, x_tones, y_tones) + device_fn(src_x, src_y, dst_x, dst_y) \ No newline at end of file From e73a0e5898b2d6bd573b9e2b954d473cde73f098 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Mon, 29 Sep 2025 13:56:29 -0700 Subject: [PATCH 10/16] add hardware exp --- scratch/example_spec.py | 243 ++++++++++++++++++ .../qcrank_architecture_4_2_v.json | 0 .../hardware_example/small_architecture.json | 52 ++++ .../small_architecture_2Ryd.json | 74 ++++++ scratch/qcr_4a8d_quera_circ_code.json | 2 +- scratch/qcrank.py | 5 +- 6 files changed, 373 insertions(+), 3 deletions(-) create mode 100644 scratch/example_spec.py rename scratch/{ => hardware_example}/qcrank_architecture_4_2_v.json (100%) create mode 100644 scratch/hardware_example/small_architecture.json create mode 100644 scratch/hardware_example/small_architecture_2Ryd.json diff --git a/scratch/example_spec.py b/scratch/example_spec.py new file mode 100644 index 00000000..5e3dfd66 --- /dev/null +++ b/scratch/example_spec.py @@ -0,0 +1,243 @@ +from typing import Any +from bloqade.geometry.dialects import grid +from kirin.dialects import ilist + +# UCLA architecture spec + +# Approach 1: +# Each zone is described by a grid. Each slm array in the spec is a subgrid. +# Assume traps of an entanglement site are placed either horizontally or vertically +# Comments: UCLA spec is more expressive. Traps are can be placed diagonally. + +# Approach 2: +# Each slm is described by a grid. A zone consists of multiple grid. However, it is +# non-trivial to perfrom Rydberg gates (not on a single grid) + +# Approach 3: +# Each zone is described by a grid. Each slm array in the spec is a subgrid. To support +# may construct arbitrary shape, we construct additional sites that will not be used + +# Implementation follows approach 1 + + +# example architecture for scratch/hardware_example/qcrank_architecture_4_2_v.json +# 1 entanglement zone, no storage zone +def qcrank_architecture_4_2_v(): + # traps are placed vertically + # information is derived from the arch spec. Assume those info are consistent across + # all SLMs of the same zone. + x_offset, y_offset = 0, 5 + trap_spacing = 2 + x_spacing, y_spacing = 10, 12 + r, c = 2, 8 + x_positions = [x_offset + x_spacing * i for i in range(c)] + y_positions = sorted([ + y_offset + shift + y_spacing * i + for shift in (0, trap_spacing) + for i in range(r) + ]) + traps: grid.Grid[Any, Any] = grid.Grid.from_positions( + x_positions=x_positions, y_positions=y_positions + ) + + all_x: ilist.IList[int, Any] = ilist.IList(data=range(traps.shape[0])) + lower_col_idx: ilist.IList[int, Any] = ilist.IList(data=range(0, traps.shape[1], 2)) + upper_col_idx: ilist.IList[int, Any] = ilist.IList(data=range(1, traps.shape[1], 2)) + + lower_traps = traps.get_view(x_indices=all_x, y_indices=lower_col_idx) + upper_traps = traps.get_view(x_indices=all_x, y_indices=upper_col_idx) + + static_traps: dict[str, grid.Grid[Any, Any]] = { + "traps": traps, + "lower_traps": lower_traps, + "upper_traps": upper_traps, + } + + return static_traps + + +def generate_entanglement_zone_horizontal_traps( + offset: tuple[int, int], + trap_spacing: int, + site_spacing: tuple[int, int], + num_row: int, + num_column: int, +) -> grid.Grid[Any, Any]: + pass + x_offset, y_offset = offset + x_spacing, y_spacing = site_spacing + x_positions_entanglement = sorted([ + x_offset + shift + x_spacing * i + for shift in (0, trap_spacing) + for i in range(num_column) + ]) + y_positions_entanglement = [y_offset + y_spacing * i for i in range(num_row)] + + traps: grid.Grid[Any, Any] = grid.Grid.from_positions( + x_positions=x_positions_entanglement, y_positions=y_positions_entanglement + ) + return traps + + +# example architecture for scratch/hardware_example/small_architecture.json +# 1 entanglement zone, 1 storage zone +def small_architecture(): + # traps are placed horizontally + # entanglement zone + offset_entanglement = (3, 16) + site_spacing = (12, 10) + num_row, num_column = 6, 10 + + traps_entanglement = generate_entanglement_zone_horizontal_traps( + offset=offset_entanglement, + trap_spacing=2, + site_spacing=site_spacing, + num_row=num_row, + num_column=num_column, + ) + + left_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(0, traps_entanglement.shape[0], 2) + ) + right_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(1, traps_entanglement.shape[0], 2) + ) + all_y: ilist.IList[int, Any] = ilist.IList(data=range(traps_entanglement.shape[1])) + + left_traps = traps_entanglement.get_view(x_indices=left_col_idx, y_indices=all_y) + right_traps = traps_entanglement.get_view(x_indices=right_col_idx, y_indices=all_y) + + # storage zone + x_offset_storage, y_offset_storage = 0, 0 + x_spacing_storage, y_spacing_storage = 3, 3 + r_storage, c_storage = 3, 40 + + x_positions_storage = [ + x_offset_storage + x_spacing_storage * i for i in range(c_storage) + ] + y_positions_storage = [ + y_offset_storage + y_spacing_storage * i for i in range(r_storage) + ] + + traps_storage: grid.Grid[Any, Any] = grid.Grid.from_positions( + x_positions=x_positions_storage, y_positions=y_positions_storage + ) + + static_traps: dict[str, grid.Grid[Any, Any]] = { + "traps_entanglement": traps_entanglement, + "left_traps_entanglement": left_traps, + "right_traps_entanglement": right_traps, + "traps_storage": traps_storage, + } + + return static_traps + + +# example architecture for scratch/hardware_example/small_architecture_2Ryd.json +# 1 entanglement zone, 1 storage zone +def small_architecture_2Ryd(): + # traps are placed horizontally + # entanglement zone 0 + offset_entanglement = (3, 16) + site_spacing = (12, 10) + num_row, num_column = 6, 10 + + traps_entanglement_0 = generate_entanglement_zone_horizontal_traps( + offset=offset_entanglement, + trap_spacing=2, + site_spacing=site_spacing, + num_row=num_row, + num_column=num_column, + ) + + left_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(0, traps_entanglement_0.shape[0], 2) + ) + right_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(1, traps_entanglement_0.shape[0], 2) + ) + all_y: ilist.IList[int, Any] = ilist.IList( + data=range(traps_entanglement_0.shape[1]) + ) + + left_traps_0 = traps_entanglement_0.get_view( + x_indices=left_col_idx, y_indices=all_y + ) + right_traps_0 = traps_entanglement_0.get_view( + x_indices=right_col_idx, y_indices=all_y + ) + + # entanglement zone 1 + offset_entanglement = (3, -30) + site_spacing = (12, 10) + num_row, num_column = 6, 10 + + traps_entanglement_1 = generate_entanglement_zone_horizontal_traps( + offset=offset_entanglement, + trap_spacing=2, + site_spacing=site_spacing, + num_row=num_row, + num_column=num_column, + ) + + left_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(0, traps_entanglement_1.shape[0], 2) + ) + right_col_idx: ilist.IList[int, Any] = ilist.IList( + data=range(1, traps_entanglement_1.shape[0], 2) + ) + all_y: ilist.IList[int, Any] = ilist.IList( + data=range(traps_entanglement_1.shape[1]) + ) + + left_traps_1 = traps_entanglement_1.get_view( + x_indices=left_col_idx, y_indices=all_y + ) + right_traps_1 = traps_entanglement_1.get_view( + x_indices=right_col_idx, y_indices=all_y + ) + + # storage zone + x_offset_storage, y_offset_storage = 0, 0 + x_spacing_storage, y_spacing_storage = 3, 3 + r_storage, c_storage = 3, 40 + + x_positions_storage = [ + x_offset_storage + x_spacing_storage * i for i in range(c_storage) + ] + y_positions_storage = [ + y_offset_storage + y_spacing_storage * i for i in range(r_storage) + ] + + traps_storage: grid.Grid[Any, Any] = grid.Grid.from_positions( + x_positions=x_positions_storage, y_positions=y_positions_storage + ) + + static_traps: dict[str, grid.Grid[Any, Any]] = { + "traps_entanglement_0": traps_entanglement_0, + "left_traps_entanglement_0": left_traps_0, + "right_traps_entanglement_0": right_traps_0, + "traps_entanglement_1": traps_entanglement_1, + "left_traps_entanglement_1": left_traps_1, + "right_traps_entanglement_1": right_traps_1, + "traps_storage": traps_storage, + } + + return static_traps +print("Monolithic architecture: 8 col, 2 row, vertical traps") +arch = qcrank_architecture_4_2_v() +for key in arch: + print(key) + print(arch[key]) + +print("\nZoned architecture with one 6*10 entanglement zone and one 3*40 storage zone, horizontal traps") +arch = small_architecture() +for key in arch: + print(key) + print(arch[key]) + +print("\nZoned architecture with two 6*10 entanglement zones and one 3*40 storage zone, horizontal traps") +arch = small_architecture_2Ryd() +for key in arch: + print(key) + print(arch[key]) diff --git a/scratch/qcrank_architecture_4_2_v.json b/scratch/hardware_example/qcrank_architecture_4_2_v.json similarity index 100% rename from scratch/qcrank_architecture_4_2_v.json rename to scratch/hardware_example/qcrank_architecture_4_2_v.json diff --git a/scratch/hardware_example/small_architecture.json b/scratch/hardware_example/small_architecture.json new file mode 100644 index 00000000..ee04bd01 --- /dev/null +++ b/scratch/hardware_example/small_architecture.json @@ -0,0 +1,52 @@ +{ + "name": "small_compute_store_architecture", + "operation_duration": { + "rydberg": 0.36, + "1qGate": 52, + "atom_transfer": 15 + }, + "operation_fidelity": { + "two_qubit_gate": 0.995, + "single_qubit_gate": 0.9997, + "atom_transfer": 0.999 + }, + "qubit_spec":{ + "T": 1.5e6 + }, + "storage_zones": [{ + "zone_id": 0, + "slms": [{ + "id": 0, + "site_seperation": [3, 3], + "r": 3, + "c": 40, + "location": [0, 0]}], + "offset": [0, 0], + "dimenstion": [120, 9] + }], + "entanglement_zones": [{ + "zone_id": 0, + "slms": [ + { + "id": 1, + "site_seperation": [12, 10], + "r": 6, + "c": 10, + "location": [3, 16] + }, + { + "id": 2, + "site_seperation": [12, 10], + "r": 6, + "c": 10, + "location": [5, 16] + }], + "offset": [3, 16], + "dimension": [110, 50] + }], + "aods":[ + {"id": 0, "site_seperation": 2, "r": 4, "c": 40} + ], + "arch_range": [[0, 0], [120, 66]], + "rydberg_range": [[[3, 16], [113, 66]]] +} diff --git a/scratch/hardware_example/small_architecture_2Ryd.json b/scratch/hardware_example/small_architecture_2Ryd.json new file mode 100644 index 00000000..36720145 --- /dev/null +++ b/scratch/hardware_example/small_architecture_2Ryd.json @@ -0,0 +1,74 @@ +{ + "name": "small_compute_store_architecture", + "operation_duration": { + "rydberg": 0.36, + "1qGate": 52, + "atom_transfer": 15 + }, + "operation_fidelity": { + "two_qubit_gate": 0.995, + "single_qubit_gate": 0.9997, + "atom_transfer": 0.999 + }, + "qubit_spec":{ + "T": 1.5e6 + }, + "storage_zones": [{ + "zone_id": 0, + "slms": [{ + "id": 0, + "site_seperation": [3, 3], + "r": 3, + "c": 40, + "location": [0, 0]}], + "offset": [0, 0], + "dimenstion": [120, 9] + }], + "entanglement_zones": [{ + "zone_id": 0, + "slms": [ + { + "id": 1, + "site_seperation": [12, 10], + "r": 3, + "c": 10, + "location": [3, 16] + }, + { + "id": 2, + "site_seperation": [12, 10], + "r": 3, + "c": 10, + "location": [5, 16] + } + ], + "offset": [3, 16], + "dimension": [122, 30] + }, + { + "zone_id": 1, + "slms": [ + { + "id": 3, + "site_seperation": [12, 10], + "r": 3, + "c": 10, + "location": [3, -30] + }, + { + "id": 4, + "site_seperation": [12, 10], + "r": 3, + "c": 10, + "location": [5, -30] + } + ], + "offset": [3, -30], + "dimension": [122, 30] + }], + "aods":[ + {"id": 0, "site_seperation": 2, "r": 4, "c": 40} + ], + "arch_range": [[3, -36], [120, 36]], + "rydberg_range": [[[3, 16], [113, 36]], [[3, -30], [113, 0]]] +} diff --git a/scratch/qcr_4a8d_quera_circ_code.json b/scratch/qcr_4a8d_quera_circ_code.json index b7176504..30c245d4 100644 --- a/scratch/qcr_4a8d_quera_circ_code.json +++ b/scratch/qcr_4a8d_quera_circ_code.json @@ -1,6 +1,6 @@ { "name": "qcr_4a8d_quera_circ", - "architecture_spec_path": "scratch/qcrank_architecture_4_2_v.json", + "architecture_spec_path": "scratch/hardware_example/qcrank_architecture_4_2_v.json", "instructions": [ { "type": "init", diff --git a/scratch/qcrank.py b/scratch/qcrank.py index 1123fcab..7a8b3e48 100644 --- a/scratch/qcrank.py +++ b/scratch/qcrank.py @@ -8,7 +8,7 @@ from bloqade.shuttle import action, gate, init, measure, schedule, spec from bloqade.shuttle.prelude import move, tweezer -from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange +from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange, rearrange_horizontal_vertical_move from bloqade.shuttle.visualizer import MatplotlibRenderer, PathVisualizer @@ -80,10 +80,11 @@ def run_qcrank(filename: str): shuttle_builder = ShuttleBuilder( spec_mapping=spec_mapping, move_kernel=rearrange, + # move_kernel=rearrange_horizontal_vertical_move, num_qubits=num_qubits ) method = shuttle_builder.lower(compiled_qcrank) - # print(method.print()) + method.print() if __name__ == "__main__": From e1e403b65deec6ca19e19b593017dd8afe381792 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Tue, 30 Sep 2025 12:25:03 -0700 Subject: [PATCH 11/16] fix type --- src/bloqade/shuttle/stdlib/layouts/two_col_zone.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index 03b937da..247fe846 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -111,6 +111,7 @@ def parking_y_end(index: int): action.move(end) action.turn_off(action.ALL, action.ALL) + @tweezer def rearrange_impl_horizontal_vertical( src_x: ilist.IList[int, NumX], @@ -153,14 +154,14 @@ def parking_y_end(index: int): num_y = len(src_y) src_horizontal_parking = grid.from_positions( - ilist.map(parking_x, src_x), src_y + ilist.map(parking_x, src_x), ilist.map(float, src_y) ) parking_y = ilist.map(parking_y_end, ilist.range(num_y)) mid_pos_after_vertical_move = grid.from_positions( grid.get_xpos(src_horizontal_parking), parking_y ) mid_pos_after_horizontal_move = grid.from_positions( - dst_x, parking_y + ilist.map(float, dst_x), ilist.map(float, parking_y) ) action.set_loc(start) @@ -188,6 +189,7 @@ def rearrange( device_fn = schedule.device_fn(rearrange_impl, x_tones, y_tones) device_fn(src_x, src_y, dst_x, dst_y) + @move def rearrange_horizontal_vertical_move( src_x: ilist.IList[int, NumX], @@ -202,4 +204,4 @@ def rearrange_horizontal_vertical_move( y_tones = ilist.range(len(src_y)) device_fn = schedule.device_fn(rearrange_impl_horizontal_vertical, x_tones, y_tones) - device_fn(src_x, src_y, dst_x, dst_y) \ No newline at end of file + device_fn(src_x, src_y, dst_x, dst_y) From a21bdca40cca641ba1efaf21e684960bddb13166 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Thu, 2 Oct 2025 15:59:39 -0700 Subject: [PATCH 12/16] fix format --- .gitignore | 1 + scratch/example_spec.py | 243 - .../qcrank_architecture_4_2_v.json | 42 - .../hardware_example/small_architecture.json | 52 - .../small_architecture_2Ryd.json | 74 - scratch/lower_zair.py | 192 - scratch/qcr_4a8d_quera_circ_code.json | 5617 ----------------- scratch/qcrank.py | 92 - .../shuttle/stdlib/layouts/two_col_zone.py | 27 +- uv.lock | 8 +- 10 files changed, 10 insertions(+), 6338 deletions(-) delete mode 100644 scratch/example_spec.py delete mode 100644 scratch/hardware_example/qcrank_architecture_4_2_v.json delete mode 100644 scratch/hardware_example/small_architecture.json delete mode 100644 scratch/hardware_example/small_architecture_2Ryd.json delete mode 100644 scratch/lower_zair.py delete mode 100644 scratch/qcr_4a8d_quera_circ_code.json delete mode 100644 scratch/qcrank.py diff --git a/.gitignore b/.gitignore index ecf3b156..1b49276f 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,4 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +scratch/ diff --git a/scratch/example_spec.py b/scratch/example_spec.py deleted file mode 100644 index 5e3dfd66..00000000 --- a/scratch/example_spec.py +++ /dev/null @@ -1,243 +0,0 @@ -from typing import Any -from bloqade.geometry.dialects import grid -from kirin.dialects import ilist - -# UCLA architecture spec - -# Approach 1: -# Each zone is described by a grid. Each slm array in the spec is a subgrid. -# Assume traps of an entanglement site are placed either horizontally or vertically -# Comments: UCLA spec is more expressive. Traps are can be placed diagonally. - -# Approach 2: -# Each slm is described by a grid. A zone consists of multiple grid. However, it is -# non-trivial to perfrom Rydberg gates (not on a single grid) - -# Approach 3: -# Each zone is described by a grid. Each slm array in the spec is a subgrid. To support -# may construct arbitrary shape, we construct additional sites that will not be used - -# Implementation follows approach 1 - - -# example architecture for scratch/hardware_example/qcrank_architecture_4_2_v.json -# 1 entanglement zone, no storage zone -def qcrank_architecture_4_2_v(): - # traps are placed vertically - # information is derived from the arch spec. Assume those info are consistent across - # all SLMs of the same zone. - x_offset, y_offset = 0, 5 - trap_spacing = 2 - x_spacing, y_spacing = 10, 12 - r, c = 2, 8 - x_positions = [x_offset + x_spacing * i for i in range(c)] - y_positions = sorted([ - y_offset + shift + y_spacing * i - for shift in (0, trap_spacing) - for i in range(r) - ]) - traps: grid.Grid[Any, Any] = grid.Grid.from_positions( - x_positions=x_positions, y_positions=y_positions - ) - - all_x: ilist.IList[int, Any] = ilist.IList(data=range(traps.shape[0])) - lower_col_idx: ilist.IList[int, Any] = ilist.IList(data=range(0, traps.shape[1], 2)) - upper_col_idx: ilist.IList[int, Any] = ilist.IList(data=range(1, traps.shape[1], 2)) - - lower_traps = traps.get_view(x_indices=all_x, y_indices=lower_col_idx) - upper_traps = traps.get_view(x_indices=all_x, y_indices=upper_col_idx) - - static_traps: dict[str, grid.Grid[Any, Any]] = { - "traps": traps, - "lower_traps": lower_traps, - "upper_traps": upper_traps, - } - - return static_traps - - -def generate_entanglement_zone_horizontal_traps( - offset: tuple[int, int], - trap_spacing: int, - site_spacing: tuple[int, int], - num_row: int, - num_column: int, -) -> grid.Grid[Any, Any]: - pass - x_offset, y_offset = offset - x_spacing, y_spacing = site_spacing - x_positions_entanglement = sorted([ - x_offset + shift + x_spacing * i - for shift in (0, trap_spacing) - for i in range(num_column) - ]) - y_positions_entanglement = [y_offset + y_spacing * i for i in range(num_row)] - - traps: grid.Grid[Any, Any] = grid.Grid.from_positions( - x_positions=x_positions_entanglement, y_positions=y_positions_entanglement - ) - return traps - - -# example architecture for scratch/hardware_example/small_architecture.json -# 1 entanglement zone, 1 storage zone -def small_architecture(): - # traps are placed horizontally - # entanglement zone - offset_entanglement = (3, 16) - site_spacing = (12, 10) - num_row, num_column = 6, 10 - - traps_entanglement = generate_entanglement_zone_horizontal_traps( - offset=offset_entanglement, - trap_spacing=2, - site_spacing=site_spacing, - num_row=num_row, - num_column=num_column, - ) - - left_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(0, traps_entanglement.shape[0], 2) - ) - right_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(1, traps_entanglement.shape[0], 2) - ) - all_y: ilist.IList[int, Any] = ilist.IList(data=range(traps_entanglement.shape[1])) - - left_traps = traps_entanglement.get_view(x_indices=left_col_idx, y_indices=all_y) - right_traps = traps_entanglement.get_view(x_indices=right_col_idx, y_indices=all_y) - - # storage zone - x_offset_storage, y_offset_storage = 0, 0 - x_spacing_storage, y_spacing_storage = 3, 3 - r_storage, c_storage = 3, 40 - - x_positions_storage = [ - x_offset_storage + x_spacing_storage * i for i in range(c_storage) - ] - y_positions_storage = [ - y_offset_storage + y_spacing_storage * i for i in range(r_storage) - ] - - traps_storage: grid.Grid[Any, Any] = grid.Grid.from_positions( - x_positions=x_positions_storage, y_positions=y_positions_storage - ) - - static_traps: dict[str, grid.Grid[Any, Any]] = { - "traps_entanglement": traps_entanglement, - "left_traps_entanglement": left_traps, - "right_traps_entanglement": right_traps, - "traps_storage": traps_storage, - } - - return static_traps - - -# example architecture for scratch/hardware_example/small_architecture_2Ryd.json -# 1 entanglement zone, 1 storage zone -def small_architecture_2Ryd(): - # traps are placed horizontally - # entanglement zone 0 - offset_entanglement = (3, 16) - site_spacing = (12, 10) - num_row, num_column = 6, 10 - - traps_entanglement_0 = generate_entanglement_zone_horizontal_traps( - offset=offset_entanglement, - trap_spacing=2, - site_spacing=site_spacing, - num_row=num_row, - num_column=num_column, - ) - - left_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(0, traps_entanglement_0.shape[0], 2) - ) - right_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(1, traps_entanglement_0.shape[0], 2) - ) - all_y: ilist.IList[int, Any] = ilist.IList( - data=range(traps_entanglement_0.shape[1]) - ) - - left_traps_0 = traps_entanglement_0.get_view( - x_indices=left_col_idx, y_indices=all_y - ) - right_traps_0 = traps_entanglement_0.get_view( - x_indices=right_col_idx, y_indices=all_y - ) - - # entanglement zone 1 - offset_entanglement = (3, -30) - site_spacing = (12, 10) - num_row, num_column = 6, 10 - - traps_entanglement_1 = generate_entanglement_zone_horizontal_traps( - offset=offset_entanglement, - trap_spacing=2, - site_spacing=site_spacing, - num_row=num_row, - num_column=num_column, - ) - - left_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(0, traps_entanglement_1.shape[0], 2) - ) - right_col_idx: ilist.IList[int, Any] = ilist.IList( - data=range(1, traps_entanglement_1.shape[0], 2) - ) - all_y: ilist.IList[int, Any] = ilist.IList( - data=range(traps_entanglement_1.shape[1]) - ) - - left_traps_1 = traps_entanglement_1.get_view( - x_indices=left_col_idx, y_indices=all_y - ) - right_traps_1 = traps_entanglement_1.get_view( - x_indices=right_col_idx, y_indices=all_y - ) - - # storage zone - x_offset_storage, y_offset_storage = 0, 0 - x_spacing_storage, y_spacing_storage = 3, 3 - r_storage, c_storage = 3, 40 - - x_positions_storage = [ - x_offset_storage + x_spacing_storage * i for i in range(c_storage) - ] - y_positions_storage = [ - y_offset_storage + y_spacing_storage * i for i in range(r_storage) - ] - - traps_storage: grid.Grid[Any, Any] = grid.Grid.from_positions( - x_positions=x_positions_storage, y_positions=y_positions_storage - ) - - static_traps: dict[str, grid.Grid[Any, Any]] = { - "traps_entanglement_0": traps_entanglement_0, - "left_traps_entanglement_0": left_traps_0, - "right_traps_entanglement_0": right_traps_0, - "traps_entanglement_1": traps_entanglement_1, - "left_traps_entanglement_1": left_traps_1, - "right_traps_entanglement_1": right_traps_1, - "traps_storage": traps_storage, - } - - return static_traps -print("Monolithic architecture: 8 col, 2 row, vertical traps") -arch = qcrank_architecture_4_2_v() -for key in arch: - print(key) - print(arch[key]) - -print("\nZoned architecture with one 6*10 entanglement zone and one 3*40 storage zone, horizontal traps") -arch = small_architecture() -for key in arch: - print(key) - print(arch[key]) - -print("\nZoned architecture with two 6*10 entanglement zones and one 3*40 storage zone, horizontal traps") -arch = small_architecture_2Ryd() -for key in arch: - print(key) - print(arch[key]) diff --git a/scratch/hardware_example/qcrank_architecture_4_2_v.json b/scratch/hardware_example/qcrank_architecture_4_2_v.json deleted file mode 100644 index 7856393b..00000000 --- a/scratch/hardware_example/qcrank_architecture_4_2_v.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "qcrank_zoned_architecture", - "operation_duration": { - "rydberg": 0.36, - "raman": 11, - "atom_transfer": 15 - }, - "operation_fidelity": { - "two_qubit_gate": 0.995, - "single_qubit_gate": 0.9997, - "atom_transfer": 0.999 - }, - "qubit_spec":{ - "T": 1.5e6 - }, - "storage_zones": [{}], - "entanglement_zones": [{ - "zone_id": 0, - "slms": [ - { - "id": 1, - "site_seperation": [10, 12], - "r": 2, - "c": 8, - "location": [0, 5] - }, - { - "id": 2, - "site_seperation": [10, 12], - "r": 2, - "c": 8, - "location": [0, 7] - }], - "offset": [0, 5], - "dimension": [70, 3] - }], - "aods":[ - {"id": 0, "site_seperation": 2, "r": 3, "c": 8} - ], - "arch_range": [[0, 5], [70, 21]], - "rydberg_range": [[[0, 5], [70, 21]]] -} \ No newline at end of file diff --git a/scratch/hardware_example/small_architecture.json b/scratch/hardware_example/small_architecture.json deleted file mode 100644 index ee04bd01..00000000 --- a/scratch/hardware_example/small_architecture.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "small_compute_store_architecture", - "operation_duration": { - "rydberg": 0.36, - "1qGate": 52, - "atom_transfer": 15 - }, - "operation_fidelity": { - "two_qubit_gate": 0.995, - "single_qubit_gate": 0.9997, - "atom_transfer": 0.999 - }, - "qubit_spec":{ - "T": 1.5e6 - }, - "storage_zones": [{ - "zone_id": 0, - "slms": [{ - "id": 0, - "site_seperation": [3, 3], - "r": 3, - "c": 40, - "location": [0, 0]}], - "offset": [0, 0], - "dimenstion": [120, 9] - }], - "entanglement_zones": [{ - "zone_id": 0, - "slms": [ - { - "id": 1, - "site_seperation": [12, 10], - "r": 6, - "c": 10, - "location": [3, 16] - }, - { - "id": 2, - "site_seperation": [12, 10], - "r": 6, - "c": 10, - "location": [5, 16] - }], - "offset": [3, 16], - "dimension": [110, 50] - }], - "aods":[ - {"id": 0, "site_seperation": 2, "r": 4, "c": 40} - ], - "arch_range": [[0, 0], [120, 66]], - "rydberg_range": [[[3, 16], [113, 66]]] -} diff --git a/scratch/hardware_example/small_architecture_2Ryd.json b/scratch/hardware_example/small_architecture_2Ryd.json deleted file mode 100644 index 36720145..00000000 --- a/scratch/hardware_example/small_architecture_2Ryd.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "small_compute_store_architecture", - "operation_duration": { - "rydberg": 0.36, - "1qGate": 52, - "atom_transfer": 15 - }, - "operation_fidelity": { - "two_qubit_gate": 0.995, - "single_qubit_gate": 0.9997, - "atom_transfer": 0.999 - }, - "qubit_spec":{ - "T": 1.5e6 - }, - "storage_zones": [{ - "zone_id": 0, - "slms": [{ - "id": 0, - "site_seperation": [3, 3], - "r": 3, - "c": 40, - "location": [0, 0]}], - "offset": [0, 0], - "dimenstion": [120, 9] - }], - "entanglement_zones": [{ - "zone_id": 0, - "slms": [ - { - "id": 1, - "site_seperation": [12, 10], - "r": 3, - "c": 10, - "location": [3, 16] - }, - { - "id": 2, - "site_seperation": [12, 10], - "r": 3, - "c": 10, - "location": [5, 16] - } - ], - "offset": [3, 16], - "dimension": [122, 30] - }, - { - "zone_id": 1, - "slms": [ - { - "id": 3, - "site_seperation": [12, 10], - "r": 3, - "c": 10, - "location": [3, -30] - }, - { - "id": 4, - "site_seperation": [12, 10], - "r": 3, - "c": 10, - "location": [5, -30] - } - ], - "offset": [3, -30], - "dimension": [122, 30] - }], - "aods":[ - {"id": 0, "site_seperation": 2, "r": 4, "c": 40} - ], - "arch_range": [[3, -36], [120, 36]], - "rydberg_range": [[[3, 16], [113, 36]], [[3, -30], [113, 0]]] -} diff --git a/scratch/lower_zair.py b/scratch/lower_zair.py deleted file mode 100644 index 9fe1b45c..00000000 --- a/scratch/lower_zair.py +++ /dev/null @@ -1,192 +0,0 @@ -import json -import math -from dataclasses import dataclass, field -from typing import Any, Generic, Sequence, TypeVar - -from kirin import ir, types -from kirin.dialects import func, ilist, py -from kirin.dialects.ilist import IList - -from bloqade.shuttle.dialects import filled, gate, init, spec -from bloqade.shuttle.prelude import move - - -def _simple_region() -> ir.Region: - return ir.Region(ir.Block()) - - -@dataclass -class ShuttleBuilder: - - spec_mapping: dict[int, str] - move_kernel: ir.Method[ - [IList[int, Any], IList[int, Any], IList[int, Any], IList[int, Any]], None - ] - num_qubits: int - - body: ir.Region = field(default_factory=_simple_region, init=False) - - def push_stmt(self, stmt: ir.Statement): - self.body.blocks[0].stmts.append(stmt) - return stmt - - def push_constant(self, value: Any) -> ir.SSAValue: - const_stmt = py.Constant(value) - return self.push_stmt(const_stmt).expect_one_result() - - def get_zone(self, zone_id: int) -> ir.SSAValue: - return self.push_stmt( - spec.GetStaticTrap(zone_id=self.spec_mapping[zone_id]) - ).expect_one_result() - - def get_slm( - self, - slm_id: int, - ): - return self.push_stmt( - spec.GetStaticTrap(zone_id=self.spec_mapping[slm_id]) - ).expect_one_result() - - def lower_rearrange( - self, - begin_locs: Sequence[tuple[int, int, int, int]], - end_locs: Sequence[tuple[int, int, int, int]], - ): - # ignoring zone mapping, only include all unique x and y positions - x_src = IList(sorted(set(src[2] for src in begin_locs))) - y_src = IList(sorted(set(src[3] for src in begin_locs))) - x_dst = IList(sorted(set(dst[2] for dst in end_locs))) - y_dst = IList(sorted(set(dst[3] for dst in end_locs))) - - x_src_ref = self.push_constant(x_src) - y_src_ref = self.push_constant(y_src) - x_dst_ref = self.push_constant(x_dst) - y_dst_ref = self.push_constant(y_dst) - - self.push_stmt( - func.Invoke( - inputs=(x_src_ref, y_src_ref, x_dst_ref, y_dst_ref), - callee=self.move_kernel, - kwargs=(), - ) - ) - - def rydberg(self, zone_id: int): - self.push_stmt(gate.TopHatCZ(self.get_zone(zone_id))) - - def lower_ry_gate( - self, - rotation_angle: float, - locs: Sequence[tuple[int, int, int, int]], - ): - filled_locs: dict[int, list[tuple[int, int]]] = {} - - for _, grid_id, x, y in locs: - filled_locs.setdefault(grid_id, []).append((x, y)) - - filled_loc_refs: list[ir.SSAValue] = [] - - for grid_id, coords in filled_locs.items(): - locs_ref = self.push_constant(ilist.IList(coords)) - filled_loc_refs.append( - self.push_stmt( - filled.Fill(self.get_slm(grid_id), locs_ref) - ).expect_one_result() - ) - - axis_angle = self.push_constant(0.5) - rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) - - for filled_ref in filled_loc_refs: - self.push_stmt(gate.LocalR(axis_angle, rotation_angle_ref, filled_ref)) - - def lower_rz_gate( - self, rotation_angle: float, locations: Sequence[tuple[int, int, int, int]] - ): - filled_locs: dict[int, list[tuple[int, int]]] = {} - - for _, grid_id, x, y in locations: - filled_locs.setdefault(grid_id, []).append((x, y)) - - filled_loc_refs: list[ir.SSAValue] = [] - - for grid_id, coords in filled_locs.items(): - locs_ref = self.push_constant(ilist.IList(coords)) - filled_loc_refs.append( - self.push_stmt( - filled.Fill(self.get_slm(grid_id), locs_ref) - ).expect_one_result() - ) - - rotation_angle_ref = self.push_constant(rotation_angle / (2 * math.pi)) - - for filled_ref in filled_loc_refs: - self.push_stmt(gate.LocalRz(rotation_angle_ref, filled_ref)) - - def lower_h(self, locs: Sequence[tuple[int, int, int, int]]): - quarter_rotation = self.push_constant(0.25) - zero = self.push_constant(0.0) - half_rotation = self.push_constant(0.5) - if len(locs) == self.num_qubits: - - self.push_stmt(gate.GlobalRz(quarter_rotation)) - self.push_stmt(gate.GlobalR(zero, half_rotation)) - self.push_stmt(gate.GlobalRz(quarter_rotation)) - - def lower_init(self, locs: Sequence[tuple[int, int, int, int]]): - filled_locs: dict[int, list[tuple[int, int]]] = {} - - for _, grid_id, x, y in locs: - filled_locs.setdefault(grid_id, []).append((x, y)) - - filled_loc_refs: list[ir.SSAValue] = [] - - for grid_id, coords in filled_locs.items(): - locs_ref = self.push_constant(ilist.IList(coords)) - filled_loc_refs.append( - self.push_stmt( - filled.Fill(self.get_slm(grid_id), locs_ref) - ).expect_one_result() - ) - - locations = self.push_constant(ilist.IList(filled_loc_refs)) - self.push_stmt(init.Fill(locations)) - - def lower_instruction(self, instruction: dict[str, Any]): - match instruction: - case {"type": "init", "locs": locs}: - self.lower_init(locs) - case {"type": "1qGate", "unitary": "ry", "locs": locs, "angle": angle}: - self.lower_ry_gate(angle, locs) - case {"type": "1qGate", "unitary": "h", "locs": locs}: - self.lower_h(locs) - case {"type": "rydberg", "zone_id": zone_id}: - self.rydberg(zone_id) - case { - "type": "rearrangeJob", - "begin_locs": begin_locs, - "end_locs": end_locs, - }: - self.lower_rearrange(begin_locs, end_locs) - - def lower(self, program: dict[str, Any]) -> ir.Method: - """Entry point for lowering a ZAIR program - - Args: - program (dict[str, Any]): JSON representation of the ZAIR program - - Returns: - ir.Method: Lowered IR method - """ - sym_name = program["name"] - signature = func.Signature((), types.NoneType) - - for inst in program["instructions"]: - self.lower_instruction(inst) - - code = func.Function( - sym_name=sym_name, - signature=signature, - body=self.body, - ) - return ir.Method(None, None, sym_name, [], move, code) diff --git a/scratch/qcr_4a8d_quera_circ_code.json b/scratch/qcr_4a8d_quera_circ_code.json deleted file mode 100644 index 30c245d4..00000000 --- a/scratch/qcr_4a8d_quera_circ_code.json +++ /dev/null @@ -1,5617 +0,0 @@ -{ - "name": "qcr_4a8d_quera_circ", - "architecture_spec_path": "scratch/hardware_example/qcrank_architecture_4_2_v.json", - "instructions": [ - { - "type": "init", - "id": 0, - "begin_time": 0, - "end_time": 0, - "init_locs": [ - [ - 4, - 1, - 0, - 2 - ], - [ - 5, - 1, - 0, - 3 - ], - [ - 6, - 1, - 0, - 4 - ], - [ - 7, - 1, - 0, - 5 - ], - [ - 8, - 1, - 1, - 2 - ], - [ - 9, - 1, - 1, - 3 - ], - [ - 10, - 1, - 1, - 4 - ], - [ - 11, - 1, - 1, - 5 - ], - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 2 - ] - ] - }, - { - "type": "1qGate", - "unitary": "h", - "id": 1, - "locs": [ - [ - -4, - 1, - 1, - 2 - ], - [ - -3, - 1, - 1, - 3 - ], - [ - -2, - 1, - 1, - 4 - ], - [ - -1, - 1, - 1, - 5 - ], - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 2 - ], - [ - 4, - 1, - 0, - 2 - ], - [ - 5, - 1, - 0, - 3 - ], - [ - 6, - 1, - 0, - 4 - ], - [ - 7, - 1, - 0, - 5 - ] - ], - "gates": [ - { - "name": "h", - "q": 0, - "angle": 0 - }, - { - "name": "h", - "q": 1, - "angle": 0 - }, - { - "name": "h", - "q": 2, - "angle": 0 - }, - { - "name": "h", - "q": 3, - "angle": 0 - }, - { - "name": "h", - "q": 4, - "angle": 0 - }, - { - "name": "h", - "q": 5, - "angle": 0 - }, - { - "name": "h", - "q": 6, - "angle": 0 - }, - { - "name": "h", - "q": 7, - "angle": 0 - }, - { - "name": "h", - "q": 8, - "angle": 0 - }, - { - "name": "h", - "q": 9, - "angle": 0 - }, - { - "name": "h", - "q": 10, - "angle": 0 - }, - { - "name": "h", - "q": 11, - "angle": 0 - } - ], - "begin_time": 0, - "end_time": 26.5 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.44482036261982016, - "id": 2, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 26.5, - "end_time": 46.125 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6243114745412531, - "id": 3, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 46.125, - "end_time": 65.75 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.48851645943035393, - "id": 4, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 65.75, - "end_time": 85.375 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7075977375401195, - "id": 5, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 85.375, - "end_time": 105.0 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.1264210841830885, - "id": 6, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 105.0, - "end_time": 124.625 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.21193045723521453, - "id": 7, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 124.625, - "end_time": 144.25 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.09935359277523925, - "id": 8, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 144.25, - "end_time": 163.875 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6317419308676328, - "id": 9, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 163.875, - "end_time": 183.5 - }, - { - "type": "rydberg", - "id": 10, - "zone_id": 0, - "gates": [ - [ - 3, - 4 - ], - [ - 0, - 5 - ], - [ - 1, - 6 - ], - [ - 2, - 7 - ] - ], - "begin_time": 183.5, - "end_time": 183.86 - }, - { - "type": "rearrangeJob", - "id": 11, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "id": 0, - "begin_time": 183.86, - "end_time": 198.86 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 30, - 40, - 50, - 20 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 198.86, - "end_time": 264.9178259075817 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "id": 2, - "begin_time": 264.9178259075817, - "end_time": 279.9178259075817 - } - ], - "begin_time": 183.86, - "end_time": 279.9178259075817 - }, - { - "type": "rydberg", - "id": 12, - "zone_id": 0, - "gates": [ - [ - 3, - 8 - ], - [ - 0, - 9 - ], - [ - 1, - 10 - ], - [ - 2, - 11 - ] - ], - "begin_time": 279.9178259075817, - "end_time": 280.2778259075817 - }, - { - "type": "rearrangeJob", - "id": 13, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 4 - ], - [ - 1, - 2, - 1, - 5 - ], - [ - 2, - 2, - 1, - 6 - ], - [ - 3, - 2, - 1, - 3 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_time": 280.2778259075817, - "end_time": 295.2778259075817 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 40, - 50, - 60, - 30 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 6 - ], - [ - 2, - 3 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 60, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "begin_time": 295.2778259075817, - "end_time": 355.5800948231344 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "begin_time": 355.5800948231344, - "end_time": 370.5800948231344 - } - ], - "begin_time": 280.2778259075817, - "end_time": 370.5800948231344 - }, - { - "type": "rearrangeJob", - "id": 14, - "aod_id": 0, - "aod_qubits": [ - 2 - ], - "begin_locs": [ - [ - 2, - 2, - 1, - 6 - ] - ], - "end_locs": [ - [ - 2, - 2, - 1, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0 - ], - "col_x": [ - 60 - ], - "col_loc": [ - [ - 2, - 6 - ] - ], - "id": 0, - "begin_time": 370.5800948231344, - "end_time": 385.5800948231344 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0 - ], - "col_x_begin": [ - 60 - ], - "col_x_end": [ - 20 - ], - "col_loc_begin": [ - [ - 2, - 6 - ] - ], - "col_loc_end": [ - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 60, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 20, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 385.5800948231344, - "end_time": 506.18463265423986 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 0 - ], - "id": 2, - "begin_time": 506.18463265423986, - "end_time": 521.1846326542399 - } - ], - "begin_time": 370.5800948231344, - "end_time": 521.1846326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.8554446921353213, - "id": 15, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 521.1846326542399, - "end_time": 540.8096326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9629412504473308, - "id": 16, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 540.8096326542399, - "end_time": 560.4346326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.3183283424742377, - "id": 17, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 560.4346326542399, - "end_time": 580.0596326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.3570684717669246, - "id": 18, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 580.0596326542399, - "end_time": 599.6846326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.5708857494908607, - "id": 19, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 599.6846326542399, - "end_time": 619.3096326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.039890072710002555, - "id": 20, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 619.3096326542399, - "end_time": 638.9346326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.2687504476209268, - "id": 21, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 638.9346326542399, - "end_time": 658.5596326542399 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9850699851801968, - "id": 22, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 658.5596326542399, - "end_time": 678.1846326542399 - }, - { - "type": "rydberg", - "id": 23, - "zone_id": 0, - "gates": [ - [ - 1, - 11 - ], - [ - 0, - 10 - ], - [ - 3, - 9 - ], - [ - 2, - 8 - ] - ], - "begin_time": 678.1846326542399, - "end_time": 678.5446326542399 - }, - { - "type": "rearrangeJob", - "id": 24, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 4 - ], - [ - 1, - 2, - 1, - 5 - ], - [ - 2, - 2, - 1, - 2 - ], - [ - 3, - 2, - 1, - 3 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 4 - ], - [ - 1, - 2, - 0, - 5 - ], - [ - 2, - 2, - 0, - 2 - ], - [ - 3, - 2, - 0, - 3 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x": [ - 40, - 50, - 20, - 30 - ], - "col_loc": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "id": 0, - "begin_time": 678.5446326542399, - "end_time": 693.5446326542399 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x_begin": [ - 40, - 50, - 20, - 30 - ], - "col_x_end": [ - 40, - 50, - 20, - 30 - ], - "col_loc_begin": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "col_loc_end": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 20, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 7 - }, - { - "id": 1, - "x": 50, - "y": 7 - }, - { - "id": 2, - "x": 20, - "y": 7 - }, - { - "id": 3, - "x": 30, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 693.5446326542399, - "end_time": 759.6024585618215 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "id": 2, - "begin_time": 759.6024585618215, - "end_time": 774.6024585618215 - } - ], - "begin_time": 678.5446326542399, - "end_time": 774.6024585618215 - }, - { - "type": "rydberg", - "id": 25, - "zone_id": 0, - "gates": [ - [ - 1, - 7 - ], - [ - 0, - 6 - ], - [ - 3, - 5 - ], - [ - 2, - 4 - ] - ], - "begin_time": 774.6024585618215, - "end_time": 774.9624585618216 - }, - { - "type": "rearrangeJob", - "id": 26, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 4 - ], - [ - 1, - 2, - 0, - 5 - ], - [ - 2, - 2, - 0, - 2 - ], - [ - 3, - 2, - 0, - 3 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 1 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x": [ - 40, - 50, - 20, - 30 - ], - "col_loc": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "begin_time": 774.9624585618216, - "end_time": 789.9624585618216 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x_begin": [ - 40, - 50, - 20, - 30 - ], - "col_x_end": [ - 30, - 40, - 10, - 20 - ], - "col_loc_begin": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 1 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 7 - }, - { - "id": 1, - "x": 50, - "y": 7 - }, - { - "id": 2, - "x": 20, - "y": 7 - }, - { - "id": 3, - "x": 30, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 10, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "begin_time": 789.9624585618216, - "end_time": 850.2647274773743 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "begin_time": 850.2647274773743, - "end_time": 865.2647274773743 - } - ], - "begin_time": 774.9624585618216, - "end_time": 865.2647274773743 - }, - { - "type": "rearrangeJob", - "id": 27, - "aod_id": 0, - "aod_qubits": [ - 2 - ], - "begin_locs": [ - [ - 2, - 2, - 0, - 1 - ] - ], - "end_locs": [ - [ - 2, - 2, - 0, - 5 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 0 - ], - "col_x": [ - 10 - ], - "col_loc": [ - [ - 2, - 1 - ] - ], - "id": 0, - "begin_time": 865.2647274773743, - "end_time": 880.2647274773743 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 0 - ], - "col_x_begin": [ - 10 - ], - "col_x_end": [ - 50 - ], - "col_loc_begin": [ - [ - 2, - 1 - ] - ], - "col_loc_end": [ - [ - 2, - 5 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 10, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 880.2647274773743, - "end_time": 1000.8692653084797 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 0 - ], - "id": 2, - "begin_time": 1000.8692653084797, - "end_time": 1015.8692653084797 - } - ], - "begin_time": 865.2647274773743, - "end_time": 1015.8692653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.20486859973509242, - "id": 28, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 1015.8692653084797, - "end_time": 1035.4942653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.864858860380752, - "id": 29, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 1035.4942653084797, - "end_time": 1055.1192653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.11418393870717058, - "id": 30, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 1055.1192653084797, - "end_time": 1074.7442653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.23093895165734868, - "id": 31, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 1074.7442653084797, - "end_time": 1094.3692653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.13047349548716525, - "id": 32, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 1094.3692653084797, - "end_time": 1113.9942653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.2594701401226652, - "id": 33, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 1113.9942653084797, - "end_time": 1133.6192653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.8123550180563659, - "id": 34, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 1133.6192653084797, - "end_time": 1153.2442653084797 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.769097981013622, - "id": 35, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 1153.2442653084797, - "end_time": 1172.8692653084797 - }, - { - "type": "rydberg", - "id": 36, - "zone_id": 0, - "gates": [ - [ - 3, - 4 - ], - [ - 0, - 5 - ], - [ - 1, - 6 - ], - [ - 2, - 7 - ] - ], - "begin_time": 1172.8692653084797, - "end_time": 1173.2292653084796 - }, - { - "type": "rearrangeJob", - "id": 37, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "id": 0, - "begin_time": 1173.2292653084796, - "end_time": 1188.2292653084796 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 30, - 40, - 50, - 20 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 1188.2292653084796, - "end_time": 1254.2870912160613 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "id": 2, - "begin_time": 1254.2870912160613, - "end_time": 1269.2870912160613 - } - ], - "begin_time": 1173.2292653084796, - "end_time": 1269.2870912160613 - }, - { - "type": "rydberg", - "id": 38, - "zone_id": 0, - "gates": [ - [ - 3, - 8 - ], - [ - 0, - 9 - ], - [ - 1, - 10 - ], - [ - 2, - 11 - ] - ], - "begin_time": 1269.2870912160613, - "end_time": 1269.6470912160612 - }, - { - "type": "rearrangeJob", - "id": 39, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 5 - ], - [ - 1, - 2, - 1, - 6 - ], - [ - 2, - 2, - 1, - 7 - ], - [ - 3, - 2, - 1, - 4 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_time": 1269.6470912160612, - "end_time": 1284.6470912160612 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 50, - 60, - 70, - 40 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 5 - ], - [ - 2, - 6 - ], - [ - 2, - 7 - ], - [ - 2, - 4 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 19 - }, - { - "id": 1, - "x": 60, - "y": 19 - }, - { - "id": 2, - "x": 70, - "y": 19 - }, - { - "id": 3, - "x": 40, - "y": 19 - } - ] - ], - "begin_time": 1284.6470912160612, - "end_time": 1369.9273777583053 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "begin_time": 1369.9273777583053, - "end_time": 1384.9273777583053 - } - ], - "begin_time": 1269.6470912160612, - "end_time": 1384.9273777583053 - }, - { - "type": "rearrangeJob", - "id": 40, - "aod_id": 0, - "aod_qubits": [ - 1, - 2 - ], - "begin_locs": [ - [ - 1, - 2, - 1, - 6 - ], - [ - 2, - 2, - 1, - 7 - ] - ], - "end_locs": [ - [ - 1, - 2, - 1, - 2 - ], - [ - 2, - 2, - 1, - 3 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0, - 1 - ], - "col_x": [ - 60, - 70 - ], - "col_loc": [ - [ - 2, - 6 - ], - [ - 2, - 7 - ] - ], - "id": 0, - "begin_time": 1384.9273777583053, - "end_time": 1399.9273777583053 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0, - 1 - ], - "col_x_begin": [ - 60, - 70 - ], - "col_x_end": [ - 20, - 30 - ], - "col_loc_begin": [ - [ - 2, - 6 - ], - [ - 2, - 7 - ] - ], - "col_loc_end": [ - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 19 - }, - { - "id": 1, - "x": 60, - "y": 19 - }, - { - "id": 2, - "x": 70, - "y": 19 - }, - { - "id": 3, - "x": 40, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 19 - }, - { - "id": 1, - "x": 20, - "y": 19 - }, - { - "id": 2, - "x": 30, - "y": 19 - }, - { - "id": 3, - "x": 40, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 1399.9273777583053, - "end_time": 1520.5319155894108 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 0, - 1 - ], - "id": 2, - "begin_time": 1520.5319155894108, - "end_time": 1535.5319155894108 - } - ], - "begin_time": 1384.9273777583053, - "end_time": 1535.5319155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.4497895402504003, - "id": 41, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 1535.5319155894108, - "end_time": 1555.1569155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9726899827641711, - "id": 42, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 1555.1569155894108, - "end_time": 1574.7819155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7497893204477966, - "id": 43, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 1574.7819155894108, - "end_time": 1594.4069155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7733599572058976, - "id": 44, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 1594.4069155894108, - "end_time": 1614.0319155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9684007516841149, - "id": 45, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 1614.0319155894108, - "end_time": 1633.6569155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7254772134505297, - "id": 46, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 1633.6569155894108, - "end_time": 1653.2819155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7123155565685442, - "id": 47, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 1653.2819155894108, - "end_time": 1672.9069155894108 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.07830956110351617, - "id": 48, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 1672.9069155894108, - "end_time": 1692.5319155894108 - }, - { - "type": "rydberg", - "id": 49, - "zone_id": 0, - "gates": [ - [ - 0, - 11 - ], - [ - 3, - 10 - ], - [ - 2, - 9 - ], - [ - 1, - 8 - ] - ], - "begin_time": 1692.5319155894108, - "end_time": 1692.8919155894107 - }, - { - "type": "rearrangeJob", - "id": 50, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 5 - ], - [ - 1, - 2, - 1, - 2 - ], - [ - 2, - 2, - 1, - 3 - ], - [ - 3, - 2, - 1, - 4 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 5 - ], - [ - 1, - 2, - 0, - 2 - ], - [ - 2, - 2, - 0, - 3 - ], - [ - 3, - 2, - 0, - 4 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "col_x": [ - 50, - 20, - 30, - 40 - ], - "col_loc": [ - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ], - [ - 2, - 4 - ] - ], - "id": 0, - "begin_time": 1692.8919155894107, - "end_time": 1707.8919155894107 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "col_x_begin": [ - 50, - 20, - 30, - 40 - ], - "col_x_end": [ - 50, - 20, - 30, - 40 - ], - "col_loc_begin": [ - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ], - [ - 2, - 4 - ] - ], - "col_loc_end": [ - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ], - [ - 2, - 4 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 19 - }, - { - "id": 1, - "x": 20, - "y": 19 - }, - { - "id": 2, - "x": 30, - "y": 19 - }, - { - "id": 3, - "x": 40, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 7 - }, - { - "id": 1, - "x": 20, - "y": 7 - }, - { - "id": 2, - "x": 30, - "y": 7 - }, - { - "id": 3, - "x": 40, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 1707.8919155894107, - "end_time": 1773.9497414969924 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "id": 2, - "begin_time": 1773.9497414969924, - "end_time": 1788.9497414969924 - } - ], - "begin_time": 1692.8919155894107, - "end_time": 1788.9497414969924 - }, - { - "type": "rydberg", - "id": 51, - "zone_id": 0, - "gates": [ - [ - 0, - 7 - ], - [ - 3, - 6 - ], - [ - 2, - 5 - ], - [ - 1, - 4 - ] - ], - "begin_time": 1788.9497414969924, - "end_time": 1789.3097414969923 - }, - { - "type": "rearrangeJob", - "id": 52, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 5 - ], - [ - 1, - 2, - 0, - 2 - ], - [ - 2, - 2, - 0, - 3 - ], - [ - 3, - 2, - 0, - 4 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 7 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 6 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "col_x": [ - 50, - 20, - 30, - 40 - ], - "col_loc": [ - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ], - [ - 2, - 4 - ] - ], - "begin_time": 1789.3097414969923, - "end_time": 1804.3097414969923 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "col_x_begin": [ - 50, - 20, - 30, - 40 - ], - "col_x_end": [ - 70, - 40, - 50, - 60 - ], - "col_loc_begin": [ - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ], - [ - 2, - 4 - ] - ], - "col_loc_end": [ - [ - 2, - 7 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 6 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 50, - "y": 7 - }, - { - "id": 1, - "x": 20, - "y": 7 - }, - { - "id": 2, - "x": 30, - "y": 7 - }, - { - "id": 3, - "x": 40, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 70, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 60, - "y": 7 - } - ] - ], - "begin_time": 1804.3097414969923, - "end_time": 1889.5900280392364 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 3, - 0, - 1, - 2 - ], - "begin_time": 1889.5900280392364, - "end_time": 1904.5900280392364 - } - ], - "begin_time": 1789.3097414969923, - "end_time": 1904.5900280392364 - }, - { - "type": "rearrangeJob", - "id": 53, - "aod_id": 0, - "aod_qubits": [ - 0, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 7 - ], - [ - 3, - 2, - 0, - 6 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 1, - 0 - ], - "col_x": [ - 70, - 60 - ], - "col_loc": [ - [ - 2, - 7 - ], - [ - 2, - 6 - ] - ], - "id": 0, - "begin_time": 1904.5900280392364, - "end_time": 1919.5900280392364 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 1, - 0 - ], - "col_x_begin": [ - 70, - 60 - ], - "col_x_end": [ - 30, - 20 - ], - "col_loc_begin": [ - [ - 2, - 7 - ], - [ - 2, - 6 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 70, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 60, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 1919.5900280392364, - "end_time": 2040.1945658703419 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 0 - ], - "id": 2, - "begin_time": 2040.1945658703419, - "end_time": 2055.1945658703416 - } - ], - "begin_time": 1904.5900280392364, - "end_time": 2055.1945658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.17796426297818568, - "id": 54, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 2055.1945658703416, - "end_time": 2074.8195658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9103625211859183, - "id": 55, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 2074.8195658703416, - "end_time": 2094.4445658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.7509979216074734, - "id": 56, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 2094.4445658703416, - "end_time": 2114.0695658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.8685286518346035, - "id": 57, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 2114.0695658703416, - "end_time": 2133.6945658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.01435387873378624, - "id": 58, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 2133.6945658703416, - "end_time": 2153.3195658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.14855941671487083, - "id": 59, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 2153.3195658703416, - "end_time": 2172.9445658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6449625728520407, - "id": 60, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 2172.9445658703416, - "end_time": 2192.5695658703416 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.5028408409056974, - "id": 61, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 2192.5695658703416, - "end_time": 2212.1945658703416 - }, - { - "type": "rydberg", - "id": 62, - "zone_id": 0, - "gates": [ - [ - 3, - 4 - ], - [ - 0, - 5 - ], - [ - 1, - 6 - ], - [ - 2, - 7 - ] - ], - "begin_time": 2212.1945658703416, - "end_time": 2212.554565870342 - }, - { - "type": "rearrangeJob", - "id": 63, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 5 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "id": 0, - "begin_time": 2212.554565870342, - "end_time": 2227.554565870342 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 30, - 40, - 50, - 20 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 2227.554565870342, - "end_time": 2293.612391777923 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "id": 2, - "begin_time": 2293.612391777923, - "end_time": 2308.612391777923 - } - ], - "begin_time": 2212.554565870342, - "end_time": 2308.612391777923 - }, - { - "type": "rydberg", - "id": 64, - "zone_id": 0, - "gates": [ - [ - 3, - 8 - ], - [ - 0, - 9 - ], - [ - 1, - 10 - ], - [ - 2, - 11 - ] - ], - "begin_time": 2308.612391777923, - "end_time": 2308.9723917779233 - }, - { - "type": "rearrangeJob", - "id": 65, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 3 - ], - [ - 1, - 2, - 1, - 4 - ], - [ - 2, - 2, - 1, - 5 - ], - [ - 3, - 2, - 1, - 2 - ] - ], - "end_locs": [ - [ - 0, - 2, - 1, - 4 - ], - [ - 1, - 2, - 1, - 5 - ], - [ - 2, - 2, - 1, - 6 - ], - [ - 3, - 2, - 1, - 3 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x": [ - 30, - 40, - 50, - 20 - ], - "col_loc": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "begin_time": 2308.9723917779233, - "end_time": 2323.9723917779233 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "col_x_begin": [ - 30, - 40, - 50, - 20 - ], - "col_x_end": [ - 40, - 50, - 60, - 30 - ], - "col_loc_begin": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ] - ], - "col_loc_end": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 6 - ], - [ - 2, - 3 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 19 - }, - { - "id": 1, - "x": 40, - "y": 19 - }, - { - "id": 2, - "x": 50, - "y": 19 - }, - { - "id": 3, - "x": 20, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 60, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "begin_time": 2323.9723917779233, - "end_time": 2384.274660693476 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 1, - 2, - 3, - 0 - ], - "begin_time": 2384.274660693476, - "end_time": 2399.274660693476 - } - ], - "begin_time": 2308.9723917779233, - "end_time": 2399.274660693476 - }, - { - "type": "rearrangeJob", - "id": 66, - "aod_id": 0, - "aod_qubits": [ - 2 - ], - "begin_locs": [ - [ - 2, - 2, - 1, - 6 - ] - ], - "end_locs": [ - [ - 2, - 2, - 1, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0 - ], - "col_x": [ - 60 - ], - "col_loc": [ - [ - 2, - 6 - ] - ], - "id": 0, - "begin_time": 2399.274660693476, - "end_time": 2414.274660693476 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 19 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 0 - ], - "col_x_begin": [ - 60 - ], - "col_x_end": [ - 20 - ], - "col_loc_begin": [ - [ - 2, - 6 - ] - ], - "col_loc_end": [ - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 60, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 20, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "id": 1, - "begin_time": 2414.274660693476, - "end_time": 2534.8791985245816 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 0 - ], - "id": 2, - "begin_time": 2534.8791985245816, - "end_time": 2549.8791985245816 - } - ], - "begin_time": 2399.274660693476, - "end_time": 2549.8791985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.19268032441473948, - "id": 67, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 2549.8791985245816, - "end_time": 2569.5041985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6823970945461502, - "id": 68, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 2569.5041985245816, - "end_time": 2589.1291985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.34374268372529426, - "id": 69, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 2589.1291985245816, - "end_time": 2608.7541985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9893082586958559, - "id": 70, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 2608.7541985245816, - "end_time": 2628.3791985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6761686602967548, - "id": 71, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 2628.3791985245816, - "end_time": 2648.0041985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.27493447082336897, - "id": 72, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 2648.0041985245816, - "end_time": 2667.6291985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.2741776925997004, - "id": 73, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 2667.6291985245816, - "end_time": 2687.2541985245816 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.5052805165190674, - "id": 74, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 2687.2541985245816, - "end_time": 2706.8791985245816 - }, - { - "type": "rydberg", - "id": 75, - "zone_id": 0, - "gates": [ - [ - 1, - 11 - ], - [ - 0, - 10 - ], - [ - 3, - 9 - ], - [ - 2, - 8 - ] - ], - "begin_time": 2706.8791985245816, - "end_time": 2707.2391985245818 - }, - { - "type": "rearrangeJob", - "id": 76, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 1, - 4 - ], - [ - 1, - 2, - 1, - 5 - ], - [ - 2, - 2, - 1, - 2 - ], - [ - 3, - 2, - 1, - 3 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 4 - ], - [ - 1, - 2, - 0, - 5 - ], - [ - 2, - 2, - 0, - 2 - ], - [ - 3, - 2, - 0, - 3 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 19 - ], - "row_loc": [ - [ - 2, - 1 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x": [ - 40, - 50, - 20, - 30 - ], - "col_loc": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "id": 0, - "begin_time": 2707.2391985245818, - "end_time": 2722.2391985245818 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 19 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 1 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x_begin": [ - 40, - 50, - 20, - 30 - ], - "col_x_end": [ - 40, - 50, - 20, - 30 - ], - "col_loc_begin": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "col_loc_end": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 19 - }, - { - "id": 1, - "x": 50, - "y": 19 - }, - { - "id": 2, - "x": 20, - "y": 19 - }, - { - "id": 3, - "x": 30, - "y": 19 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 7 - }, - { - "id": 1, - "x": 50, - "y": 7 - }, - { - "id": 2, - "x": 20, - "y": 7 - }, - { - "id": 3, - "x": 30, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 2722.2391985245818, - "end_time": 2788.297024432163 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "id": 2, - "begin_time": 2788.297024432163, - "end_time": 2803.297024432163 - } - ], - "begin_time": 2707.2391985245818, - "end_time": 2803.297024432163 - }, - { - "type": "rydberg", - "id": 77, - "zone_id": 0, - "gates": [ - [ - 1, - 7 - ], - [ - 0, - 6 - ], - [ - 3, - 5 - ], - [ - 2, - 4 - ] - ], - "begin_time": 2803.297024432163, - "end_time": 2803.6570244321633 - }, - { - "type": "rearrangeJob", - "id": 78, - "aod_id": 0, - "aod_qubits": [ - 0, - 1, - 2, - 3 - ], - "begin_locs": [ - [ - 0, - 2, - 0, - 4 - ], - [ - 1, - 2, - 0, - 5 - ], - [ - 2, - 2, - 0, - 2 - ], - [ - 3, - 2, - 0, - 3 - ] - ], - "end_locs": [ - [ - 0, - 2, - 0, - 3 - ], - [ - 1, - 2, - 0, - 4 - ], - [ - 2, - 2, - 0, - 1 - ], - [ - 3, - 2, - 0, - 2 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x": [ - 40, - 50, - 20, - 30 - ], - "col_loc": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "begin_time": 2803.6570244321633, - "end_time": 2818.6570244321633 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "col_x_begin": [ - 40, - 50, - 20, - 30 - ], - "col_x_end": [ - 30, - 40, - 10, - 20 - ], - "col_loc_begin": [ - [ - 2, - 4 - ], - [ - 2, - 5 - ], - [ - 2, - 2 - ], - [ - 2, - 3 - ] - ], - "col_loc_end": [ - [ - 2, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 1 - ], - [ - 2, - 2 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 40, - "y": 7 - }, - { - "id": 1, - "x": 50, - "y": 7 - }, - { - "id": 2, - "x": 20, - "y": 7 - }, - { - "id": 3, - "x": 30, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 10, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "begin_time": 2818.6570244321633, - "end_time": 2878.959293347716 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 2, - 3, - 0, - 1 - ], - "begin_time": 2878.959293347716, - "end_time": 2893.959293347716 - } - ], - "begin_time": 2803.6570244321633, - "end_time": 2893.959293347716 - }, - { - "type": "rearrangeJob", - "id": 79, - "aod_id": 0, - "aod_qubits": [ - 2 - ], - "begin_locs": [ - [ - 2, - 2, - 0, - 1 - ] - ], - "end_locs": [ - [ - 2, - 2, - 0, - 5 - ] - ], - "insts": [ - { - "type": "activate", - "row_id": [ - 0 - ], - "row_y": [ - 7 - ], - "row_loc": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 0 - ], - "col_x": [ - 10 - ], - "col_loc": [ - [ - 2, - 1 - ] - ], - "id": 0, - "begin_time": 2893.959293347716, - "end_time": 2908.959293347716 - }, - { - "type": "move:big", - "move_type": "big", - "row_id": [ - 0 - ], - "row_y_begin": [ - 7 - ], - "row_y_end": [ - 7 - ], - "row_loc_begin": [ - [ - 2, - 0 - ] - ], - "row_loc_end": [ - [ - 2, - 0 - ] - ], - "col_id": [ - 0 - ], - "col_x_begin": [ - 10 - ], - "col_x_end": [ - 50 - ], - "col_loc_begin": [ - [ - 2, - 1 - ] - ], - "col_loc_end": [ - [ - 2, - 5 - ] - ], - "begin_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 10, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "end_coord": [ - [ - { - "id": 0, - "x": 30, - "y": 7 - }, - { - "id": 1, - "x": 40, - "y": 7 - }, - { - "id": 2, - "x": 50, - "y": 7 - }, - { - "id": 3, - "x": 20, - "y": 7 - } - ] - ], - "id": 1, - "begin_time": 2908.959293347716, - "end_time": 3029.5638311788216 - }, - { - "type": "deactivate", - "row_id": [ - 0 - ], - "col_id": [ - 0 - ], - "id": 2, - "begin_time": 3029.5638311788216, - "end_time": 3044.5638311788216 - } - ], - "begin_time": 2893.959293347716, - "end_time": 3044.5638311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.06221884132610567, - "id": 80, - "locs": [ - [ - 0, - 1, - 0, - 2 - ] - ], - "begin_time": 3044.5638311788216, - "end_time": 3064.1888311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.47984909838638656, - "id": 81, - "locs": [ - [ - 1, - 1, - 0, - 3 - ] - ], - "begin_time": 3064.1888311788216, - "end_time": 3083.8138311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.28128919513734174, - "id": 82, - "locs": [ - [ - 2, - 1, - 0, - 4 - ] - ], - "begin_time": 3083.8138311788216, - "end_time": 3103.4388311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.046831045633477064, - "id": 83, - "locs": [ - [ - 3, - 1, - 0, - 5 - ] - ], - "begin_time": 3103.4388311788216, - "end_time": 3123.0638311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.6759701921298618, - "id": 84, - "locs": [ - [ - 4, - 1, - 1, - 2 - ] - ], - "begin_time": 3123.0638311788216, - "end_time": 3142.6888311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.2675913446883964, - "id": 85, - "locs": [ - [ - 5, - 1, - 1, - 3 - ] - ], - "begin_time": 3142.6888311788216, - "end_time": 3162.3138311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.9797944935017265, - "id": 86, - "locs": [ - [ - 6, - 1, - 1, - 4 - ] - ], - "begin_time": 3162.3138311788216, - "end_time": 3181.9388311788216 - }, - { - "type": "1qGate", - "unitary": "ry", - "angle": 0.4511743159081828, - "id": 87, - "locs": [ - [ - 7, - 1, - 1, - 5 - ] - ], - "begin_time": 3181.9388311788216, - "end_time": 3201.5638311788216 - }, - { - "type": "rydberg", - "id": 88, - "zone_id": 0, - "gates": [ - [ - 3, - 4 - ], - [ - 0, - 5 - ], - [ - 1, - 6 - ], - [ - 2, - 7 - ] - ], - "begin_time": 3201.5638311788216, - "end_time": 3201.9238311788217 - } - ], - "runtime": 3201.9238311788217 -} \ No newline at end of file diff --git a/scratch/qcrank.py b/scratch/qcrank.py deleted file mode 100644 index 7a8b3e48..00000000 --- a/scratch/qcrank.py +++ /dev/null @@ -1,92 +0,0 @@ -import json -from typing import Any, Literal, TypeVar - -import numpy as np -from bloqade.geometry.dialects import grid -from kirin.dialects import ilist -from lower_zair import ShuttleBuilder - -from bloqade.shuttle import action, gate, init, measure, schedule, spec -from bloqade.shuttle.prelude import move, tweezer -from bloqade.shuttle.stdlib.layouts.two_col_zone import rearrange, rearrange_horizontal_vertical_move -from bloqade.shuttle.visualizer import MatplotlibRenderer, PathVisualizer - - -def run_qcrank(filename: str): - with open(filename, "r") as f: - compiled_qcrank = json.load(f) - - arch_filename = compiled_qcrank["architecture_spec_path"] - - with open(arch_filename, "r") as f: - architecture_spec = json.load(f) - - # set architecture - # assume single entagnlement zone - entanglement_zone_spec = architecture_spec["entanglement_zones"][0] - slms = entanglement_zone_spec["slms"] - assert len(slms) == 2 - slm1 = slms[0] - slm2 = slms[1] - assert slm1["r"] == slm2["r"] - assert slm1["c"] == slm2["c"] - assert slm1["site_seperation"] == slm2["site_seperation"] - assert slm1["location"][0] == slm2["location"][0] - dis_trap = abs(slm1["location"][1] - slm2["location"][1]) - dis_site = slm1["site_seperation"][1] - dis_trap - x_spacing = [slm1["site_seperation"][0] * (slm1["c"] - 1)] - y_spacing = [] - for _ in range(slm1["r"]): - y_spacing.append(dis_trap) - y_spacing.append(dis_site) - - slm0 = grid.Grid( - x_spacing=tuple(x_spacing), - y_spacing=tuple(y_spacing), - x_init=slm1["location"][0], - y_init=slm1["location"][1], - ) - - x_spacing = [slm1["site_seperation"][0]] * (slm1["c"] - 1) - y_spacing = [slm1["site_seperation"][1]] * (slm1["r"] - 1) - slm1 = grid.Grid( - x_spacing=tuple(x_spacing), - y_spacing=tuple(y_spacing), - x_init=slm1["location"][0], - y_init=slm1["location"][1], - ) - x_spacing = [slm2["site_seperation"][0]] * (slm2["c"] - 1) - y_spacing = [slm2["site_seperation"][1]] * (slm2["r"] - 1) - slm2 = grid.Grid( - x_spacing=tuple(x_spacing), - y_spacing=tuple(y_spacing), - x_init=slm2["location"][0], - y_init=slm2["location"][1], - ) - spec_value = spec.ArchSpec( - layout=spec.Layout( - static_traps={ - "slm0": slm0, - "slm1": slm1, - "slm2": slm2, - }, - fillable=set(["slm1", "slm2"]), - ) - ) - # print(spec_value) - - spec_mapping = {0: "slms", 1: "slm1", 2: "slm2"} - num_qubits = len(compiled_qcrank["instructions"][0]["init_locs"]) - shuttle_builder = ShuttleBuilder( - spec_mapping=spec_mapping, - move_kernel=rearrange, - # move_kernel=rearrange_horizontal_vertical_move, - num_qubits=num_qubits - ) - method = shuttle_builder.lower(compiled_qcrank) - method.print() - - -if __name__ == "__main__": - filename = "scratch/qcr_4a8d_quera_circ_code.json" - run_qcrank(filename) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index 247fe846..b365546c 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -2,6 +2,7 @@ from typing import TypeVar from bloqade.geometry.dialects import grid +from kirin import ir from kirin.dialects import ilist from bloqade.shuttle import action, schedule, spec @@ -154,15 +155,13 @@ def parking_y_end(index: int): num_y = len(src_y) src_horizontal_parking = grid.from_positions( - ilist.map(parking_x, src_x), ilist.map(float, src_y) + ilist.map(parking_x, src_x), grid.get_ypos(start) ) parking_y = ilist.map(parking_y_end, ilist.range(num_y)) mid_pos_after_vertical_move = grid.from_positions( grid.get_xpos(src_horizontal_parking), parking_y ) - mid_pos_after_horizontal_move = grid.from_positions( - ilist.map(float, dst_x), ilist.map(float, parking_y) - ) + mid_pos_after_horizontal_move = grid.from_positions(grid.get_xpos(end), parking_y) action.set_loc(start) action.turn_on(action.ALL, action.ALL) @@ -179,6 +178,7 @@ def rearrange( src_y: ilist.IList[int, NumY], dst_x: ilist.IList[int, NumX], dst_y: ilist.IList[int, NumY], + tweezer_kernal: ir.Method = rearrange_impl, ): if len(src_x) < 1 or len(dst_x) < 1: return @@ -186,22 +186,5 @@ def rearrange( x_tones = ilist.range(len(src_x)) y_tones = ilist.range(len(src_y)) - device_fn = schedule.device_fn(rearrange_impl, x_tones, y_tones) - device_fn(src_x, src_y, dst_x, dst_y) - - -@move -def rearrange_horizontal_vertical_move( - src_x: ilist.IList[int, NumX], - src_y: ilist.IList[int, NumY], - dst_x: ilist.IList[int, NumX], - dst_y: ilist.IList[int, NumY], -): - if len(src_x) < 1 or len(dst_x) < 1: - return - - x_tones = ilist.range(len(src_x)) - y_tones = ilist.range(len(src_y)) - - device_fn = schedule.device_fn(rearrange_impl_horizontal_vertical, x_tones, y_tones) + device_fn = schedule.device_fn(tweezer_kernal, x_tones, y_tones) device_fn(src_x, src_y, dst_x, dst_y) diff --git a/uv.lock b/uv.lock index a579ebeb..df2dae27 100644 --- a/uv.lock +++ b/uv.lock @@ -182,7 +182,7 @@ doc = [ requires-dist = [ { name = "bloqade-circuit", specifier = ">=0.6.0,<0.8.0.dev0" }, { name = "bloqade-geometry", specifier = "~=0.3.0" }, - { name = "kirin-toolchain", specifier = ">=0.17.17,<0.18.0.dev0" }, + { name = "kirin-toolchain", specifier = ">=0.17.23,<0.18.0.dev0" }, { name = "matplotlib", marker = "extra == 'visualization'", specifier = ">=3.9.4" }, ] provides-extras = ["visualization"] @@ -955,16 +955,16 @@ wheels = [ [[package]] name = "kirin-toolchain" -version = "0.17.22" +version = "0.17.27" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "beartype" }, { name = "rich" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/48/58/0fcd2b2c63580cf50aa1a13516d44d329422e35967258696b1bb176d3231/kirin_toolchain-0.17.22.tar.gz", hash = "sha256:a0a05ac5870352564c76c2754f501c158608217613136f17ecf25882cb7e2b03", size = 1184720, upload-time = "2025-08-20T13:09:11.71Z" } +sdist = { url = "https://files.pythonhosted.org/packages/80/1d/d7401fde271224c7768d5481e9025681764b909f4ef39acea78581ce0de1/kirin_toolchain-0.17.27.tar.gz", hash = "sha256:782521650e7aa1c79890b0fe9b8ffe6edbcd857fe4bc93198b8d78933e4bd739", size = 1184493, upload-time = "2025-10-01T20:55:26.051Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/63/a5/295afd71ec6c3c116e875ee94a589baf097045e7cbc35d509c47edf9c2fc/kirin_toolchain-0.17.22-py3-none-any.whl", hash = "sha256:516b4dd85ceaa2e94a5a051a8aa8d6264fd33757e6aafc94ef2118384e45f1f4", size = 228152, upload-time = "2025-08-20T13:09:08.738Z" }, + { url = "https://files.pythonhosted.org/packages/c9/a3/68e0f242a4934378b7ab2e84351e0fb5986d37e49a698d85df5eaf15cf32/kirin_toolchain-0.17.27-py3-none-any.whl", hash = "sha256:2a7917ce3d823956036c26045a1e33ab4cf1cf54e4d7d89639c115cff12c15a9", size = 231024, upload-time = "2025-10-01T20:55:24.44Z" }, ] [[package]] From 74284087afd638ad820f411d500e7780ef1f9b20 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Tue, 7 Oct 2025 16:26:18 -0700 Subject: [PATCH 13/16] remove redundant files --- .../shuttle/stdlib/layouts/two_col_zone.py | 30 ++-- test/stdlib/two_col_zone/test_move.py | 133 +++++++++++------- 2 files changed, 101 insertions(+), 62 deletions(-) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index e15c7cab..113c5682 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -197,18 +197,18 @@ def rearrange( device_fn(src_x, src_y, dst_x, dst_y) -@move -def get_device_fn( - src_x: ilist.IList[int, NumX], - src_y: ilist.IList[int, NumY], - dst_x: ilist.IList[int, NumX], - dst_y: ilist.IList[int, NumY], - tweezer_kernal: ir.Method = rearrange_impl, -): - if len(src_x) < 1 or len(dst_x) < 1: - return - - x_tones = ilist.range(len(src_x)) - y_tones = ilist.range(len(src_y)) - - return schedule.device_fn(tweezer_kernal, x_tones, y_tones) +# @move +# def get_device_fn( +# src_x: ilist.IList[int, NumX], +# src_y: ilist.IList[int, NumY], +# dst_x: ilist.IList[int, NumX], +# dst_y: ilist.IList[int, NumY], +# tweezer_kernal: ir.Method = rearrange_impl, +# ): +# if len(src_x) < 1 or len(dst_x) < 1: +# return + +# x_tones = ilist.range(len(src_x)) +# y_tones = ilist.range(len(src_y)) + +# return schedule.device_fn(tweezer_kernal, x_tones, y_tones) diff --git a/test/stdlib/two_col_zone/test_move.py b/test/stdlib/two_col_zone/test_move.py index cc6ca5d9..1c7ee501 100644 --- a/test/stdlib/two_col_zone/test_move.py +++ b/test/stdlib/two_col_zone/test_move.py @@ -1,64 +1,103 @@ +import itertools +import typing +from typing import Any + +import pytest +from bloqade.geometry.dialects import grid from kirin.dialects import ilist -from bloqade.shuttle import move -from bloqade.shuttle.arch import ArchSpecInterpreter from bloqade.shuttle.codegen import TraceInterpreter, taskgen from bloqade.shuttle.stdlib.layouts.two_col_zone import ( - get_device_fn, get_spec, rearrange_impl_horizontal_vertical, ) +move_test_cases = [ + ( + ilist.IList([0, 2, 4, 6]), + ilist.IList([0]), + ilist.IList([1, 3, 5, 7]), + ilist.IList([1]), + [ + grid.Grid((12.0, 12.0, 12.0), (), -3.0, 0.0), + grid.Grid((12.0, 12.0, 12.0), (), -3.0, 7.0), + grid.Grid((12.0, 12.0, 12.0), (), 2.0, 7.0), + ], + ), + ( + ilist.IList([0, 1, 2, 3]), + ilist.IList([0]), + ilist.IList([4, 5, 6, 7]), + ilist.IList([1]), + [ + grid.Grid((8.0, 4.0, 8.0), (), -3.0, 0.0), + grid.Grid((8.0, 4.0, 8.0), (), -3.0, 7.0), + grid.Grid((2.0, 10.0, 2.0), (), 24.0, 7.0), + ], + ), + ( + ilist.IList([0, 1, 6, 7]), + ilist.IList([1]), + ilist.IList([1, 2, 7, 8]), + ilist.IList([0]), + [ + grid.Grid((8.0, 28.0, 8.0), (), -3.0, 10.0), + grid.Grid((8.0, 28.0, 8.0), (), -3.0, 3.0), + grid.Grid((10.0, 26.0, 10.0), (), 2.0, 3.0), + ], + ), + ( # error case + ilist.IList([0, 2, 4, 6]), + ilist.IList([0]), + ilist.IList([1, 3]), + ilist.IList([1]), + [], + ), +] + +N = typing.TypeVar("N") + -def test_aom_move(): - spec_value = get_spec(10, 2) +@pytest.mark.parametrize( + "src_cols, src_rows, dst_cols, dst_rows, way_points", move_test_cases +) +def test_horizontal_move_impl( + src_cols: ilist.IList[int, N], + src_rows: ilist.IList[int, N], + dst_cols: ilist.IList[int, N], + dst_rows: ilist.IList[int, N], + way_points: list[grid.Grid[Any, Any]], +): + spec_value = get_spec(10, 2, spacing=10.0, gate_spacing=2.0) zone = spec_value.layout.static_traps["traps"] - qubit_init_x = ilist.IList([0, 2, 4, 6]) - qubit_init_y = ilist.IList([0]) - qubit_final_x = ilist.IList([1, 3, 5, 7]) - qubit_final_y = ilist.IList([1]) + args = (src_cols, src_rows, dst_cols, dst_rows) - device_fn = ArchSpecInterpreter( - dialects=move, arch_spec=(arch_spec := spec_value) - ).run( - get_device_fn, - ( - qubit_init_x, - qubit_init_y, - qubit_final_x, - qubit_final_y, - rearrange_impl_horizontal_vertical, - ), - ) - actions = TraceInterpreter(arch_spec=arch_spec).run_trace( - device_fn.move_fn, - (qubit_init_x, qubit_init_y, qubit_final_x, qubit_final_y), - kwargs={}, - ) - set_waypoint_init, turn_on, movement, turn_off, set_waypoint_end = actions + has_error = len(src_cols) != len(dst_cols) + ti = TraceInterpreter(spec_value) - start_pos = zone.get_view(qubit_init_x, qubit_init_y) - end_pos = zone.get_view(qubit_final_x, qubit_final_y) + if has_error: + with pytest.raises(AssertionError): + ti.run_trace(rearrange_impl_horizontal_vertical, args=args, kwargs={}) - first_pos = start_pos.shift(-3.0, 0.0) - second_pos = first_pos.shift(0.0, 7.0) - third_pos = first_pos.shift(5.0, 7.0) + return - expected_movement = taskgen.WayPointsAction( - [start_pos, first_pos, second_pos, third_pos, end_pos] + trace_results = ti.run_trace( + rearrange_impl_horizontal_vertical, args=args, kwargs={} ) - assert set_waypoint_init == taskgen.WayPointsAction([start_pos]) - assert set_waypoint_end == taskgen.WayPointsAction([end_pos]) - assert ( - isinstance(turn_on, taskgen.TurnOnXYSliceAction) - and turn_on.x_tone_indices == slice(None) - and turn_on.y_tone_indices == slice(None) - ) - assert ( - isinstance(turn_off, taskgen.TurnOffXYSliceAction) - and turn_off.x_tone_indices == slice(None) - and turn_off.y_tone_indices == slice(None) - ) - assert movement == expected_movement + start_pos = zone.get_view(src_cols, src_rows) + end_pos = zone.get_view(dst_cols, dst_rows) + + expected_movement = [start_pos] + way_points + [end_pos] + + expected_actions = [ + taskgen.WayPointsAction([start_pos]), + taskgen.TurnOnXYSliceAction(slice(None), slice(None)), + taskgen.WayPointsAction(expected_movement), + taskgen.TurnOffXYSliceAction(slice(None), slice(None)), + taskgen.WayPointsAction([end_pos]), + ] + + for a, e in itertools.zip_longest(trace_results, expected_actions): + assert a == e, f"Action {a} does not match expected {e}" From 5588401e2afbd1efac7771bd2f062d94cac9f709 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Tue, 7 Oct 2025 17:17:34 -0700 Subject: [PATCH 14/16] remove unuse function --- .../shuttle/stdlib/layouts/two_col_zone.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index 113c5682..652d1636 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -195,20 +195,3 @@ def rearrange( device_fn = schedule.device_fn(tweezer_kernal, x_tones, y_tones) device_fn(src_x, src_y, dst_x, dst_y) - - -# @move -# def get_device_fn( -# src_x: ilist.IList[int, NumX], -# src_y: ilist.IList[int, NumY], -# dst_x: ilist.IList[int, NumX], -# dst_y: ilist.IList[int, NumY], -# tweezer_kernal: ir.Method = rearrange_impl, -# ): -# if len(src_x) < 1 or len(dst_x) < 1: -# return - -# x_tones = ilist.range(len(src_x)) -# y_tones = ilist.range(len(src_y)) - -# return schedule.device_fn(tweezer_kernal, x_tones, y_tones) From 3de464fe02c5affbfdd74556f76df4946920610c Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Wed, 8 Oct 2025 13:16:06 -0700 Subject: [PATCH 15/16] add implementation and test for partial pickup --- .../shuttle/stdlib/layouts/two_col_zone.py | 185 ++++++++++++++++++ test/stdlib/two_col_zone/test_move.py | 101 ++++++++++ 2 files changed, 286 insertions(+) diff --git a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py index 652d1636..8520e9ab 100644 --- a/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py +++ b/src/bloqade/shuttle/stdlib/layouts/two_col_zone.py @@ -13,6 +13,7 @@ # Define type variables for generic programming NumX = TypeVar("NumX", bound=int) NumY = TypeVar("NumY", bound=int) +Num = TypeVar("Num", bound=int) def get_spec( @@ -179,6 +180,158 @@ def parking_y_end(index: int): action.turn_off(action.ALL, action.ALL) +@tweezer +def rearrange_impl_horizontal_vertical_multi_row( + src: ilist.IList[tuple[int, int], Num], + src_col: ilist.IList[int, Num], + src_row: ilist.IList[int, Num], + dst: ilist.IList[tuple[int, int], Num], + dst_col: ilist.IList[int, Num], + dst_row: ilist.IList[int, Num], +): + assert len(src_col) == len( + dst_col + ), "Source and destination col indices must have the same length." + assert len(src_row) == len( + dst_row + ), "Source and destination row indices must have the same length." + + assert_sorted(src_col) + assert_sorted(src_row) + assert_sorted(dst_col) + assert_sorted(dst_row) + + def push_list(row): + cols = [] + for loc in src: + if loc[1] == row: + cols = cols + [loc[0]] + return cols + + rows_to_columns = ilist.map(push_list, src_row) + + zone = spec.get_static_trap(zone_id="traps") + + start = grid.sub_grid(zone, src_col, src_row) + end = grid.sub_grid(zone, dst_col, dst_row) + + x_positions = grid.get_xpos(zone) + + def parking_y_end(index: int): + start_y = grid.get_ypos(start)[index] + end_y = grid.get_ypos(end)[index] + if start_y < end_y: + end_y = end_y - 3.0 + else: + end_y = end_y + 3.0 + + return end_y + + num_row = len(src_row) + + action.set_loc(start) + activated_cols = [] + + n_iter = 0 + for row in src_row: + # iteratively pick up qubits row by row + col_to_activate = [] + col_to_shift_back = [] + for col in rows_to_columns[row]: + if col in activated_cols: + # col is already activated, need to be shifted back + col_to_shift_back = col_to_shift_back + [col] + else: + # activate column + col_to_activate = col_to_activate + [col] + activated_cols = activated_cols + [col] + + # helper function + # the direction for x displacement is decided based on the left (index % 2 == 0) or right site (index % 2 == 1) + def parking_x(index: int): + if index in activated_cols: + return x_positions[index] + 3.0 * (2 * (index % 2) - 1) + else: + return x_positions[index] + + def reverse_parking_x(index: int): + if ( + index in col_to_shift_back + or index in col_to_activate + or index not in activated_cols + ): + return x_positions[index] + else: + return x_positions[index] + 3.0 * (2 * (index % 2) - 1) + + def reverse_parking_y(index: int): + # ? add this function because I don't have a way + # ? to pass extra argument in to the function + # ? In addtion, I try to update n_iter in the if block + # ? but the value is not updated correctly + start_y = grid.get_ypos(start)[index] + end_y = grid.get_ypos(end)[index] + if n_iter - 1 < index: + return start_y + elif start_y < end_y: + return start_y + 3.0 + else: + return start_y - 3.0 + + def parking_y_start(index: int): + start_y = grid.get_ypos(start)[index] + end_y = grid.get_ypos(end)[index] + if n_iter < index: + return start_y + elif start_y < end_y: + return start_y + 3.0 + else: + return start_y - 3.0 + + # shift column back if previously parked + if col_to_shift_back: + assert n_iter > 0 + reverse_parking = grid.from_positions( + ilist.map(reverse_parking_x, src_col), + ilist.map( + reverse_parking_y, + ilist.range(num_row), + ), + ) + action.move(reverse_parking) + + # activate new row and column + action.turn_on(col_to_activate, [row]) + + # park column and row + src_parking = grid.from_positions( + ilist.map(parking_x, src_col), + ilist.map(parking_y_start, ilist.range(num_row)), + ) + action.move(src_parking) + n_iter += 1 + + assert len(activated_cols) == len( + dst_col + ), "Number of activated columns does not match the number of source indices" + + # perform big horizontal and vertical move + parking_y = ilist.map(parking_y_end, ilist.range(num_row)) + + def parking_x(index: int): + return x_positions[index] + 3.0 * (2 * (index % 2) - 1) + + mid_pos_after_vertical_move = grid.from_positions( + ilist.map(parking_x, src_col), parking_y + ) + mid_pos_after_horizontal_move = grid.from_positions(grid.get_xpos(end), parking_y) + + action.move(mid_pos_after_vertical_move) + action.move(mid_pos_after_horizontal_move) + action.move(end) + action.turn_off(action.ALL, action.ALL) + + @move def rearrange( src_x: ilist.IList[int, NumX], @@ -195,3 +348,35 @@ def rearrange( device_fn = schedule.device_fn(tweezer_kernal, x_tones, y_tones) device_fn(src_x, src_y, dst_x, dst_y) + + +@move +def rearrange_partial_pickup( + src: ilist.IList[tuple[int, int], Num], + dst: ilist.IList[tuple[int, int], Num], + tweezer_kernal: ir.Method = rearrange_impl_horizontal_vertical_multi_row, +): + if len(src) < 1 or len(dst) < 1: + return + + src_col = [] + src_row = [] + for loc in src: + if loc[0] not in src_col: + src_col = src_col + [loc[0]] + if loc[1] not in src_row: + src_row = src_row + [loc[1]] + + dst_col = [] + dst_row = [] + for loc in dst: + if loc[0] not in dst_col: + dst_col = dst_col + [loc[0]] + if loc[1] not in dst_row: + dst_row = dst_row + [loc[1]] + + x_tones = ilist.range(len(src_col)) + y_tones = ilist.range(len(src_row)) + + device_fn = schedule.device_fn(tweezer_kernal, x_tones, y_tones) + device_fn(src, src_col, src_row, dst, dst_col, dst_row) diff --git a/test/stdlib/two_col_zone/test_move.py b/test/stdlib/two_col_zone/test_move.py index 1c7ee501..50bba059 100644 --- a/test/stdlib/two_col_zone/test_move.py +++ b/test/stdlib/two_col_zone/test_move.py @@ -10,6 +10,7 @@ from bloqade.shuttle.stdlib.layouts.two_col_zone import ( get_spec, rearrange_impl_horizontal_vertical, + rearrange_impl_horizontal_vertical_multi_row, ) move_test_cases = [ @@ -101,3 +102,103 @@ def test_horizontal_move_impl( for a, e in itertools.zip_longest(trace_results, expected_actions): assert a == e, f"Action {a} does not match expected {e}" + + +move_test_cases = [ + ( + ilist.IList([(0, 0), (0, 1), (1, 1), (2, 1)]), + ilist.IList([0, 1, 2]), + ilist.IList([0, 1]), + ilist.IList([(2, 2), (2, 3), (4, 3), (5, 3)]), + ilist.IList([2, 4, 5]), + ilist.IList([2, 3]), + [ + # taskgen.WayPointsAction( + # [ + # grid.Grid((2.0, 10.0), (10.0,), 0.0, 0.0), + # ] + # ), + taskgen.TurnOnXYSliceAction(slice(0, 1), slice(0, 1)), + taskgen.WayPointsAction( + [ + grid.Grid((2.0, 10.0), (10.0,), 0.0, 0.0), + grid.Grid((5.0, 10.0), (7.0,), -3.0, 3.0), + grid.Grid((2.0, 10.0), (7.0,), 0.0, 3.0), + ] + ), + taskgen.TurnOnXYSliceAction(slice(1, 3), slice(0, 1)), + taskgen.WayPointsAction( + [ + grid.Grid((2.0, 10.0), (7.0,), 0.0, 3.0), + grid.Grid((8.0, 4.0), (10.0,), -3.0, 3.0), + grid.Grid((8.0, 4.0), (10.0,), -3.0, 17.0), + grid.Grid((12.0, 2.0), (10.0,), 12.0, 17.0), + grid.Grid((12.0, 2.0), (10.0,), 12.0, 20.0), + ] + ), + taskgen.TurnOffXYSliceAction(slice(None), slice(None)), + # taskgen.WayPointsAction( + # [ + # grid.Grid((12.0, 2.0), (10.0,), 12.0, 20.0), + # ] + # ), + ], + ), + ( # error case + ilist.IList([(0, 0), (0, 1), (1, 1), (2, 1)]), + ilist.IList([0, 1, 2]), + ilist.IList([0, 1]), + ilist.IList([(2, 2)]), + ilist.IList([2]), + ilist.IList([2]), + [], + ), +] + +N = typing.TypeVar("N") + + +@pytest.mark.parametrize( + "src, src_cols, src_rows, dst, dst_cols, dst_rows, expected_actions", + move_test_cases, +) +def test_horizontal_move_multi_row_impl( + src: ilist.IList[tuple[int, int], N], + src_cols: ilist.IList[int, N], + src_rows: ilist.IList[int, N], + dst: ilist.IList[tuple[int, int], N], + dst_cols: ilist.IList[int, N], + dst_rows: ilist.IList[int, N], + expected_actions: list[Any], +): + spec_value = get_spec(10, 4, spacing=10.0, gate_spacing=2.0) + zone = spec_value.layout.static_traps["traps"] + + args = (src, src_cols, src_rows, dst, dst_cols, dst_rows) + + has_error = len(src) != len(dst) + ti = TraceInterpreter(spec_value) + + if has_error: + with pytest.raises(AssertionError): + ti.run_trace( + rearrange_impl_horizontal_vertical_multi_row, args=args, kwargs={} + ) + + return + + trace_results = ti.run_trace( + rearrange_impl_horizontal_vertical_multi_row, args=args, kwargs={} + ) + + start_pos = zone.get_view(src_cols, src_rows) + end_pos = zone.get_view(dst_cols, dst_rows) + + expected_actions = ( + [taskgen.WayPointsAction([start_pos])] + + expected_actions + + [taskgen.WayPointsAction([end_pos])] + ) + + for a, e in itertools.zip_longest(trace_results, expected_actions): + assert a == e, f"Action {a} does not match expected {e}" From dc6dc6ff55b97010ea922705c0a025092bc44259 Mon Sep 17 00:00:00 2001 From: WanHsuanLin Date: Wed, 8 Oct 2025 20:58:15 -0700 Subject: [PATCH 16/16] upd test --- test/stdlib/two_col_zone/test_move.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/test/stdlib/two_col_zone/test_move.py b/test/stdlib/two_col_zone/test_move.py index 50bba059..c040fc5f 100644 --- a/test/stdlib/two_col_zone/test_move.py +++ b/test/stdlib/two_col_zone/test_move.py @@ -113,12 +113,7 @@ def test_horizontal_move_impl( ilist.IList([2, 4, 5]), ilist.IList([2, 3]), [ - # taskgen.WayPointsAction( - # [ - # grid.Grid((2.0, 10.0), (10.0,), 0.0, 0.0), - # ] - # ), - taskgen.TurnOnXYSliceAction(slice(0, 1), slice(0, 1)), + taskgen.TurnOnXYAction(ilist.IList([0]), ilist.IList([0])), taskgen.WayPointsAction( [ grid.Grid((2.0, 10.0), (10.0,), 0.0, 0.0), @@ -126,7 +121,7 @@ def test_horizontal_move_impl( grid.Grid((2.0, 10.0), (7.0,), 0.0, 3.0), ] ), - taskgen.TurnOnXYSliceAction(slice(1, 3), slice(0, 1)), + taskgen.TurnOnXYAction(ilist.IList([1, 2]), ilist.IList([1])), taskgen.WayPointsAction( [ grid.Grid((2.0, 10.0), (7.0,), 0.0, 3.0), @@ -137,11 +132,6 @@ def test_horizontal_move_impl( ] ), taskgen.TurnOffXYSliceAction(slice(None), slice(None)), - # taskgen.WayPointsAction( - # [ - # grid.Grid((12.0, 2.0), (10.0,), 12.0, 20.0), - # ] - # ), ], ), ( # error case