diff --git a/2026/Bruno_minions/ETH_Hackathon_QuEra.pptx b/2026/Bruno_minions/ETH_Hackathon_QuEra.pptx new file mode 100644 index 0000000..19ba68a Binary files /dev/null and b/2026/Bruno_minions/ETH_Hackathon_QuEra.pptx differ diff --git a/2026/Bruno_minions/STAR_part.ipynb b/2026/Bruno_minions/STAR_part.ipynb new file mode 100644 index 0000000..d6bdc14 --- /dev/null +++ b/2026/Bruno_minions/STAR_part.ipynb @@ -0,0 +1,7820 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "55528cdd", + "metadata": {}, + "outputs": [], + "source": [ + "from typing import Any\n", + "import os\n", + "import re\n", + "\n", + "from kirin.ir import Method\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "from bloqade import squin, tsim\n", + "from bloqade.cirq_utils import emit_circuit, load_circuit, noise\n", + "from bloqade.pyqrack import StackMemorySimulator\n", + "from bloqade.types import MeasurementResult, Qubit\n", + "from kirin.dialects.ilist import IList\n", + "\n", + "# this will help us have return types for our methods that have more intuitive names\n", + "Register = IList[Qubit, Any]\n", + "Measurement = IList[MeasurementResult, Any]\n", + "\n", + "# this function will help us visualize some circuits\n", + "def show_circuit(squin_kernel):\n", + " @squin.kernel\n", + " def _to_visualize():\n", + " _ = squin_kernel()\n", + "\n", + " return tsim.Circuit(_to_visualize).diagram(height=400)" + ] + }, + { + "cell_type": "markdown", + "id": "98b73c39", + "metadata": {}, + "source": [ + "## **STAR team part**\n", + "\n", + "**PART 1:** A surface code is a type of quantum error-correcting stabilizer code. A \"distance-3\" ($d=3$) surface code is designed to reliably detect and correct any single physical error that occurs anywhere on the grid without the logical qubit failing. \n", + "\n", + "To build this logical processor, we use **17 physical qubits** arranged in a planar square lattice:\n", + "* **9 Data Qubits:** These hold the actual logical quantum state and are never measured directly during the computation cycle. \n", + "* **8 Ancilla (Measure) Qubits:** These act as \"watchdogs.\" They are interlaced with the data qubits and are continuously measured to extract error syndromes without destroying the underlying data.\n", + "\n", + "Geometry & Qubit Mapping\n", + "\n", + "To build the circuit in Tsim, we map the qubits across a 2D grid. The data qubits form a $3 \\times 3$ lattice, while the ancillas sit between them to measure \"plaquettes\" (groups of 2 or 4 adjacent data qubits). \n", + "\n", + "**Our 17-Qubit Map:**\n", + "* **Data (0-8):** Vertices of the grid.\n", + "* **Z-Ancillas (9-12):** Measure $Z$-parity.\n", + "* **X-Ancillas (13-16):** Measure $X$-parity.\n", + "\n", + "\n", + "**Stabilizer Checks (The X and Z Crosses)**\n", + "\n", + "We detect errors by measuring multi-qubit Pauli operators called \"stabilizers\". \n", + "\n", + "- Z-Stabilizers (Green Checks): These entangle a Z-ancilla with its neighboring data qubits. Measuring the Z-ancilla allows us to detect X (bit-flip) errors on those data qubits. \n", + "\n", + "- X-Stabilizers (Yellow Checks): These entangle an X-ancilla with its neighbors. Using a Hadamard gate to change the basis, measuring the X-ancilla allows us to detect Z (phase-flip) errors. \n", + "\n", + "**Syndrome Extraction Over Time**\n", + " \n", + "\n", + "A single round of measurements is not reliable because the measurement hardware itself might introduce errors. To achieve fault tolerance, we perform repeated syndrome extraction cycles. \n", + "\n", + "1. Initialize the ancillas.\n", + "\n", + "2. Entangle them with data qubits (using a strict CNOT schedule to avoid gate collisions).\n", + "\n", + "3. Measure the ancillas.\n", + "\n", + "4. Repeat.\n", + "\n", + "By running this circuit for several rounds, we track the errors over time, transforming the problem from a 2D spatial grid into a 3D volume (2D space + 1D time). Tracking these measurements over multiple rounds is essential to distinguish between genuine data qubit errors and faulty measurement events. In Tsim, \"Detectors\" compare the measurement of an ancilla in the current round to its measurement in the previous round—if the parity suddenly flips, the detector fires, indicating an error occurred in that specific time window." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "fc1c02bb", + "metadata": {}, + "outputs": [], + "source": [ + "from bloqade import squin, tsim\n", + "from bloqade.types import Qubit\n", + "from kirin.dialects.ilist import IList\n", + "from typing import Any\n", + "\n", + "Register = IList[Qubit, Any]\n", + "\n", + "@squin.kernel\n", + "def d3_surface_code() -> Register:\n", + " # Allocate all 17 physical qubits symmetrically:\n", + " data = squin.qalloc(9) # Indices 0-8\n", + " z_anc = squin.qalloc(4) # Indices 0-3\n", + " x_anc = squin.qalloc(4) # Indices 0-3\n", + " \n", + " # Execute 2 rounds of syndrome extraction\n", + " for r in range(2):\n", + " squin.broadcast.h(x_anc)\n", + " \n", + " # 4-layer CNOT Schedule\n", + " # Z-checks: Data is control, Ancilla is target\n", + " # X-checks: Ancilla is control, Data is target\n", + " \n", + " # Layer 1: North Interactions\n", + " squin.cx(data[0], z_anc[0]) \n", + " squin.cx(data[4], z_anc[3]) \n", + " squin.cx(data[2], z_anc[1])\n", + " squin.cx(x_anc[1], data[1])\n", + " squin.cx(x_anc[2], data[3])\n", + " squin.cx(x_anc[3], data[7])\n", + " \n", + " # Layer 2: East Interactions\n", + " squin.cx(data[1], z_anc[0])\n", + " squin.cx(data[3], z_anc[2])\n", + " squin.cx(data[5], z_anc[3])\n", + " squin.cx(x_anc[1], data[2])\n", + " squin.cx(x_anc[2], data[4])\n", + " squin.cx(x_anc[3], data[8])\n", + " \n", + " # Layer 3: West Interactions\n", + " squin.cx(data[3], z_anc[0])\n", + " squin.cx(data[7], z_anc[3])\n", + " squin.cx(data[5], z_anc[1])\n", + " squin.cx(x_anc[2], data[6])\n", + " squin.cx(x_anc[1], data[4])\n", + " squin.cx(x_anc[0], data[0])\n", + " \n", + " # Layer 4: South Interactions\n", + " squin.cx(data[4], z_anc[0])\n", + " squin.cx(data[6], z_anc[2])\n", + " squin.cx(data[8], z_anc[3])\n", + " squin.cx(x_anc[0], data[1])\n", + " squin.cx(x_anc[2], data[7])\n", + " squin.cx(x_anc[1], data[5])\n", + " \n", + " squin.broadcast.h(x_anc)\n", + " \n", + " # Mid-circuit measurement of the watchdogs\n", + " squin.broadcast.measure(z_anc)\n", + " squin.broadcast.measure(x_anc)\n", + "\n", + " # Reset ancillas\n", + " squin.broadcast.reset(z_anc)\n", + " squin.broadcast.reset(x_anc)\n", + "\n", + " # Check if there are errors:\n", + " if r == 0: squin.x(data[4])\n", + " \n", + " return data" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "1fcb1755", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "