pytket-pennylane


Namepytket-pennylane JSON
Version 0.20.0 PyPI version JSON
download
home_pageNone
SummaryPytket extension and Pennylane plugin.
upload_time2025-01-24 09:43:39
maintainerNone
docs_urlNone
authorTKET development team
requires_python>=3.10
licenseApache 2
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytket-pennylane

[![Slack](https://img.shields.io/badge/Slack-4A154B?style=for-the-badge&logo=slack&logoColor=white)](https://tketusers.slack.com/join/shared_invite/zt-18qmsamj9-UqQFVdkRzxnXCcKtcarLRA#)
[![Stack Exchange](https://img.shields.io/badge/StackExchange-%23ffffff.svg?style=for-the-badge&logo=StackExchange)](https://quantumcomputing.stackexchange.com/tags/pytket)

[Pytket](https://tket.quantinuum.com/) extension and [PennyLane](https://github.com/PennyLaneAI/pennylane) plugin which allows pytket backends and compilation to be used as a PennyLane device.

Pytket is a quantum SDK python package which provides state of the art compilation for quantum
circuits and a unified interface for execution on a number of "backends" (devices and simulators).
PennyLane is a package for differentiable programming of quantum computer, which also provides a way
to execute circuits on a variety of "devices". This package allows users to easily leverage the 
differentiablecircuits of PennyLane combined with the compilation available in Pytket.

The package is available for python 3.10, 3.11 and 3.12, and can be installed by
cloning and installing from source, or via pip:

```shell
pip install pytket-pennylane
```

API documentation is [here](https://tket.quantinuum.com/extensions/pytket-pennylane/api/).

See the PennyLane [documentation](https://pennylane.readthedocs.io) and Pytket [documentation](https://tket.quantinuum.com/api-docs/) to get an intro to PennyLane and Pytket.

To use the integration once installed, initialise your pytket backend (in this example, an `AerBackend` which uses Qiskit Aer), and construct a PennyLane `PytketDevice` using this backend:

```python
import pennylane as qml
from pytket.extensions.qiskit import AerBackend

# initialise pytket backend
pytket_backend = AerBackend()

# construct PennyLane device
dev = qml.device(
    "pytket.pytketdevice",
    wires=2,
    pytket_backend=pytket_backend,
    shots=1000
)

# define a PennyLane Qnode with this device
@qml.qnode(dev)
def my_quantum_function(x, y):
    qml.RZ(x, wires=0)
    qml.RX(y, wires=1)
    return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))

# call the node
print(my_quantum_function(0.1, 0.2))

```

The example above uses the Pytket default compilation pass for the backend, you can change the optimisation
level of the default backend pass (0, 1 or 2) by setting the `optimisation_level` parameter:

```python
dev = qml.device(
    "pytket.pytketdevice",
    wires=2,
    pytket_backend=pytket_backend,
    optimisation_level=2,
    shots=1000
)
```

You can also use any Pytket [compilation pass](https://tket.quantinuum.com/user-manual/manual_compiler.html) using the `compilation_pass` parameter, which is used instead of the default pass:

```python
from pytket.passes import PauliSimp, SequencePass

# use a Chemistry optimised pass before the backend's default pass

custom_pass = SequencePass([PauliSimp(), pytket_backend.default_compilation_pass()])

dev = qml.device(
    "pytket.pytketdevice",
    wires=2,
    pytket_backend=pytket_backend,
    compilation_pass=custom_pass,
    shots=1000
)

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytket-pennylane",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "TKET development team",
    "author_email": "tket-support@quantinuum.com",
    "download_url": null,
    "platform": null,
    "description": "# pytket-pennylane\r\n\r\n[![Slack](https://img.shields.io/badge/Slack-4A154B?style=for-the-badge&logo=slack&logoColor=white)](https://tketusers.slack.com/join/shared_invite/zt-18qmsamj9-UqQFVdkRzxnXCcKtcarLRA#)\r\n[![Stack Exchange](https://img.shields.io/badge/StackExchange-%23ffffff.svg?style=for-the-badge&logo=StackExchange)](https://quantumcomputing.stackexchange.com/tags/pytket)\r\n\r\n[Pytket](https://tket.quantinuum.com/) extension and [PennyLane](https://github.com/PennyLaneAI/pennylane) plugin which allows pytket backends and compilation to be used as a PennyLane device.\r\n\r\nPytket is a quantum SDK python package which provides state of the art compilation for quantum\r\ncircuits and a unified interface for execution on a number of \"backends\" (devices and simulators).\r\nPennyLane is a package for differentiable programming of quantum computer, which also provides a way\r\nto execute circuits on a variety of \"devices\". This package allows users to easily leverage the \r\ndifferentiablecircuits of PennyLane combined with the compilation available in Pytket.\r\n\r\nThe package is available for python 3.10, 3.11 and 3.12, and can be installed by\r\ncloning and installing from source, or via pip:\r\n\r\n```shell\r\npip install pytket-pennylane\r\n```\r\n\r\nAPI documentation is [here](https://tket.quantinuum.com/extensions/pytket-pennylane/api/).\r\n\r\nSee the PennyLane [documentation](https://pennylane.readthedocs.io) and Pytket [documentation](https://tket.quantinuum.com/api-docs/) to get an intro to PennyLane and Pytket.\r\n\r\nTo use the integration once installed, initialise your pytket backend (in this example, an `AerBackend` which uses Qiskit Aer), and construct a PennyLane `PytketDevice` using this backend:\r\n\r\n```python\r\nimport pennylane as qml\r\nfrom pytket.extensions.qiskit import AerBackend\r\n\r\n# initialise pytket backend\r\npytket_backend = AerBackend()\r\n\r\n# construct PennyLane device\r\ndev = qml.device(\r\n    \"pytket.pytketdevice\",\r\n    wires=2,\r\n    pytket_backend=pytket_backend,\r\n    shots=1000\r\n)\r\n\r\n# define a PennyLane Qnode with this device\r\n@qml.qnode(dev)\r\ndef my_quantum_function(x, y):\r\n    qml.RZ(x, wires=0)\r\n    qml.RX(y, wires=1)\r\n    return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))\r\n\r\n# call the node\r\nprint(my_quantum_function(0.1, 0.2))\r\n\r\n```\r\n\r\nThe example above uses the Pytket default compilation pass for the backend, you can change the optimisation\r\nlevel of the default backend pass (0, 1 or 2) by setting the `optimisation_level` parameter:\r\n\r\n```python\r\ndev = qml.device(\r\n    \"pytket.pytketdevice\",\r\n    wires=2,\r\n    pytket_backend=pytket_backend,\r\n    optimisation_level=2,\r\n    shots=1000\r\n)\r\n```\r\n\r\nYou can also use any Pytket [compilation pass](https://tket.quantinuum.com/user-manual/manual_compiler.html) using the `compilation_pass` parameter, which is used instead of the default pass:\r\n\r\n```python\r\nfrom pytket.passes import PauliSimp, SequencePass\r\n\r\n# use a Chemistry optimised pass before the backend's default pass\r\n\r\ncustom_pass = SequencePass([PauliSimp(), pytket_backend.default_compilation_pass()])\r\n\r\ndev = qml.device(\r\n    \"pytket.pytketdevice\",\r\n    wires=2,\r\n    pytket_backend=pytket_backend,\r\n    compilation_pass=custom_pass,\r\n    shots=1000\r\n)\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "Pytket extension and Pennylane plugin.",
    "version": "0.20.0",
    "project_urls": {
        "Documentation": "https://tket.quantinuum.com/extensions/pytket-pennylane/index.html",
        "Source": "https://github.com/CQCL/pytket-pennylane",
        "Tracker": "https://github.com/CQCL/pytket-pennylane/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6949b4a698178262d176a3e6c10547d934430a7a6a6a8738656a0ea93b840fd3",
                "md5": "008c3d51da187cfeabe8b12de9315767",
                "sha256": "ea71a43a2cbba67367b2b0091eefb3925b520a3d0dec34cc7469205d89072e3c"
            },
            "downloads": -1,
            "filename": "pytket_pennylane-0.20.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "008c3d51da187cfeabe8b12de9315767",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12157,
            "upload_time": "2025-01-24T09:43:39",
            "upload_time_iso_8601": "2025-01-24T09:43:39.185128Z",
            "url": "https://files.pythonhosted.org/packages/69/49/b4a698178262d176a3e6c10547d934430a7a6a6a8738656a0ea93b840fd3/pytket_pennylane-0.20.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-24 09:43:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CQCL",
    "github_project": "pytket-pennylane",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytket-pennylane"
}
        
Elapsed time: 0.53991s