qiskit-qubit-reuse


Nameqiskit-qubit-reuse JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryA Qiskit's compiler plugin to reuse qubits using midcircuit measurement
upload_time2024-02-05 16:17:24
maintainer
docs_urlNone
authorRaynel Sanchez and Danielle Odigie
requires_python>=3.8
licenseApache 2.0
keywords qiskit sdk quantum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Qubit Reuse By Reset Plugin

This repository contains an experimental transpiler pass called `qubit_reuse` which is executed at the end of the `init` stage of transpilation. This pass is based on: Matthew DeCross et al. "Qubit-reuse compilation with mid-circuit measurement and reset" [arXiv:2210.0.08039v1](https://arxiv.org/abs/2210.08039v1)

### Background

Certain circuits can reduce the number of qubits required to produce results by resetting and re-using existent measured qubits. The order in which certain qubits are chosen is based on their **causal cones** and the order in which they are measured.

#### Causal Cones

Let's say we have qubit a x in a `DAGCircuit`. We can traverse the `DAGCircuit` from the output node of x by checking all its predecessor nodes. When checking every operation node found, if at any point x interacts with other qubits, via a multi-qubit gate, the qubits in that operation are added to a set. From that point we continue evaluating recursively all the predecessor nodes in that multi-qubit interaction and adding all qubits found into the set, until no more predecessor nodes are left. 

When the traversal ends, the set will contain **all the qubits whose interactions affect qubit x**. That is what we call the causal cone of x.

#### Order of Measurement

Qubits are re-arranged based on the length of their causal cones in ascending order, i.e. the first to be re-arranged are those with smaller causal cones. 

Before re-arranging a qubit, we need to check if there are any qubit that have been measured and is available to re-use. If so, we reset it and apply all operations onto its wire. Otherwise, a new qubit is added and the operations are passed on to that wire.

## Installation

This package is not available through pypi, but can be installed by cloning this repository:

```zsh
git clone https://github.com/qiskit-community/qiskit-qubit-reuse
```
And then installing locally:

```zsh
pip install ./qiskit-qubit-reuse
```
If you have the proper authentication keys, you can install it remotely by using:

```zsh
pip install git+https://github.com/qiskit-community/qiskit-qubit-reuse
```

## Usage

Once installed, Qiskit is able to detect the `qubit_reuse` plugin via an entry point. All that needs to be done is to specify the init method in your `transpile` call by using `init_method="qubit_reuse"`. Use the following example:

```py3
from qiskit.circuit.random import random_circuit
from qiskit import transpile
from qiskit.providers.fake_provider import FakeGuadalupeV2

qc = random_circuit(16, 4, measure=True)

transpiled_qc = transpile(qc, backend=FakeGuadalupeV2(), init_method="qubit_reuse")
```

This entry point provides the option with the least amount of qubits. If you want to specifically use the normal or dual circuit, you can specifcy that by using the `qubit_reuse_normal` or the `qubit_reuse_dual` endpoints.

**Warning: This plugin should only be used with circuits that contain measurements.**

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "qiskit-qubit-reuse",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "qiskit sdk quantum",
    "author": "Raynel Sanchez and Danielle Odigie",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/37/f3/aa061998ef302ee837f27de81659460f6d5b263b60528a95107b04c349ce/qiskit-qubit-reuse-0.0.2.tar.gz",
    "platform": null,
    "description": "# Qubit Reuse By Reset Plugin\n\nThis repository contains an experimental transpiler pass called `qubit_reuse` which is executed at the end of the `init` stage of transpilation. This pass is based on: Matthew DeCross et al. \"Qubit-reuse compilation with mid-circuit measurement and reset\" [arXiv:2210.0.08039v1](https://arxiv.org/abs/2210.08039v1)\n\n### Background\n\nCertain circuits can reduce the number of qubits required to produce results by resetting and re-using existent measured qubits. The order in which certain qubits are chosen is based on their **causal cones** and the order in which they are measured.\n\n#### Causal Cones\n\nLet's say we have qubit a x in a `DAGCircuit`. We can traverse the `DAGCircuit` from the output node of x by checking all its predecessor nodes. When checking every operation node found, if at any point x interacts with other qubits, via a multi-qubit gate, the qubits in that operation are added to a set. From that point we continue evaluating recursively all the predecessor nodes in that multi-qubit interaction and adding all qubits found into the set, until no more predecessor nodes are left. \n\nWhen the traversal ends, the set will contain **all the qubits whose interactions affect qubit x**. That is what we call the causal cone of x.\n\n#### Order of Measurement\n\nQubits are re-arranged based on the length of their causal cones in ascending order, i.e. the first to be re-arranged are those with smaller causal cones. \n\nBefore re-arranging a qubit, we need to check if there are any qubit that have been measured and is available to re-use. If so, we reset it and apply all operations onto its wire. Otherwise, a new qubit is added and the operations are passed on to that wire.\n\n## Installation\n\nThis package is not available through pypi, but can be installed by cloning this repository:\n\n```zsh\ngit clone https://github.com/qiskit-community/qiskit-qubit-reuse\n```\nAnd then installing locally:\n\n```zsh\npip install ./qiskit-qubit-reuse\n```\nIf you have the proper authentication keys, you can install it remotely by using:\n\n```zsh\npip install git+https://github.com/qiskit-community/qiskit-qubit-reuse\n```\n\n## Usage\n\nOnce installed, Qiskit is able to detect the `qubit_reuse` plugin via an entry point. All that needs to be done is to specify the init method in your `transpile` call by using `init_method=\"qubit_reuse\"`. Use the following example:\n\n```py3\nfrom qiskit.circuit.random import random_circuit\nfrom qiskit import transpile\nfrom qiskit.providers.fake_provider import FakeGuadalupeV2\n\nqc = random_circuit(16, 4, measure=True)\n\ntranspiled_qc = transpile(qc, backend=FakeGuadalupeV2(), init_method=\"qubit_reuse\")\n```\n\nThis entry point provides the option with the least amount of qubits. If you want to specifically use the normal or dual circuit, you can specifcy that by using the `qubit_reuse_normal` or the `qubit_reuse_dual` endpoints.\n\n**Warning: This plugin should only be used with circuits that contain measurements.**\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "A Qiskit's compiler plugin to reuse qubits using midcircuit measurement",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "qiskit",
        "sdk",
        "quantum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb6cba8fde32e0deb3111e1958b6c855096410bb363ce5d5485f03cc3b247835",
                "md5": "638a547d50b72c1e9ef4161b3071dfce",
                "sha256": "07cc093154ad99024f1fbd71c9dff68898abf641bcaee38aebcb0071cf6f2305"
            },
            "downloads": -1,
            "filename": "qiskit_qubit_reuse-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "638a547d50b72c1e9ef4161b3071dfce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11936,
            "upload_time": "2024-02-05T16:17:23",
            "upload_time_iso_8601": "2024-02-05T16:17:23.493392Z",
            "url": "https://files.pythonhosted.org/packages/bb/6c/ba8fde32e0deb3111e1958b6c855096410bb363ce5d5485f03cc3b247835/qiskit_qubit_reuse-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "37f3aa061998ef302ee837f27de81659460f6d5b263b60528a95107b04c349ce",
                "md5": "69b30f3df7cb11eda8b99ffc7c1c9fd3",
                "sha256": "a19546cb51881e234c1cf7b57e7d6e81e11e42ca6a81eed6967603c3a6954c03"
            },
            "downloads": -1,
            "filename": "qiskit-qubit-reuse-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "69b30f3df7cb11eda8b99ffc7c1c9fd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10861,
            "upload_time": "2024-02-05T16:17:24",
            "upload_time_iso_8601": "2024-02-05T16:17:24.540854Z",
            "url": "https://files.pythonhosted.org/packages/37/f3/aa061998ef302ee837f27de81659460f6d5b263b60528a95107b04c349ce/qiskit-qubit-reuse-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 16:17:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "qiskit-qubit-reuse"
}
        
Elapsed time: 0.18731s