Skip to content
Empty file added notebooks/bloqade_shuttle.ipynb
Empty file.
178 changes: 178 additions & 0 deletions notebooks/circuit_noise.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ef56ea11",
"metadata": {},
"source": [
"# Evaluating circuit-level performance"
]
},
{
"cell_type": "markdown",
"id": "1789346a",
"metadata": {},
"source": [
"# Zoned archetectures, Gemini noise models\n",
"Describe our noise model (cross reference the Gemini benchmarking paper)\n",
"\n",
"“Hello Gemini” level hardware description. Native gate sets; parallelism; atom moving; loss.\n",
"\n",
"Describe our strategy for noise modeling: Pauli channels plus atom loss"
]
},
{
"cell_type": "markdown",
"id": "43e70f6c",
"metadata": {},
"source": [
"Canonical circuit we will use for this example: Trotterization of 1d Ising."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1805a747",
"metadata": {},
"outputs": [],
"source": [
"import bloqade\n",
"import bloqade.squin\n",
"import kirin\n",
"\n",
"@bloqade.squin.kernel\n",
"def bloqade_trotter(qubits:list[bloqade.squin.qubit], steps:int, dt:float = 0.01, J:float = 1, h:float = 1):\n",
" \"\"\"\n",
" Main function that runs the Trotter circuit for a given number of steps\n",
" \"\"\"\n",
" for _ in range(steps):\n",
" zz = bloqade.squin.op.zzpow(dt * J)\n",
" x = bloqade.squin.op.xpow(dt * h)\n",
" for i in range(0, len(qubits) - 1, 2):\n",
" bloqade.squin.op.apply(zz, qubits[i], qubits[i + 1])\n",
" for i in range(1, len(qubits) - 1, 2):\n",
" bloqade.squin.op.apply(zz, qubits[i], qubits[i + 1])\n",
" for i in range(0, len(qubits)):\n",
" bloqade.squin.op.apply(x, qubits[i])\n",
"\n",
"def trotter_builder(nqubits:int,\n",
" steps:int = 100,\n",
" dt:float = 0.01,\n",
" J:float = 1,\n",
" h:float = 1)-> kirin.ir.Kernel:\n",
" \"\"\"\n",
" Builder function to create a Trotter circuit with the specified parameters.\n",
" \n",
" Inputs:\n",
" nqubits: Number of qubits in the circuit.\n",
" steps: Number of Trotter steps to perform.\n",
" dt: Time step for the Trotter evolution.\n",
" J: Coupling strength for the ZZ interaction.\n",
" h: Strength of the X field.\n",
" Returns:\n",
" A kernel function with no inputs and returns the qubits after the Trotter evolution.\n",
" \"\"\"\n",
" def main():\n",
" qubits = bloqade.squin.qubit.create(nqubits)\n",
" bloqade_trotter(qubits, steps, dt, J, h)\n",
" return qubits\n",
" \n",
" # Enforce the CZ + XYphase structure with a compiler pass\n",
" main2 = bloqade.squin.passes.CZGateSet()(main)\n",
" \n",
" return main2"
]
},
{
"cell_type": "markdown",
"id": "7917fe68",
"metadata": {},
"source": [
"Now that we have specified the circuit, we can start doing analysis...\n",
"\n",
"Simplest analysis: counting the number of gates and estimating a utility function"
]
},
{
"cell_type": "markdown",
"id": "e53c136d",
"metadata": {},
"source": [
"## Log fidelity analysis\n",
"Count the number of gates; log fidelity is simply a weighted sum/dot product."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d2a415c7",
"metadata": {},
"outputs": [],
"source": [
"# Only works with no mid-circuit feed-forward? Optionally, run statevector evolution\n",
"# and sample from the distribution to get a monte carlo estimate of the counting.\n",
"noise_interpreter = bloqade.circuit.interpreters.noise_counting()\n",
"\n",
"report = noise_interpreter.run(trotter_builder(10, steps=10, dt=0.01, J=1, h=1))\n",
"report.print()\n",
"# Number of qubits: 10\n",
"# Number of 2 qubit gates: 90\n",
"# Number of 1 qubit gates: 100\n",
"# Number of touches: 50\n",
"# Number of moves: 10\n",
"\n",
"error_model = bloqade.circuit.GeminiErrorModel(scale = 0.7)\n",
"log_fidelity:float = report.log_fidelity(error_model)\n",
"print(f\"Log fidelity: {log_fidelity:.3f}\")\n",
"# Log fidelity: -1.234"
]
},
{
"cell_type": "markdown",
"id": "456f758e",
"metadata": {},
"source": [
"## Noise annotation in Cirq"
]
},
{
"cell_type": "markdown",
"id": "d15f4bb1",
"metadata": {},
"source": [
"Reproduce and reference [cirq_tools](https://github.com/QuEraComputing/cirq_tools/)"
]
},
{
"cell_type": "markdown",
"id": "953e9567",
"metadata": {},
"source": [
"## Noise annotation in Bloqade"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "462c2ab8",
"metadata": {},
"outputs": [],
"source": [
"raise NotImplementedError(\"We cannot do noise simulation with bloqade\")"
]
},
{
"cell_type": "markdown",
"id": "edd4adbd",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading