htlogicalgates


Namehtlogicalgates JSON
Version 0.6.1 PyPI version JSON
download
home_pageNone
SummaryFind circuit implementations for logical gates of QECCs.
upload_time2025-02-11 14:58:42
maintainerNone
docs_urlNone
authorerkue
requires_python>=3.9
licenseMIT License Copyright (c) 2024-2025 erkue Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords quantum information quantum error correction quantum circuit logical gates
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hardware-Tailored Logical Gates
![PyPI - Version](https://img.shields.io/pypi/v/htlogicalgates)
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/erkue/htlogicalgates/blob/main/LICENSE)
[![Tests](https://github.com/erkue/htlogicalgates/actions/workflows/run-tests.yml/badge.svg)](https://github.com/erkue/htlogicalgates/actions/workflows/run-tests.yml)
[![Unitary Foundation](https://img.shields.io/badge/Supported%20By-UNITARY%20FOUNDATION-brightgreen.svg)](https://unitary.foundation)



This package can be used to compile circuit implementations for **logical Clifford gates** of **quantum error-correcting codes**. The main features are:

- works for **every stabilizer code** (runtime increases with code size),
- works for **every logical Clifford gate**, and
- by providing a connectivity map of qubits, **hardware-tailored** circuits can be obtained.

During circuit compilation, the number of two-qubit gates is minimized. By constructing **hardware-tailored** circuits, further qubit permutations are avoided altogether.  

## Requirements

A list of Python package dependencies is included in [pyproject.toml](pyproject.toml) and are automatically installed together with the package.

Furthermore, a valid [Gurobi](https://www.gurobi.com/) license is neccesary for the circuit compilation. There exists a wide-range of licences, including one for academic use that is free of charge. You can find further information on the [Gurobi downloads page](https://www.gurobi.com/downloads/).

## Installation

This Python package is available on [PyPI](https://pypi.org/project/htlogicalgates/) and can be installed using `pip` via

```
pip install htlogicalgates
```
Alternatively, you can clone this repository and include it in your project.

## License 

This package is distributed under the MIT License.

If you want to support work like this, please cite: _our paper (tba)_

## Tutorials

The following sections of this readme, along with more examples and guiding information, can be found as Jupyter notebook tutorials:
- [Basic Tutorial](doc/tutorial.ipynb)
- [Advanced Tutorial](doc/tutorial_tailor_multiple_gates.ipynb)




## How to tailor logical circuits

The main workflow for tailoring a circuit starts with creating three central objects:

```py
import htlogicalgates as htlg

stab_code = htlg.StabilizerCode("4_2_2")
connectivity = htlg.Connectivity("circular", num_qubits=4)
logical_gate = htlg.Circuit(2)
logical_gate.h(0)
```

After importing the package, we create three objects:

- First, we create a `StabilizerCode` for which we wish to find a logical circuit. In this example, we pass `"4_2_2"`, which selects the $⟦4,2,2⟧$ color code. Some common codes are predefined (see below), but custom codes can also be specified through a set of stabilizer generators. 

- Next, we create a `Connectivity` that stores connections between qubits on the target hardware. Two-qubit gates will only be allowed between connected qubits. For this example, we use a `"circular"` connectivity on `num_qubits=4` qubits. Other predefined connectivities can be queried via `htlg.available_connectivities()`. Moreover, a custom connectivity can be created from an adjacency matrix. 

- Finally, we initialize a `Circuit` with the number of logical qubits and add a Hadamard gate on the first qubit (note that we count **qubits starting at 0**). In the following we will tailor a circuit that implements the action of this circuit on the logical level of the stabilizer code.

Note that we created a `Connectivity` for $n=4$ qubits and a logical `Circuit` for $k=2$ qubits since we are using the $⟦n=4,k=2,2⟧$-code.

Now we can pass these objects to the function `tailor_logical_gate`:
```py
circ, status = htlg.tailor_logical_gate(stab_code, connectivity, logical_gate, num_cz_layers=2)
```
The parameter `num_cz_layers` determines the number of CZ gate layers in the ansatz circuit. Generally speaking, more CZ layers make the ansatz more expressive and can lead to circuits with less two-qubit gates in total, while increasing runtime. If you can not find a specific gate, try to increase the number of CZ gate layers.

The return value `status` indicates the state of the optimization:

- `"Optimal"` : The returned circuit is optimal in terms of two-qubit gates.
- `"Bound {n}"` : The returned circuit is not optimal in terms of two-qubit games but there is no circuit with less than $n$ two-qubit gates.
- `"Infeasible"` : There is no physical circuit for the given stabilizer code, connectivity, logical circuit, and number of CZ gate layer.
- `"Time out"` : A physical circuit was not found in the given time limit.

If the status message is `"Optimal"` or `"Bound {n}"`, then `circ` contains the physical circuit implementation. Otherwise, it is `None`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "htlogicalgates",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "quantum information, quantum error correction, quantum circuit, logical gates",
    "author": "erkue",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/5d/6d/b69fc3cf46c9f760f2c03a6645649bf7fd5ab8e3d8520b01d73bcb21d6ec/htlogicalgates-0.6.1.tar.gz",
    "platform": null,
    "description": "# Hardware-Tailored Logical Gates\n![PyPI - Version](https://img.shields.io/pypi/v/htlogicalgates)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/erkue/htlogicalgates/blob/main/LICENSE)\n[![Tests](https://github.com/erkue/htlogicalgates/actions/workflows/run-tests.yml/badge.svg)](https://github.com/erkue/htlogicalgates/actions/workflows/run-tests.yml)\n[![Unitary Foundation](https://img.shields.io/badge/Supported%20By-UNITARY%20FOUNDATION-brightgreen.svg)](https://unitary.foundation)\n\n\n\nThis package can be used to compile circuit implementations for **logical Clifford gates** of **quantum error-correcting codes**. The main features are:\n\n- works for **every stabilizer code** (runtime increases with code size),\n- works for **every logical Clifford gate**, and\n- by providing a connectivity map of qubits, **hardware-tailored** circuits can be obtained.\n\nDuring circuit compilation, the number of two-qubit gates is minimized. By constructing **hardware-tailored** circuits, further qubit permutations are avoided altogether.  \n\n## Requirements\n\nA list of Python package dependencies is included in [pyproject.toml](pyproject.toml) and are automatically installed together with the package.\n\nFurthermore, a valid [Gurobi](https://www.gurobi.com/) license is neccesary for the circuit compilation. There exists a wide-range of licences, including one for academic use that is free of charge. You can find further information on the [Gurobi downloads page](https://www.gurobi.com/downloads/).\n\n## Installation\n\nThis Python package is available on [PyPI](https://pypi.org/project/htlogicalgates/) and can be installed using `pip` via\n\n```\npip install htlogicalgates\n```\nAlternatively, you can clone this repository and include it in your project.\n\n## License \n\nThis package is distributed under the MIT License.\n\nIf you want to support work like this, please cite: _our paper (tba)_\n\n## Tutorials\n\nThe following sections of this readme, along with more examples and guiding information, can be found as Jupyter notebook tutorials:\n- [Basic Tutorial](doc/tutorial.ipynb)\n- [Advanced Tutorial](doc/tutorial_tailor_multiple_gates.ipynb)\n\n\n\n\n## How to tailor logical circuits\n\nThe main workflow for tailoring a circuit starts with creating three central objects:\n\n```py\nimport htlogicalgates as htlg\n\nstab_code = htlg.StabilizerCode(\"4_2_2\")\nconnectivity = htlg.Connectivity(\"circular\", num_qubits=4)\nlogical_gate = htlg.Circuit(2)\nlogical_gate.h(0)\n```\n\nAfter importing the package, we create three objects:\n\n- First, we create a `StabilizerCode` for which we wish to find a logical circuit. In this example, we pass `\"4_2_2\"`, which selects the $\u27e64,2,2\u27e7$ color code. Some common codes are predefined (see below), but custom codes can also be specified through a set of stabilizer generators. \n\n- Next, we create a `Connectivity` that stores connections between qubits on the target hardware. Two-qubit gates will only be allowed between connected qubits. For this example, we use a `\"circular\"` connectivity on `num_qubits=4` qubits. Other predefined connectivities can be queried via `htlg.available_connectivities()`. Moreover, a custom connectivity can be created from an adjacency matrix. \n\n- Finally, we initialize a `Circuit` with the number of logical qubits and add a Hadamard gate on the first qubit (note that we count **qubits starting at 0**). In the following we will tailor a circuit that implements the action of this circuit on the logical level of the stabilizer code.\n\nNote that we created a `Connectivity` for $n=4$ qubits and a logical `Circuit` for $k=2$ qubits since we are using the $\u27e6n=4,k=2,2\u27e7$-code.\n\nNow we can pass these objects to the function `tailor_logical_gate`:\n```py\ncirc, status = htlg.tailor_logical_gate(stab_code, connectivity, logical_gate, num_cz_layers=2)\n```\nThe parameter `num_cz_layers` determines the number of CZ gate layers in the ansatz circuit. Generally speaking, more CZ layers make the ansatz more expressive and can lead to circuits with less two-qubit gates in total, while increasing runtime. If you can not find a specific gate, try to increase the number of CZ gate layers.\n\nThe return value `status` indicates the state of the optimization:\n\n- `\"Optimal\"` : The returned circuit is optimal in terms of two-qubit gates.\n- `\"Bound {n}\"` : The returned circuit is not optimal in terms of two-qubit games but there is no circuit with less than $n$ two-qubit gates.\n- `\"Infeasible\"` : There is no physical circuit for the given stabilizer code, connectivity, logical circuit, and number of CZ gate layer.\n- `\"Time out\"` : A physical circuit was not found in the given time limit.\n\nIf the status message is `\"Optimal\"` or `\"Bound {n}\"`, then `circ` contains the physical circuit implementation. Otherwise, it is `None`.\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024-2025 erkue\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Find circuit implementations for logical gates of QECCs.",
    "version": "0.6.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/erkue/htlogicalgates/issues",
        "Homepage": "https://github.com/erkue/htlogicalgates"
    },
    "split_keywords": [
        "quantum information",
        " quantum error correction",
        " quantum circuit",
        " logical gates"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bba2242689625c59dc751d285547444bf01416a661318a2c49547899606eea8c",
                "md5": "2f3836428d45c0500dd0027f96a7f39d",
                "sha256": "5ba62b7b2b6348fced99d9844927b454601d793068b24c5fc4ab404e55d9ab59"
            },
            "downloads": -1,
            "filename": "htlogicalgates-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2f3836428d45c0500dd0027f96a7f39d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 30417,
            "upload_time": "2025-02-11T14:58:40",
            "upload_time_iso_8601": "2025-02-11T14:58:40.312892Z",
            "url": "https://files.pythonhosted.org/packages/bb/a2/242689625c59dc751d285547444bf01416a661318a2c49547899606eea8c/htlogicalgates-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5d6db69fc3cf46c9f760f2c03a6645649bf7fd5ab8e3d8520b01d73bcb21d6ec",
                "md5": "4c9b2e6045655e01005897f4a4f9ee31",
                "sha256": "67f3a2cad556597b46f1df7c6222266f5710b444f16855aeb9872a19af4de2b3"
            },
            "downloads": -1,
            "filename": "htlogicalgates-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4c9b2e6045655e01005897f4a4f9ee31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 29564,
            "upload_time": "2025-02-11T14:58:42",
            "upload_time_iso_8601": "2025-02-11T14:58:42.258649Z",
            "url": "https://files.pythonhosted.org/packages/5d/6d/b69fc3cf46c9f760f2c03a6645649bf7fd5ab8e3d8520b01d73bcb21d6ec/htlogicalgates-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-11 14:58:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "erkue",
    "github_project": "htlogicalgates",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "htlogicalgates"
}
        
Elapsed time: 8.63632s