Skip to main content

pytket-qirpass

This module provides a method to optimize QIR using pytket, and a method to convert QIR to pytket for simple circuits.

Installation

Python 3.10, 3.11, 3.12 or 3.13 is required.

To install from PyPI:

pip install pytket-qirpass

Usage

Optimizing QIR with apply_qirpass

The function apply_qirpass takes as input

  • some QIR bitcode
  • a pytket compilation pass
  • a target gateset

and outputs some new QIR bitcode, where the pass has been applied to the basic blocks in the input program, followed by a rebase to the target gateset.

For example:

from pytket_qirpass import apply_qirpass
from pytket.circuit import OpType
from pytket.passes import FullPeepholeOptimise

qir_out = apply_qirpass(
    qir_bitcode=qir_in,
    comp_pass=FullPeepholeOptimise(allow_swaps=False),
    target_1q_gates={OpType.Rx, OpType.Rz},
    target_2q_gates={OpType.ZZPhase},
)

Both the input and the output are Python bytes objects.

Provided the pass preserves the circuit semantics, apply_qirpass preserves the QIR semantics.

Converting QIR to pytket with qir_to_pytket

The function qir_to_pytket takes as input some QIR bitcode and outputs a pytket circuit.

For example:

from pytket_qirpass import qir_to_pytket

circ = qir_to_pytket(qir_bitcode=qir_in)

The program represented by the bitcode must consist of a single basic block comprised of quantum operations, i.e. __quantum__qis__* instructions; any __quantum__rt__* instructions are accepted but ignored.

Download files

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

Source Distribution

pytket_qirpass-0.10.0.tar.gz (282.1 kB view details)

Uploaded Source

Built Distribution

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

pytket_qirpass-0.10.0-py2.py3-none-any.whl (10.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytket_qirpass-0.10.0.tar.gz.

File metadata

  • Download URL: pytket_qirpass-0.10.0.tar.gz
  • Upload date:
  • Size: 282.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for pytket_qirpass-0.10.0.tar.gz
Algorithm Hash digest
SHA256 8d66164d628a84a6346de2ae1b2c67aea877eabe8f4fa0237b55797b9580e664
MD5 186bfc2bf148ce88c866f1c3166883d8
BLAKE2b-256 a73496c5306b5f709f9968b21299747522865154ad24b927b8582844be703b3f

See more details on using hashes here.

File details

Details for the file pytket_qirpass-0.10.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytket_qirpass-0.10.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 607a14d889d38c3941d130e7a669096c5760af7fc666888480cabe47dc4b16d0
MD5 2811239b473b126f30f296ac8517b86e
BLAKE2b-256 8c4f35fd467a557627622ebe33fa2639684328add6a5ce7c38cd283e9ee1aa6f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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