⚡️ tzap
Installation · Using tzap | Qiskit integration · PennyLane integration
A super fast, Rust-based optimizer for large Clifford+T 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.
- The core optimization algorithms are fully formalized in Lean under
formalization.
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.5.0
Parsed benchmarks/feynman/hwb12.qasm (5.5 MB) in 0.080s
└─ 20 qubits · 514,412 gates
Loaded superoptimizer table in 0.021s
Converged after 6 rounds
┌─ Final result · 43.7% fewer gates · 1.595s ──────────────────────────┐
│ Gates ━━━━━━━━━━━━━╸────────────────── ↓43.7% · 514,412 → 289,484 │
│ 2q gates ━━━━━╸────────────────────────── ↓18.7% · 191,803 → 155,914 │
│ T/Tdg ━━━━━━━━━━━━━━━╸──────────────── ↓49.9% · 171,465 → 85,897 │
│ Depth ━━━━━━━╸──────────────────────── ↓24.3% · 274,781 → 207,940 │
└──────────────────────────────────────────────────────────────────────┘
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
Decompose Rz into Clifford+T
Use --decompose-rz when the target backend only accepts Clifford+T; tzap uses gridsynth. --epsilon trades approximation accuracy for circuit size (default 1e-10; larger is coarser).
tzap input.qasm -o output.qasm --decompose-rz --epsilon 1e-6
Use --decompose-cz to decompose CZ gates into H+CX+H before the
optimization pipeline.
Custom pipeline
--passes runs an explicit, ordered sequence of passes in place of the default pipeline.
tzap input.qasm -o output.qasm --passes CancelGates,PhaseFoldRand
tzap input.qasm -o output.qasm --passes DecomposeCz,CancelGates,PhaseFoldRand
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
Toffoli (ccx) and doubly controlled-Z (ccz) are auto-decomposed into Clifford+T. Controlled-Z (cz) is kept native so phase folding and cancellation can operate through it; use --decompose-cz for H+CX output. Rz is left as-is unless you pass --decompose-rz.
Correctness
- Fuzzing and equivalence verification on small random circuits and benchmark circuits.
- Lean formalization: core algorithms are implemented and proven sound in Lean 4 — see
formalization.
Citation
If you use tzap in your research, please cite:
@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},
}
Release files for tzap 0.5.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.5.0.tar.gz | 278.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| tzap-0.5.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| tzap-0.5.0-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| tzap-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| tzap-0.5.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.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| tzap-0.5.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| tzap-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 6.2 MB
Release files / tzap-0.5.0.tar.gz
| Download URL | tzap-0.5.0.tar.gz |
|---|---|
| Size | 278.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81a8de41d2372f1f59a5c64d20b00c2d83a1d0a0a9d9284c9f78c6b3451a941a
|
|
BLAKE2b-256 checksum How to use checksums |
ab0a2377e26c421c95395ffb4c0a3c12f06030e69d80438b690134601babe492
|
| 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.5.0-cp310-abi3-win_amd64.whl
| Download URL | tzap-0.5.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 754.9 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
750892f00680c64174a0724367fb7a84cd2ab9df914e7f79c9b15413deecf17a
|
|
BLAKE2b-256 checksum How to use checksums |
d7339340db210b8a941b84640dbd79d0a365502716ef55fa50d523f01a019d2f
|
| 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.5.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | tzap-0.5.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 |
2a7dc21ad88c89a27e6727caa63cc1ca7adf7d60e9ff3078e7cb026eb776bbc8
|
|
BLAKE2b-256 checksum How to use checksums |
e7eba4ae325a4c25d1dd008a7015ed67964f63c92ecbd2e8436aa48dc970062b
|
| 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.5.0-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | tzap-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 956.5 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2ce5d124e2fec5676e553ecb006b06ff815552a1029143f18b7da743b7603d4a
|
|
BLAKE2b-256 checksum How to use checksums |
86cb141b54db81086089b4d8ad14f881e363cb0230a573b7086510e7d7544930
|
| 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.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tzap-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 825.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2ba003f3c7244885b5bebe60f472f82e4b468a71edfa5a5553bc0345dd4d730f
|
|
BLAKE2b-256 checksum How to use checksums |
93e0b698b834a006a6cb9b315598a0687385aa4b69d6bfa40fdf44ca3665984e
|
| 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.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | tzap-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 778.5 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4987240130575fadb008927022e1e45a7a6310b68cba9ea9bf58ea972158b13d
|
|
BLAKE2b-256 checksum How to use checksums |
c5e8d8f45fc277b74000977a3bcd648269f3df969262d5d5086fe233cebc7767
|
| 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.5.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | tzap-0.5.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 754.8 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
56416b8ee384d3e208aa5b615a66f30ae4ec2e48aa90c820d48b2f19d5cfe06d
|
|
BLAKE2b-256 checksum How to use checksums |
e3350c31ea432ae0fc33ba60569d16f8c30230cf314e06eede6038ab234b33df
|
| 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.5.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | tzap-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 779.1 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2ba5673a920529053158afe0e82c738367dbd8ba58abc3298507e1fb88a20329
|
|
BLAKE2b-256 checksum How to use checksums |
8ee223642ac38af4ddc2a2e72fd19750e2eeb53c522a19b66a5e8aa416d8a842
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|