Skip to main content

Tket extension for ParityOS

Project description

ParityOS Tket

ParityOS extension adding an interface to tket.

Installation

It is recommended to install this package in a separate Python virtual environment. For example:

# To create a standard Python virtual environment:
python -m venv my_new_venv && source my_new_venv/bin/activate
# Alternatively, to create a Anaconda/Miniconda environment:
conda create --name my_new_conda_env python=<version> && conda activate my_new_conda_env
# or a pyenv environment
pyenv virtualenv <version> my_new_venv && pyenv activate my_new_venv
# or a uv managed environment
uv venv -p <version>

where <version> is a python version and one of [3.11, 3.12, 3.13].

After activating the virtual environment, install via your favorite package manager, e.g.:

# using pip
pip install parityos-tket
# using uv
uv pip install parityos-tket

Exporter

parityos-tket offers an exporter of ParityOS to tket quantum circuits.

from parityos.bits import get_q
from parityos.operators.circuit import Circuit
from parityos.operators.controlled_operator import CNOT
from parityos.operators.elementary_operator import H, Z
from parityos.operators.rotation_operator import RX
from parityos_tket.exporter import export_parityos_to_pytket

# Create circuit qubits.
qubits = [get_q(name) for name in ("a", "b", "c")]

# Create the following circuit as sequence of gates, followed by a measurement of all qubits.
#     ┌───────┐┌───┐┌───┐   ┌─┐
# qa: ┤ Rx(2) ├┤ H ├┤ Z ├───┤M├
#     └───────┘├───┤└┬─┬┘   └╥┘
# qb: ─────────┤ X ├─┤M├─────╫─
#       ┌───┐  └─┬─┘ └╥┘ ┌─┐ ║ 
# qc: ──┤ H ├────■────╫──┤M├─╫─
#       └───┘         ║  └╥┘ ║ 
# c: 3/═══════════════╩═══╩══╩═
#                     1   2  0 
circuit = Circuit(
    [
        RX(qubits[0], 2),
        H(qubits[0]),
        H(qubits[2]),
        CNOT(qubits[2], qubits[1]),
        Z(qubits[0]),
    ]
).measure_all()

# Export to tket. 
tket_result = export_parityos_to_pytket(circuit)

# print converted circuit as sequence of commands
for cmd in tket_result.circuit.get_commands():
    print(cmd)
# Rx(2) q[0];
# H q[2];
# H q[0];
# CX q[2], q[1];
# Measure q[1] --> c[1];
# Measure q[2] --> c[2];
# Z q[0];
# Measure q[0] --> c[0];

print(tket_result.qubit_map)  # Maps ParityOS qubits to tket Qubit integer labels
# {Qubit(id='a'): 0, Qubit(id='b'): 1, Qubit(id='c'): 2}

print(tket_result.cbit_map)  # Maps ParityOS cbits to tket Clbit integer labels
# {Cbit(id=0): 0, Cbit(id=1): 1, Cbit(id=2): 2}

License

This software package is made available under the 3-Clause BSD License. See License.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parityos_tket-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parityos_tket-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file parityos_tket-0.1.0.tar.gz.

File metadata

  • Download URL: parityos_tket-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for parityos_tket-0.1.0.tar.gz
Algorithm Hash digest
SHA256 592853061b8a290a915019b4142c6975cc2bd6d313ab920f5ed248ec56b9cba3
MD5 49720df10bca6b55f0d1c1f1a5c6ee88
BLAKE2b-256 3ae3314435b8734a4489e3501f2681e568d6d75341abbbe2f428cf7faf7704ca

See more details on using hashes here.

File details

Details for the file parityos_tket-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: parityos_tket-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for parityos_tket-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c9b82d28fcf750e357c98f0c2a17328b8496c661fc30b6661d3642dd8d4db22
MD5 7abf396c906dfe639d54565aacad78e2
BLAKE2b-256 d8ec4e010aaf5c9c3cf65edda64c39bb6ef50ff50365f52d077f4bbc1293fa60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page