{ "cells": [ { "cell_type": "markdown", "id": "dec6d056", "metadata": {}, "source": [ "# Qubit Reuse Compilation\n", "\n", "This notebook contains an overview of how to use the qubit reuse compilation as a hypertket pass. This capability applies a compilation strategy for reducing the number of qubits in a quantum circuit as detailed in [Qubit-reuse compilation with mid-circuit measurement and reset](https://journals.aps.org/prx/abstract/10.1103/PhysRevX.13.041057) by Matthew DeCross, Eli Chertkov, Megan Kohagen and Michael Foss-Feig.\n", "\n", "If you wish to cite this capability in any academic publications, we recommend citing our paper [Qubit-reuse compilation with mid-circuit measurement and reset](https://journals.aps.org/prx/abstract/10.1103/PhysRevX.13.041057)." ] }, { "cell_type": "markdown", "id": "ec689fb2", "metadata": {}, "source": [ "## Setup Nexus Project" ] }, { "cell_type": "markdown", "id": "1619b02f", "metadata": {}, "source": [ "Nexus enables access to H-Series. An existing project is activated, **Qubit-Reuse-Demonstration**." ] }, { "cell_type": "code", "execution_count": 1, "id": "8dd9a1f4", "metadata": {}, "outputs": [], "source": [ "import qnexus\n", "import uuid\n", "\n", "project = qnexus.projects.get_or_create(name=\"Qubit-Reuse-Demonstration\")\n", "qnexus.context.set_active_project(project)\n", "job_name_suffix = uuid.uuid1()" ] }, { "cell_type": "markdown", "id": "fe6efb46", "metadata": {}, "source": [ "The `QuantinuumConfig` is instantiated below to `backend_config` the `H2-Emulator`, an emulator instance of *System Model H2*, that is hosted on nexus." ] }, { "cell_type": "code", "execution_count": 2, "id": "ee43533e", "metadata": {}, "outputs": [], "source": [ "qntm_config = qnexus.QuantinuumConfig(device_name=\"H2-Emulator\")" ] }, { "cell_type": "markdown", "id": "6275e9b1", "metadata": {}, "source": [ "## Simple Example\n", "\n", "Most current techniques for circuit optimisation focus on reducing the number of gates in a circuit, often aiming to reduce the number of multi-qubit gates as they are known to be more error-prone. The prevailing logic is that a shorter circuit accumulates less noise and so provides better results. The compilation technique available in this repository instead focuses on reducing the number of qubits, or width, of a circuit. This can help turn a circuit that at first seems infeasible on small near-term devices into one that can be executed. A full explanation of the techniques available can be read in the paper [Qubit-reuse compilation with mid-circuit measurement and reset](https://journals.aps.org/prx/abstract/10.1103/PhysRevX.13.041057).\n", "\n", "Let's first consider how such a technique is possible via a basic example. An existing circuit is constructed and uploaded to nexus." ] }, { "cell_type": "code", "execution_count": 3, "id": "f257bc29", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "