Skip to main content

⚡️ tzap

CI crates.io PyPI Rust Lean 4 License: Apache 2.0 arXiv

Installation · Using tzap  |  Qiskit integration · PennyLane integration

A super fast, Rust-based optimizer for large Clifford+T/Rz circuits, with optional conversion to optimized Pauli-based computation (PBC) circuits.

  • tzap is state-of-the-art in speed, scalability, and gate-count reduction.
  • tzap minimizes T-count with a new linear-time phase folding algorithm, based on this paper.
  • tzap implements a new and fast superoptimization pass, based on this paper.
  • A formally verified Lean port of tzap is available in lean.

tzap is multiple orders of magnitude faster than other optimizers—and linearly scales to millions of gates! Here's a runtime comparison to two powerful optimizers on increasingly larger circuits.

Runtime comparison of tzap, VOQC, and QuiZX on GF multipliers

Installation

You can use tzap as a command-line utility or a library.

Install the binary

These options install the standalone native tzap executable.

Homebrew (macOS/Linux):

brew install qqq-wisc/tap/tzap

Prebuilt release binary (macOS/Linux):

curl -LsSf https://github.com/qqq-wisc/tzap/releases/latest/download/tzap-opt-installer.sh | sh

You can also build and install tzap from crates.io (cargo install tzap-opt) or build from source (cargo install --path .). You can also use tzap through the Rust API; see the Rust API documentation.

Integrations with Qiskit and PennyLane

You can also use tzap as a Python library and apply it as a Qiskit optimization pass or PennyLane transform. See the Qiskit API guide or PennyLane API guide for framework-specific setup.

Running tzap

The standard command-line workflow is described below.

Optimize a circuit

tzap input.qasm -o output.qasm

For example, using a benchmark in this repo:

$ tzap benchmarks/feynman/hwb12.qasm -o optimized.qasm
⚡️ tzap v0.7.0
  Parsed benchmarks/feynman/hwb12.qasm (5.5 MB) in 0.079s
	├─ 20 qubits · 514,412 gates
	└─ Circuit gates: {h, x, t, tdg, cx}
  Optimizing input circuit
  Loaded MURM in 0.039s
	└─ Synthesis basis: {h, x, z, s, sdg, t, tdg, cx}

  Converged after 6 rounds

  ┌─ Final result · 44.6% fewer gates · 1.379s ────────────────┐
  │ Gates    ━━━━━━━━━╸──────────── ↓44.6% · 514,412 → 284,848 │
  │ 2q gates ━━━━╸───────────────── ↓22.1% · 191,803 → 149,500 │
  │ T/Tdg    ━━━━━━━━━━╸─────────── ↓49.9% · 171,465 →  85,889 │
  │ Depth    ━━━━━━╸─────────────── ↓28.4% · 274,781 → 196,865 │
  └────────────────────────────────────────────────────────────┘
  wrote optimized.qasm

Optimization levels

Level Description
-O1 phase folding (PhaseFoldRand, then PhaseFoldPauli) + basic gate cancellation. Fastest; captures most of the T-gate reduction.
-O2 Adds superoptimization to -O1.
-O3 Default. Repeats -O2 until reaching a fixpoint.
-Osuper Like -O3, but with more superoptimization power (slower on first use).
tzap benchmarks/feynman/hwb12.qasm -O1 -o optimized.qasm

PhaseFoldPauli folds native P/RX/RY/RZ rotations across commuting operations. It retains exact pi fractions and declines numeric sums that add rounding.

Optional decomposition

CCX, CCZ, CZ, phase gates, and ordinary/controlled rotations stay native by default. To decompose them, use:

  • --decompose-ccx to decompose CCX and CCZ
  • --decompose-cz to decompose CZ into CX+H
  • --decompose-rotations to decompose P, Rz/Rx/Ry, CP, and CRz/CRx/CRy via gridsynth (--decompose-rz remains a compatibility alias)

PBC circuits

Use --to-pbc to convert a circuit to PBC and optimize its Pauli rotations:

tzap input.qasm --to-pbc -o output.pbc

Use --decompose-rotations for phase gates and rotations before PBC conversion. Native Y/SX/SWAP/CY/CH/CSWAP and resets are unsupported by PBC. See the PBC guide for the format, options, and examples.

Circuit support

