⚡️ tzap
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.
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 + 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
Optional decomposition
CCX, CCZ, CZ, and Rz stay native by default. To decompose them, use:
--decompose-ccxto decompose CCX and CCZ--decompose-czto decompose CZ into CX+H--decompose-rzto decompose Rz via gridsynth
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-rz when the input contains Rz gates; resets are unsupported.
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,rz,cx,ccx,ccz,cz,measure,reset - Declarations:
qreg,creg - Not supported: classical conditionals (
if), custom gate definitions (gate), barriers,includefiles (besidesqelib1.inc, which is ignored) - Unrecognized lines produce an error
Correctness
- Fuzzing and equivalence verification on small random circuits and benchmark circuits.
- Lean port: the core optimizer is implemented and proven sound in Lean 4 — see
lean/.
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.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tzap-0.7.0.tar.gz | 714.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| tzap-0.7.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| tzap-0.7.0-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| tzap-0.7.0-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| tzap-0.7.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.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| tzap-0.7.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| tzap-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 6.7 MB
Release files / tzap-0.7.0.tar.gz
| Download URL | tzap-0.7.0.tar.gz |
|---|---|
| Size | 714.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7eb4a1fe50b54e62ec91528c7ae8f0b944fbbcae5f9c66816a7f264da14801ec
|
|
BLAKE2b-256 checksum How to use checksums |
27d164d93ae2050589c64c700c809e3d459c2234b5956f0bef86e56edcd6477d
|
| 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.7.0-cp310-abi3-win_amd64.whl
| Download URL | tzap-0.7.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 771.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ff5ebc551e4a04a89db76a1743f7083e5e68685f45d068507f7e652fbfb1837b
|
|
BLAKE2b-256 checksum How to use checksums |
fb4a1169365cc3f5385f58616522d7f2251b378a8d65cd0627bfdbd5e75a555e
|
| 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.7.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | tzap-0.7.0-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1ba105ea590df425bcbfb32e0bd085efddaa3df5582632ad04920b9a7ebd63e9
|
|
BLAKE2b-256 checksum How to use checksums |
e778a13b2b4f3a8ac10cd863d22587aca24b5f99dff2caf632dac9b5a619aabb
|
| 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.7.0-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | tzap-0.7.0-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 967.7 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0cc2e2b23320965e301de2ad4bae476c9d212b64e922917b1ce9e9f4c4e6e1a0
|
|
BLAKE2b-256 checksum How to use checksums |
a451e2f898275a63d7fbacd3eb396dbd30a89cba2d77c0f8555b3ed9e38a951d
|
| 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.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tzap-0.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 840.5 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
766633bc9c0d9a5cebbd52946928249262691b5ed98167ea883f56158be684de
|
|
BLAKE2b-256 checksum How to use checksums |
02b191b34c04b0a8d3ad59f68da3cb5bd83f0a28ed9e8b4e48de506e0116cb3c
|
| 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.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | tzap-0.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 790.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
446001f9123806210b96bfd1f52e8da3ae48b52b3dfe1edcffada4b71e617b2f
|
|
BLAKE2b-256 checksum How to use checksums |
793be34dd6a3c6aab4f06e73c20487dbb9f099ddfdf5a5497f418d270953f81a
|
| 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.7.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | tzap-0.7.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 768.6 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c5487d1aa52b4d799d7b2894c045035f9d35c42f6716907f93f9fa3b5abd380e
|
|
BLAKE2b-256 checksum How to use checksums |
8407f0ef12ae97de6f90a3f6bd22c6d6c2b72f4b4d1a017b2360bb99b7d90026
|
| 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.7.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | tzap-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 786.9 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf04074c1f63730716e4e958d8bad8af2f42f3e8d74b1e6c3e1e8bbb59cd8b85
|
|
BLAKE2b-256 checksum How to use checksums |
ba9ce47a6692a5b7b23ba7db00798e4a98b1f08e37fbcbfc7b8ef5fc490cfd6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|