Installation · Using tzap | Qiskit integration · PennyLane integration
A super fast, Rust-based optimizer for large Clifford+T/Rz 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.
You can use tzap as a command-line utility or a library.
These options install the standalone native tzap executable.
Homebrew (macOS/Linux):
brew install qqq-wisc/tap/tzapPrebuilt release binary (macOS/Linux):
curl -LsSf https://github.com/qqq-wisc/tzap/releases/latest/download/tzap-opt-installer.sh | shYou 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.
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.
The standard command-line workflow is described below.
Optimize a circuit
tzap input.qasm -o output.qasmFor example, using a benchmark in this repo:
$ tzap benchmarks/feynman/hwb12.qasm -o optimized.qasm
⚡️ tzap v0.6.1
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.qasmOptimization 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.qasmOptional 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
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
- 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/.
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}
}