tzap supports a subset of OpenQASM 2.0:

  • Gates: h, x, z, s, sdg, t, tdg, p (u1), y, sx, rx, ry, rz, swap, cx, cy, ch, cp (cu1), crx, cry, crz, cswap, ccx, ccz, cz, measure, reset
  • Declarations: qreg, creg
  • Not supported: classical conditionals (if), custom gate definitions (gate), barriers, include files (besides qelib1.inc, which is ignored)
  • Unrecognized lines produce an error

Correctness

  1. Fuzzing and equivalence verification on small random circuits and benchmark circuits.
  2. Lean port: the core optimizer is implemented and proven sound in Lean 4 — see lean/.

The new native gate families and generalized rotation synthesis are currently implemented in Rust and Python; the Lean gate model has not been extended.

Citation

If you use tzap in your research, please cite the following papers:

@misc{albarghouthi2026tzap,
      title={Linear-Time T-Gate Optimization via Random Abstraction}, 
      author={Aws Albarghouthi},
      year={2026},
      eprint={2605.13929},
      archivePrefix={arXiv},
      primaryClass={cs.PL},
      url={https://arxiv.org/abs/2605.13929}, 
}
@misc{cryptoeprint:2026/2115,
      author = {Aws Albarghouthi},
      title = {Fast Quantum-Circuit Superoptimization},
      howpublished = {Cryptology {ePrint} Archive, Paper 2026/2115},
      year = {2026},
      url = {https://eprint.iacr.org/2026/2115}
}

Metadata

Release files for tzap 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tzap 0.8.0
File Size Uploaded
tzap-0.8.0.tar.gz 880.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tzap 0.8.0
File
tzap-0.8.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tzap-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tzap-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tzap-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
tzap-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
tzap-0.8.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tzap-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 8.7 MB

Release files / tzap-0.8.0.tar.gz

Download URL tzap-0.8.0.tar.gz
Size 880.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9ebe581824f94f14c6a76b4825ea1039582323fc2d3bbe0482278a66c04a7df9
BLAKE2b-256 checksum
How to use checksums
6d015e9fdb593184ca1223ffe8571b42511b5bc4892f7190281fc8290a719238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-win_amd64.whl

Download URL tzap-0.8.0-cp310-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8d4f9a4dc2225f87d2922586f93afddc7d1717945b1c78c1d8789a4b7fc3521d
BLAKE2b-256 checksum
How to use checksums
cf8a7948217e1c678baa57e5ca54665225d39ab12e1cf67fae69e2f957150d72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tzap-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
79173276d0e95bfab9af6202ecc7ccf4c2bd59769ae9f32fcbfb00dc864c2d16
BLAKE2b-256 checksum
How to use checksums
17bbe8537196a047b5fff43ca2274433eb393abee43bb1aedb91a950ab9628da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tzap-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 1.2 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
4abdc17ebda7c15653334707f44918572c31d87929c4027cc79a165d75d977bc
BLAKE2b-256 checksum
How to use checksums
ce5873498c083ef20ca7193fab9c5bdf1c5885b3d4766205e74cc85e2e836cd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tzap-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9aae7df71f82031ed12d777a05db669976c9cc3a4b6fb6abff6a88f9d921b2a2
BLAKE2b-256 checksum
How to use checksums
e2b9df0dc19dcc50b9ea3dfe3e6053245d246ba0a70970bfa1d80dcd41046eaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tzap-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.0 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0fa34ca29a923088b3c673049029f0b7cd2b80a2657268f83158140365eb3aab
BLAKE2b-256 checksum
How to use checksums
6fa0eb57af8916f25b5982cd120d2fb830eee5984a2e499a3f95ed410a9482a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tzap-0.8.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fc3befc237804776e6dfdd07a3a6ceb0000650a05797fd9fdfb5a98b7c61b91c
BLAKE2b-256 checksum
How to use checksums
ca5401bd31323601c673b9c1741309511a746fd5a0ea85da3f65d39f066b5bb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tzap-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL tzap-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
aab02b1b6d5825063310fdc2f5137433c35a5584ced5060a80767c554382772d
BLAKE2b-256 checksum
How to use checksums
46bca4b9a72202f0462576c7d7184188fd8ec6e43fd6185de39a7770fee75f01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.8.0 This release

8 release files

0.7.0

8 release files

0.6.1

8 release files

0.6.0

8 release files

0.5.0

8 release files

0.4.4

8 release files

0.4.3

4 release files

0.4.2

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page