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 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.
  • 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.6.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, include files (besides qelib1.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

  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/.

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.6.1

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.6.1
File Size Uploaded
tzap-0.6.1.tar.gz 509.5 kB Details

Built distributions (wheels)

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

Total release size: 6.4 MB

Release files / tzap-0.6.1.tar.gz

Download URL tzap-0.6.1.tar.gz
Size 509.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0a1d82985f13c8bb049065ce8b882ae0af223cfeaea46dd0ced4cdff8be405dc
BLAKE2b-256 checksum
How to use checksums
9d8873ce0570b1d14977ffb25e1479be3920782c99842a80d8734943018d096d
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.6.1-cp310-abi3-win_amd64.whl

Download URL tzap-0.6.1-cp310-abi3-win_amd64.whl
Size 754.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
31deb40d8d4dedc11023eb0005c28e05f9bec24d932cd3afcdec8e8b3aafb8c9
BLAKE2b-256 checksum
How to use checksums
27ac0c5fadfe00908197a387c3e858773d291ef531a7bcaaffb47a17a673c17c
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.6.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tzap-0.6.1-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
53eb8429d832f589707138576bb1b30d46228a6649d1168db14e88aa1a621d36
BLAKE2b-256 checksum
How to use checksums
3cef5a30dee3e8a8101a33bf9d394f10e3fcf50c8ffb6c5dd3346f0462d16fac
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.6.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tzap-0.6.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 955.6 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
058722500a27ee3fac3288f8581e2d87e7d94e408d61ceb35f2e5eb0edd0b524
BLAKE2b-256 checksum
How to use checksums
d4f87ece0b159c0955bfa0baacfe31987bd144ac8e7e8a441540f9d8ab7a7bca
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.6.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tzap-0.6.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 825.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
49bbece77caaaa992c952db52055860a29391527f117667ca915f78801377ac8
BLAKE2b-256 checksum
How to use checksums
365d2ff3bbfdd9fffb74c774ecc9119980679595f2fbdf459440f83f97f4e619
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.6.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tzap-0.6.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 777.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0da0a806a0dad3f11d9bbb6c8ca5fd8e156bccc03b2bdcddebd2a3614d98e5ce
BLAKE2b-256 checksum
How to use checksums
0736ef6798fc28319f063f3c39ee3c8bb9b48c7d873aa8791fd114de68246a00
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.6.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL tzap-0.6.1-cp310-abi3-macosx_11_0_arm64.whl
Size 754.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e5dfff27e5e12a9ad6231671e81a0174f8a9457bc82389ed089e1f16b9ee8bb5
BLAKE2b-256 checksum
How to use checksums
0f45232630cca0f8a1645b21748b683d5490ae09a1936887ebdfe9aa1c1faf51
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.6.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL tzap-0.6.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 771.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
48491278e7b29188f836790917b272a56a120894e6d0907aa3f3f615f7c1762b
BLAKE2b-256 checksum
How to use checksums
4fbf3c0264cc9423c6236bf75ae47b32e94427ae8ae90656181e13a9846d1d03
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.6.1 This release

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