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

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 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.6.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.6.0
File Size Uploaded
tzap-0.6.0.tar.gz 281.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tzap 0.6.0
File
tzap-0.6.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tzap-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tzap-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tzap-0.6.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.6.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
tzap-0.6.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tzap-0.6.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.6.0.tar.gz

Download URL tzap-0.6.0.tar.gz
Size 281.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4e5724b17d3aa735b1ce31a60d76df940ccb7d9fc15ec8a6a6fadf6699bb17e5
BLAKE2b-256 checksum
How to use checksums
8c2165ea4d8ff03461221b4181098fb2acad35f3e8d8b63d6e76294ec719f9ec
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.0-cp310-abi3-win_amd64.whl

Download URL tzap-0.6.0-cp310-abi3-win_amd64.whl
Size 755.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
bb6ac4324b655f89a7c21e1bbc89a25ccdec684e48f42b75680f3b4789057209
BLAKE2b-256 checksum
How to use checksums
b6d5c617e10ef867623076858520375adb74e4f60d8bcb9415ec6dcc0c1aebb0
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.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tzap-0.6.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
7bbb1751ccc55da3b14948a21e051fc586d1b19c24735396de6d66af2075d3e5
BLAKE2b-256 checksum
How to use checksums
3ac1c07abf98bb9e9ed0dc93ea23da8593f6ed2bd8f84fd9469828510896622a
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.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tzap-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 957.2 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
cfc7ed6490183f163b4f9bc798e2dc75c1c92a2385fcda22a7f1fde966edee96
BLAKE2b-256 checksum
How to use checksums
612e2416cc517bd0c31400d27390842ee2359e0f6de3e0c0cf419e7a8a07242a
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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tzap-0.6.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 825.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0a63d3e5ce1cc182f390f339b82462b6723664743d0df68359f5e07f9edc9e77
BLAKE2b-256 checksum
How to use checksums
973bdb8285b40fdd7d9b9d744d4aec4ee4cf138457b69125573cfa784d2ea44c
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.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tzap-0.6.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 778.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3bf1095804c8bfa35866c34639fc83420a8ce0f7ce4300bfdda85edf19f5c9e9
BLAKE2b-256 checksum
How to use checksums
8789f4de098c35d0bf76ea42c7e9825c9a79464ef67dea1a230f10e4d99befab
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.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tzap-0.6.0-cp310-abi3-macosx_11_0_arm64.whl
Size 757.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8112c005ef4dd8396fb46c22f8860a1a70bb25d56d3962cf8f99d02e5c4ec537
BLAKE2b-256 checksum
How to use checksums
98d664efdb1bed85a1b01f2d4843cae4faafac7fca6bbe55c02cc2fc3d56c132
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.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL tzap-0.6.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 779.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
341ebd450b1bcd2151eeb46d82094c2673886aa6a259876b93e375f0d2ca3202
BLAKE2b-256 checksum
How to use checksums
3e0f827b725fa258d952c8c3baa322bc8cabc8234725b508beed224666f8d2ab
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

0.6.1

8 release files

This release

0.6.0 This release

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