{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "295b5202", "metadata": {}, "source": [ "# QSCOUT Optimizations with Cirq" ] }, { "attachments": {}, "cell_type": "markdown", "id": "stone-aerospace", "metadata": {}, "source": [ "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Infleqtion/client-superstaq/blob/main/docs/source/optimizations/qscout/qscout_css.ipynb) [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Infleqtion/client-superstaq/HEAD?labpath=docs/source/optimizations/qscout/qscout_css.ipynb)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "related-museum", "metadata": {}, "source": [ "Below is a brief tutorial on Superstaq optimizations for Quantum Scientific Computing Open User Testbed (QSCOUT), a trapped ion quantum computing testbed at Sandia National Laboratories. For more information on QSCOUT, visit their website [here](https://www.sandia.gov/quantum/quantum-information-sciences/projects/qscout/)." ] }, { "attachments": {}, "cell_type": "markdown", "id": "8c861954", "metadata": {}, "source": [ "## Imports and API Token\n", "\n", "This example tutorial notebook uses `cirq-superstaq`, our Superstaq client for Cirq; you can try it out by running `pip install cirq-superstaq`:" ] }, { "cell_type": "code", "execution_count": 1, "id": "af13cd74", "metadata": {}, "outputs": [], "source": [ "# Required imports\n", "try:\n", " import cirq_superstaq as css\n", "except ImportError:\n", " print(\"Installing cirq-superstaq...\")\n", " %pip install --quiet 'cirq-superstaq[examples]'\n", " print(\"Installed cirq-superstaq.\")\n", " print(\"You may need to restart the kernel to import newly installed packages.\")\n", " import cirq_superstaq as css\n", "\n", "import random\n", "\n", "import cirq\n", "import numpy as np" ] }, { "attachments": {}, "cell_type": "markdown", "id": "5ce5dfc5", "metadata": {}, "source": [ "To interface Superstaq via Cirq, we must first instantiate a service provider in `cirq-superstaq` with `Service()`. We then supply a Superstaq API token (or key) by either providing the API token as an argument of `css.Service()` or by setting it as an environment variable (see more details [here](https://superstaq.readthedocs.io/en/latest/get_started/basics/basics_css.html#Set-up-access-to-Superstaq%E2%80%99s-API))." ] }, { "cell_type": "code", "execution_count": 2, "id": "b4cd3b9b", "metadata": {}, "outputs": [], "source": [ "# Get cirq superstaq service for Superstaq backend\n", "service = css.Service()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "dcc8201d", "metadata": {}, "source": [ "## Single Circuit Compilation\n", "\n", "Let us start by creating an example cirq circuit that we will then compile and optimize for the QSCOUT trapped-ion testbed at Sandia National Laboratories." ] }, { "cell_type": "code", "execution_count": 3, "id": "76b4c436", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───@────────────────@───M───\n", " │ │ │\n", "1: ───X───Rz(0.672π)───X───M───\n" ] } ], "source": [ "# Create a two-qubit cirq circuit\n", "rng = np.random.default_rng(random.getrandbits(128))\n", "theta = rng.uniform(0, 4 * np.pi)\n", "qubits = cirq.LineQubit.range(2)\n", "circuit1 = cirq.Circuit(\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.rz(theta).on(qubits[1]),\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.measure(qubits[0], qubits[1]),\n", ")\n", "\n", "# Draw circuit for visualization\n", "print(circuit1)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1bdb0a4d", "metadata": {}, "source": [ "Using the same circuit from above as input, we will now compile it for QSCOUT and visualize the differences by printing the compiled circuit. " ] }, { "cell_type": "code", "execution_count": 4, "id": "6ccdb44d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───PhX(-0.5)^0.5───Z───MS(-0.164π)───PhX(-0.5)^0.5───│───M───\n", " │ │ │\n", "1: ───PhX(-0.5)^0.5───Z───MS(-0.164π)───PhX(-0.5)^0.5───│───M───\n" ] } ], "source": [ "# Compile with qscout compile\n", "compiler_output = service.qscout_compile(circuit1)\n", "\n", "# Call circuit from the compiler output to get the corresponding output circuit\n", "output_circuit = compiler_output.circuit\n", "\n", "# Visualize the compiled circuit\n", "print(compiler_output.circuit)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "7ae21f23", "metadata": {}, "source": [ "The resulting output is now a circuit compiled and optimized to QSCOUT's native operations. But there's more! With Superstaq's compilation, users can also get the corresponding Jaqal (see [Just another quantum assembly language](https://arxiv.org/abs/2008.08042)) program for their compiled circuit. The Jaqal program is a useful representation that highlights the sequence of pulse level single and two-qubit gates that have to be executed on the trapped ions to realize the user's circuit. To view the jaqal program, users simply have to call `jaqal_program` on their `compiler_output`, and print to list it in a readable format. " ] }, { "cell_type": "code", "execution_count": 5, "id": "901dfd9d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "from qscout.v1.std usepulses *\n", "\n", "register allqubits[2]\n", "\n", "prepare_all\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "<\n", "\tRz allqubits[0] -3.141592653589793\n", "\tRz allqubits[1] -3.141592653589793\n", ">\n", "MS allqubits[0] allqubits[1] 0 -1.0310687190367105\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "measure_all\n", "\n" ] } ], "source": [ "# Get jaqal program\n", "print(compiler_output.jaqal_program)" ] }, { "cell_type": "markdown", "id": "d122d0bf", "metadata": {}, "source": [ "Breaking down the printed Jaqal program, we see that we begin a 2-qubit quantum register with **allqubits[2]** in correspondance to our 2-qubit circuit. The **prepare_all** command prepares the state of all the qubits in the register in the $z$ basis as the standard. Next, the program describes the pulse-level gates to be used following the format outlined and described [here](https://www.sandia.gov/quantum/quantum-information-sciences/projects/qscout-jaqal/). For a quick reference, here is a brief description of the pulse-level gates and operations that are used in a Jaqal program: \n", "\n", "- **R** ` ` : Performs a counter-clockwise rotation around an axis in the equatorial plane of the Bloch sphere defined by `` , measured counter-clockwise from the $x$ axis, by the angle defined by ``.\n", "- **Rx** ` ` : Performs a counter-clockwise rotation around the $x$ axis, by the angle defined by ``.\n", "- **Ry** ` ` : Performs a counter-clockwise rotation around the $y$ axis, by the angle defined by ``.\n", "- **Rz** ` ` : Performs a counter-clockwise rotation around the $z$ axis, by the angle defined by ``.\n", "- **Px** `` : Performs a counter-clockwise rotation around the $x$ axis, by $\\pi$. In other words, a Pauli $X$ gate.\n", "- **Py** `>` : Performs a counter-clockwise rotation around the $y$ axis, by $\\pi$. In other words, Pauli $Y$ gate.\n", "- **Pz** `` : Performs a counter-clockwise rotation around the $z$ axis, by $\\pi$. In other words, Pauli $Z$ gate.\n", "- **Sx** `` : Performs a counter-clockwise rotation around the $x$ axis, by $\\pi/2$. This results in a $\\sqrt{X}$ gate.\n", "- **Sy** `` : Performs a counter-clockwise rotation around the $y$ axis, by $\\pi/2$. This results in a $\\sqrt{Y}$ gate.\n", "- **Sz** `` : Performs a counter-clockwise rotation around the $z$ axis, by $\\pi/2$. This results in a $\\sqrt{Z}$ gate.\n", "- **Sxd** `` : Performs a clockwise rotation around the $x$ axis, by $\\pi/2$. That is, a $\\sqrt{X}^\\dagger$ gate.\n", "- **Syd** `` : Performs a clockwise rotation around the $y$ axis, by $\\pi/2$. That is, a $\\sqrt{Y}^\\dagger$ gate.\n", "- **Szd** `` : Performs a clockwise rotation around the $z$ axis, by $\\pi/2$. That is, a $\\sqrt{Z}^\\dagger$ gate.\n", "- **MS** ` ` : This is the general two-qubit Mølmer–Sørensen gate used for entanglement. Supposing that $\\theta$ and $\\varphi$ represent the `` and `` respectively, the general MS gate is given by, $$\\exp\\left(-i\\left(\\frac{\\theta}{2}\\right)(\\cos \\varphi X + \\sin \\varphi Y)^{\\otimes 2}\\right).$$\n", "- **Sxx** ` ` : This is the XX version of two-qubit Mølmer–Sørensen gate, $$\\exp \\left(-i\\left(\\frac{\\pi}{4}\\right) X\\otimes X\\right).$$\n", "- **measure_all** : Command to measure all qubits of the quantum register in the $z$ basis. \n", "\n", "The Jaqal program output is also very useful is showcasing when multiple gates are combined into a single gate block for execution -- or in the case of parallel gate blocks -- executed at the same time. These gate blocks are marked by the angle brakets like so,\n", "```\n", "<\n", " // Parallel gates\n", ">\n", "```\n", "providing the user more valuable context between the device execution and the original circuit representation. Further details on the verstaility of the Jaqal program can be found at this [reference](https://www.sandia.gov/quantum/quantum-information-sciences/projects/qscout-jaqal/)." ] }, { "attachments": {}, "cell_type": "markdown", "id": "af41c8b6", "metadata": {}, "source": [ "## Multiple Circuits Compilation\n", "\n", "All the functionalities we have seen so far can also be used on a multiple circuits input as well. To illustrate this, let us create a different, example two-qubit circuit (say, a Bell-state circuit):" ] }, { "cell_type": "code", "execution_count": 6, "id": "9dc38d6a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───H───@───M───\n", " │ │\n", "1: ───────X───M───\n" ] } ], "source": [ "# Create second circuit\n", "qubits = cirq.LineQubit.range(2)\n", "circuit2 = cirq.Circuit(\n", " cirq.H(qubits[0]),\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.measure(qubits[0], qubits[1]),\n", ")\n", "\n", "# Printing second circuit for visualization\n", "print(circuit2)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "279d5dca", "metadata": {}, "source": [ "By passing multiple circuits as a list to the `qscout_compile` endpoint, we can compile all of them individually with a single call to `qscout_compile`. This will return all the corresponding compiled circuits as a list, like so: " ] }, { "cell_type": "code", "execution_count": 7, "id": "0d317286", "metadata": {}, "outputs": [], "source": [ "# Create list of circuits\n", "circuit_list = [circuit1, circuit2]\n", "\n", "# Compile a list of circuits\n", "compiler_output_list = service.qscout_compile(circuit_list)" ] }, { "cell_type": "code", "execution_count": 8, "id": "31276b76", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Compiled circuit 1:\n", "\n", "0: ───PhX(-0.5)^0.5───Z───MS(-0.164π)───PhX(-0.5)^0.5───│───M───\n", " │ │ │\n", "1: ───PhX(-0.5)^0.5───Z───MS(-0.164π)───PhX(-0.5)^0.5───│───M───\n", "----------------------------------------------------------------- \n", "\n", "Compiled circuit 2:\n", "\n", "0: ───PhX(1)───MS(0.25π)───PhX(-0.5)^0.5───│───M───\n", " │ │ │\n", "1: ───PhX(1)───MS(0.25π)───PhX(0)^0.5──────│───M───\n" ] } ], "source": [ "# To get the list of compiled output circuits from the compiler output list, call `circuits` instead of just `circuit` as would be called for a single circuit input\n", "print(\"Compiled circuit 1:\\n\")\n", "print(compiler_output_list.circuits[0])\n", "print(\"-\" * 65, \"\\n\")\n", "print(\"Compiled circuit 2:\\n\")\n", "print(compiler_output_list.circuits[1])" ] }, { "cell_type": "markdown", "id": "31875122-c557-4cca-a76e-ce30ded6e77c", "metadata": {}, "source": [ "The corresponding Jaqal programs are still accessible via the `.jaqal_program` attribute, which will now contain multiple subcircuits sandwiched between a pair of \"prepare_all\" and \"measure_all\" operations:" ] }, { "cell_type": "code", "execution_count": 9, "id": "0175cf50-0d9a-4e74-904e-b42e28b91921", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "from qscout.v1.std usepulses *\n", "\n", "register allqubits[2]\n", "\n", "prepare_all\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "<\n", "\tRz allqubits[0] -3.141592653589793\n", "\tRz allqubits[1] -3.141592653589793\n", ">\n", "MS allqubits[0] allqubits[1] 0 -1.0310687190367105\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "measure_all\n", "\n", "prepare_all\n", "<\n", "\tR allqubits[0] 3.141592653589793 3.141592653589793\n", "\tR allqubits[1] 3.141592653589793 3.141592653589793\n", ">\n", "Sxx allqubits[0] allqubits[1]\n", "<\n", "\tR allqubits[0] -1.5707963267948972 1.5707963267948966\n", "\tR allqubits[1] 0.0 1.570796326794898\n", ">\n", "measure_all\n", "\n" ] } ], "source": [ "print(compiler_output_list.jaqal_program)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1d50dcd1", "metadata": {}, "source": [ "## Entangling Basis Compilation\n", "\n", "When compiling to the QSCOUT gateset, we can also specify the type of entangling basis gate to utilize during the compilation -- either a $XX$ or $ZZ$. Let's consider the first circuit example for earlier but with a different, random $R_Z$ angle and single measurement:" ] }, { "cell_type": "code", "execution_count": 10, "id": "7b6affee", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───@────────────────@───M───\n", " │ │ │\n", "1: ───X───Rz(-0.44π)───X───M───\n" ] } ], "source": [ "# Create circuit\n", "theta = rng.uniform(0, 4 * np.pi)\n", "qubits = cirq.LineQubit.range(2)\n", "circuit = cirq.Circuit(\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.rz(theta).on(qubits[1]),\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.measure(qubits[0], qubits[1]),\n", ")\n", "\n", "# Print circuit for visualization\n", "print(circuit)" ] }, { "cell_type": "code", "execution_count": 11, "id": "686c40ca", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "---------------------------------------------------------------------- \n", "\n", "from qscout.v1.std usepulses *\n", "\n", "register allqubits[2]\n", "\n", "prepare_all\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "<\n", "\tRz allqubits[0] -3.141592653589793\n", "\tRz allqubits[1] -3.141592653589793\n", ">\n", "MS allqubits[0] allqubits[1] 0 -1.3817761775080304\n", "<\n", "\tR allqubits[0] -1.5707963267948966 1.5707963267948966\n", "\tR allqubits[1] -1.5707963267948966 1.5707963267948966\n", ">\n", "measure_all\n", "\n", "---------------------------------------------------------------------- \n", "\n", "0: ───PhX(-0.5)^0.5───Z───MS(-0.22π)───PhX(-0.5)^0.5───│───M───\n", " │ │ │\n", "1: ───PhX(-0.5)^0.5───Z───MS(-0.22π)───PhX(-0.5)^0.5───│───M───\n" ] } ], "source": [ "# Compile with XX entangling basis\n", "compiler_output = service.qscout_compile(circuit, base_entangling_gate=\"xx\")\n", "\n", "# Visualize and get jaqal program of the compiled circuit\n", "print(\"-\" * 70, \"\\n\")\n", "print(compiler_output.jaqal_program)\n", "print(\"-\" * 70, \"\\n\")\n", "print(compiler_output.circuit)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "2c7855be", "metadata": {}, "source": [ "As we can see above, we get the same compiled gate structure as before. This is because, by default, the $XX$ interaction is used, and we observe that it uses an $MS$ gate as the base entangling gate in the compiled circuit. Similarly, let's take a look at the compiled circuit if we now specify the compiler to use the $ZZ$ interaction instead:" ] }, { "cell_type": "code", "execution_count": 12, "id": "03b5a411", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "---------------------------------------------------------------------- \n", "\n", "from qscout.v1.std usepulses *\n", "\n", "register allqubits[2]\n", "\n", "prepare_all\n", "ZZ allqubits[0] allqubits[1] -1.3817761775080304\n", "measure_all\n", "\n", "---------------------------------------------------------------------- \n", "\n", "0: ───ZZ─────────│───M───\n", " │ │ │\n", "1: ───ZZ^-0.44───│───M───\n" ] } ], "source": [ "# Compile with zz entangling basis\n", "compiler_output = service.qscout_compile(circuit, base_entangling_gate=\"zz\")\n", "\n", "# Get jaqal program and print circuit\n", "print(\"-\" * 70, \"\\n\")\n", "print(compiler_output.jaqal_program)\n", "print(\"-\" * 70, \"\\n\")\n", "print(compiler_output.circuit)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "82fd9743", "metadata": {}, "source": [ "Looking at the compiled circuit above, we can see that by specifying the $ZZ$ entangling basis, we use $R_{ZZ}$ gate as the base entangling gate and the remaining single-qubit gates are compiled and optimized accordingly. " ] }, { "attachments": {}, "cell_type": "markdown", "id": "3df7bb28", "metadata": {}, "source": [ "## Swap Mirroring\n", "\n", "In addition to specifying the type of base entangling gate to use for the compilation and optimization, we can also specify whether to use swap mirroring to help reduce the two-qubit gate overhead of the circuit. By default, it is not enabled; but we will see the differences in circuit compilation by compiling to a random quantum volume model circuit. You can learn more about quantum volume and randomized circuits [here](https://arxiv.org/abs/1811.12926)." ] }, { "attachments": {}, "cell_type": "markdown", "id": "a3bf3246", "metadata": {}, "source": [ "### Create random Quantum Volume (QV) circuit" ] }, { "cell_type": "code", "execution_count": 13, "id": "af253d10", "metadata": {}, "outputs": [], "source": [ "from cirq.contrib import quantum_volume" ] }, { "cell_type": "code", "execution_count": 14, "id": "9cc395bf", "metadata": {}, "outputs": [], "source": [ "# Generate a random QV circuit\n", "circ = quantum_volume.generate_model_circuit(\n", " num_qubits=2, depth=2, random_state=np.random.RandomState(seed=123)\n", ")\n", "circ.append([cirq.measure(*cirq.LineQubit.range(2))])" ] }, { "attachments": {}, "cell_type": "markdown", "id": "551650d1", "metadata": {}, "source": [ "### Compile without swap mirroring" ] }, { "cell_type": "code", "execution_count": 15, "id": "90e10bf6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───PhX(-0.548)^0.918───ZZ──────────PhX(-0.184)^0.5───ZZ───────────PhX(0.316)^0.5────ZZ─────────PhX(0.385)^0.775──────│───M───\n", " │ │ │ │ │\n", "1: ───PhX(0.408)^0.551────ZZ^-0.476───PhX(-0.702)^0.5───ZZ^(-4/13)───PhX(-0.202)^0.5───ZZ^0.052───PhX(-0.259)^(11/16)───│───M───\n" ] } ], "source": [ "# Compile with no swap mirroring\n", "output_nsm = service.qscout_compile(circ, mirror_swaps=False, base_entangling_gate=\"zz\")\n", "\n", "# Visualize the circuit\n", "circ_nsm = output_nsm.circuit\n", "print(circ_nsm)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "fa10c4af", "metadata": {}, "source": [ "### Compile with swap mirroring" ] }, { "cell_type": "code", "execution_count": 16, "id": "6b6be06f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: ───PhX(-0.409)^0.426────ZZ──────────PhX(0.0567)^0.5───ZZ──────────PhX(0.557)^0.5───ZZ──────────PhX(-0.254)^0.547───│───M────────────────\n", " │ │ │ │ │\n", "1: ───PhX(-0.0731)^0.391───ZZ^-0.448───PhX(-0.128)^0.5───ZZ^-0.193───PhX(0.372)^0.5───ZZ^-0.024───PhX(0.094)^0.544────│───M('q(0),q(1)')───\n" ] } ], "source": [ "# Compile with swap mirroring\n", "output_wsm = service.qscout_compile(circ, mirror_swaps=True, base_entangling_gate=\"zz\")\n", "\n", "# Visualize the circuit\n", "circ_wsm = output_wsm.circuit\n", "print(circ_wsm)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "29a03d84", "metadata": {}, "source": [ "With the use of swap mirroring, we note that the angle of the entangling gate has now been reduced and the classical bits associated with each measurement have now been swapped in the compiled circuit. This is also displayed with the measurement indices in the above compiled circuit compared to the previous compiled circuit that does not have swap mirroring enabled." ] }, { "attachments": {}, "cell_type": "markdown", "id": "028a48bd", "metadata": {}, "source": [ "### Return final logical to physical qubit mapping" ] }, { "cell_type": "code", "execution_count": 17, "id": "ba0a3966", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Non swap-mirrored mapping: {cirq.LineQubit(0): cirq.LineQubit(0), cirq.LineQubit(1): cirq.LineQubit(1)}\n", "Swap-mirrored mapping: {cirq.LineQubit(0): cirq.LineQubit(1), cirq.LineQubit(1): cirq.LineQubit(0)}\n" ] } ], "source": [ "# Return final qubit map for non swap-mirrored circuit\n", "map_nsm = output_nsm.final_logical_to_physical\n", "print(\"Non swap-mirrored mapping:\", map_nsm)\n", "\n", "# Return final qubit map for swap-mirrored circuit\n", "map_wsm = output_wsm.final_logical_to_physical\n", "print(\"Swap-mirrored mapping:\", map_wsm)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "742089ac", "metadata": {}, "source": [ "## Using the Superstaq Simulator\n", "\n", "Lastly, we will go over how to submit a circuit to a backend and simulate it. This feature is available to free trial users, and can be done by passing the `\"dry-run\"` method parameter when calling `create_job()` to instruct Superstaq to ideally sample the circuit. " ] }, { "cell_type": "code", "execution_count": 18, "id": "4f1b9455", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'00': 50, '11': 50}\n" ] } ], "source": [ "# Example Bell state circuit\n", "qubits = cirq.LineQubit.range(2)\n", "qc = cirq.Circuit(\n", " cirq.H(qubits[0]),\n", " cirq.CX(qubits[0], qubits[1]),\n", " cirq.measure(qubits[0], qubits[1]),\n", ")\n", "\n", "# Specify qscout target to service\n", "job = service.create_job(\n", " qc, repetitions=100, target=\"qscout_peregrine_qpu\", method=\"dry-run\"\n", ") # Specify \"dry-run\" as the method to run Superstaq simulation\n", "\n", "# Get the counts from the measurement\n", "print(job.counts(0))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.9" } }, "nbformat": 4, "nbformat_minor": 5 }