zxparam
A Python library for exact, parametric rewriting of ZX-diagrams. Phases can depend on Boolean parameters, so one simplification serves every parameter assignment, and diagrams can mix quantum and classical parts, such as measurements, noise and classical outputs.
Key features
- Parametric rewriting. A phase is a concrete angle plus π times a parity of Boolean parameters. Every rewrite rule holds for all parameter values, so a diagram is reduced once and then evaluated per assignment. This follows ParamZX (paper, code).
- Quantum and classical domains. Spiders and wires are quantum or
classical. Quantum ones stand for both copies of the doubled diagram, so the
same graph describes pure circuits, measurements, decoherence and classical
logic. The rules (
full_reduce, pivots, local complementation, gadget fusion, ground elimination, …) are domain-aware. - Exact scalars. Scalars are kept exactly, in the dyadic ring with parametric phase terms, never as floats.
- Stabilizer-rank decomposition.
decomposewrites a closed diagram as a sum of exactly represented stabilizer terms. The strategiescat5,bssandcuttingare ported from PyZX-Param. - Circuit extraction.
extract_circuitturns a simplified diagram back into gates whose tensor equals the diagram's, scalar included. Classical data becomes measurements, discards and classically controlled gates through the ZX⏚ ground form of Borgna, Perdrix and Valiron (paper, code). It extends the frontier extraction of Duncan et al. (PyZX). - Tensor contraction and drawing.
Graph.to_tensorcontracts diagrams with quimb, anddrawrenders them with D3 in Jupyter.
Installation
pip install "zxparam[quimb] @ git+https://github.com/QuEraComputing/zxparam"
The quimb extra is needed for Graph.to_tensor. Installing from source builds
the compiled core, which needs a Rust toolchain (rustup).
Usage
import itertools
import numpy as np
import zxparam as zx
# A Clifford+T circuit whose spiders carry Pauli phases p0, p1 ∈ {0, 1}.
g = zx.random_clifford_t(3, 60, seed=1, pauli_params={0, 1})
h = g.copy()
zx.full_reduce(h) # one reduction, valid for every parameter value
for p0, p1 in itertools.product((0, 1), repeat=2):
b = {0: p0, 1: p1}
assert np.allclose(h.to_tensor(b), g.to_tensor(b))
# Close the circuit and decompose it into exact parametric stabilizer terms.
for v in [*g.inputs(), *g.outputs()]:
g.plug(v, zx.VertexType.X)
terms = zx.decompose(g)
assert np.isclose(terms.evaluate({0: 1, 1: 0}), g.to_tensor({0: 1, 1: 0}))
Development
uv sync --group dev
uv run pytest
uv run ruff check
uv run ruff format --check
uv run ty check
uv sync builds the compiled core in rust/, and uv run and uv sync
rebuild it after a change to its Rust sources. cargo test in rust/ runs
the core's own tests.
Known performance gaps
Two speed targets of the Rust port are not met yet:
full_reduceon dense random circuits, such asrandom_clifford_t(20, 16000), is about 17× faster than the Python implementation it replaced, against a target of 20×.extract_circuiton 40-qubit random circuits of 30,000 gates, afterfull_reduce, is about 12× faster, against a target of 20×.
Both spend their time in the core's adjacency updates: the edge toggles of
local complementation, of the pivots and of the extractor's row additions.
A denser adjacency layout in rust/zxparam/src/graph/ is the likely fix.
License
Metadata
Release files for zxparam 0.1.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 | Provenance | |
|---|---|---|---|---|
| zxparam-0.1.0.tar.gz | 156.7 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| zxparam-0.1.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| zxparam-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| zxparam-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| zxparam-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| zxparam-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| zxparam-0.1.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| zxparam-0.1.0-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 / zxparam-0.1.0.tar.gz
| Download URL | zxparam-0.1.0.tar.gz |
|---|---|
| Size | 156.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cdbfb7fda197b88cfa2b69c5559bb122201974f18d6b355cefd39e5cb824b98
|
|
BLAKE2b-256 checksum How to use checksums |
862293ec6ded213fd00e0b3dc090011f9b567b9ccd6bbae6cc147df674909538
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-win_amd64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 709.4 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e86d83ee5c10fe3f826222685d08bda5c28bc881ea1cd672957e8e7c767a938a
|
|
BLAKE2b-256 checksum How to use checksums |
3693ce792c925e197dacaf9c0fbe4bf2e678d0bd7bd2315ff1419795dfac2f5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
90d7589b1f5d7daa0b6ffd0fa56d3cc7ed6bd54940e2c1b5dd3a959d1b3bd080
|
|
BLAKE2b-256 checksum How to use checksums |
beb191089f659816119633588da3b33c6910e12dfdaee2c14dbb1a30eacb0bba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b1a1f7f896e4f246e65d89af2f695ec221cbfde239ffa65865848ef7b91acf14
|
|
BLAKE2b-256 checksum How to use checksums |
3e9025829e10059fba430458272f423ca1c01c6f9e49acf4d1a08dfb9477e1d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 877.5 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2a419bd5bfd09d9315fefb09a28d2239ffc76c61584f852ce1103e1919035df0
|
|
BLAKE2b-256 checksum How to use checksums |
3d34b2ee1edcb72b2a873374b9dbb699dc88eecca620ae8326d7d7b01a1a8322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 869.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ea59bdbcf563c075bb667c500b1f47491b0b0ca0c239d141acdeb075300c465a
|
|
BLAKE2b-256 checksum How to use checksums |
d5f9b4a16e7f353b0cddae6c46678714a6093e03bf2287c4242fc505228a6fc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 817.0 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0c93a9095348f1fbf0927193dfc96ee26be2772b74dbb499e6de7dbb2d162c98
|
|
BLAKE2b-256 checksum How to use checksums |
243395459b8fb19d1a373a836f4833b698dc54ad4eeb73ecccde764e4b08b0f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / zxparam-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | zxparam-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 828.0 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
310033f5854ba1b9be6d4b9517d512a56232b75aaea74bc34fe4c428cfc782ed
|
|
BLAKE2b-256 checksum How to use checksums |
20835c1a5d9583b3ee833995a1e92b7571de41a8b6c6cdc43bcda83455d9cf31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for zxparam 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for zxparam-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.