Skip to main content

py-quantum-verifier

Deterministic, offline pre-flight checks for quantum circuits. Run them before you spend hardware time.

from py_quantum_verifier import verify_experiment, falsify_claim
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2); qc.h(0); qc.cx(0, 1); qc.measure([0, 1], [0, 1])
print(verify_experiment(qc, "ionq-forte-1"))                 # GO (ionq-forte-1): All checks passed.
print(falsify_claim(qc, "ionq-forte-1", ["00", "11"]).verdict)  # SUPPORTED

No API tokens, no network, no GPU. Everything runs on Qiskit Aer with built-in device models.

Install

pip install py-quantum-verifier                  # core: qiskit>=2.0, qiskit-aer, numpy
pip install "py-quantum-verifier[pennylane]"     # + analyze_circuit_gradients
pip install "py-quantum-verifier[cuda]"          # + cudaq (Linux/macOS with CUDA-Q wheels)
pip install "py-quantum-verifier[tket]"          # + Qiskit-vs-TKET diffing
pip install "py-quantum-verifier[all]"           # everything, incl. pytest

Optional integrations are imported lazily inside try/except ImportError, so the core install is small and identical on macOS, Windows and Linux. optional_features() reports which extras are importable.

Real bugs this catches

Silent gate-synthesis blowup (rzz on IonQ-style native gates). IonQ's native ZZ gate is tunable, so a logical rzz(θ) should compile to exactly one native gate: RZZ(θ) == ZZ(θ/2π). If the compiler has no direct rzz → zz equivalence it silently falls back to a generic cx decomposition: 2 native two-qubit gates plus a pile of single-qubit gates. The circuit still runs and still "looks right"; it just carries double the two-qubit error. gate_synthesis_check compares logical and native gate counts and blocks it:

from py_quantum_verifier import gate_synthesis_check, get_device, verify_experiment

device = get_device("ionq-forte-1").with_native_equivalences(direct_rzz=False)  # unpatched compiler
verify_experiment(qc_with_rzz, device)
# BLOCK: 1 logical two-qubit gate(s) became 2 native two-qubit gate(s) (2.0x, limit 1.5x for tunable ...)

Limits are device-aware: on CZ/CX/ECR-native hardware an arbitrary-angle rzz legitimately needs 2 gates, so that is not flagged there (limit 2.5x).

Topology traps. On heavy-hex devices a qubit with more than 3 interaction partners forces SWAP routing that multiplies two-qubit gate count. topology_check flags it before transpiling. All-to-all devices report "not applicable" rather than silently passing.

Noise passed off as a signal. A forgotten h before a cx gives 00 at 99%, which looks like a great Bell-state result. falsify_claim builds a control with the entangling gates removed, runs both under the same noise model, and compares: readout bias and SPAM hit both arms equally and cancel. If the control reproduces the signal, the claim is NOT_SUPPORTED.

Claims the shot budget can't support. verify_experiment computes the shots needed to separate a claimed amplification from uniform noise and blocks under-powered runs up front.

Fragile winners. find_robust_circuit ranks candidates by mean minus variance under the device noise model and re-validates the winner on a seed it was never scored on, so a circuit that wins only in ideal simulation loses.

Benchmark (synthetic suite)

These numbers describe this 30-circuit test suite, not real hardware.

30 circuits (Bell, GHZ incl. star fan-out, QAOA, hardware-efficient ansätze, rzz pairs/chains, plus deliberately broken and buggy-compiler variants) × 2 device presets, 4096 shots, fixed seeds, produced by benchmarks/run_benchmark.py:

Metric ibm-heron ionq-forte-1
Circuits run 30 30
verify_experiment GO 28 (93.3%) 22 (73.3%)
verify_experiment BLOCK 2 (6.7%) 8 (26.7%)
  of which gate-synthesis inflation 0 8
  of which topology (routing) 2 0
  of which ground-truth claim failed 0 0
Buggy-compiler rzz variants caught 0/8 (n/a: cz-native, 2 cz is the minimum) 8/8
Clean-compiler rzz circuits falsely blocked 0/9 0/9
Fake-entanglement circuits (missing h) passed by verify_experiment 3/3 3/3
Fake-entanglement circuits rejected by falsify_claim 3/3 3/3
Non-broken circuits rejected by falsify_claim 2/27 2/27

Takeaways:

  • The 8 IonQ blocks are exactly the 8 buggy-compiler variants; none of the 9 clean rzz circuits is flagged.
  • The fake-entanglement circuits (a cx on |0>, or an all-zero-parameter ansatz) show a ~99% "Bell/GHZ signal", so verify_experiment passes them. Only the control-circuit test in falsify_claim rejects them, which is why both exist.
  • The 2 non-broken falsify_claim rejections are the rzz(0.3) pair and its buggy-compiler duplicate: a rotation that small can't be separated from noise.

Reproduce:

pip install -e ".[dev]" && python benchmarks/run_benchmark.py --json benchmarks/results.json

API

Function What it does
verify_experiment(circuit, device, *, shots, expected_marked_bitstrings, expected_amplification, tolerance) Parse → semantic → topology → shot-budget → ideal sim → native translation + synthesis check → noisy sim → ground truth. Returns a Verdict.
falsify_claim(circuit, device, marked_bitstrings=None) Control-circuit test. With marked bitstrings: isolated effect size + one-sided z-test. Without: TVD vs. the sampling-noise floor.
find_robust_circuit(candidates, device, marked_bitstrings) Noise-aware candidate ranking with held-out validation.
gate_synthesis_check(circuit, device) Native-gate inflation check; can also audit your own transpiled= circuit.
analyze_circuit_gradients(build_fn, params, n_qubits) Barren-plateau / dead-parameter check via PennyLane autodiff. Raises an install hint if PennyLane is missing.
diff_compilers(circuit, device) Qiskit vs. TKET onto the device's native basis; each output is checked by exact unitary equivalence (≤12 qubits). Degrades to Qiskit-only without TKET.

circuit is a QuantumCircuit or an OpenQASM 2/3 string. Verdict has .status ("GO"/"BLOCK"), .reason, .checks (every stage's raw result) and .metrics.

Devices and offline noise

Presets: ionq-forte-1 (all-to-all, native zz), ibm-heron (heavy-hex degree 3, native cz), ideal. Noise rates are representative order-of-magnitude figures, not live calibration data. Supply your own:

from py_quantum_verifier import get_device
dev = get_device("ibm-heron").with_noise(p1=3e-4, p2=5e-3, readout=2e-2)

The native-gate models are offline approximations (single-qubit gates compile to rz/sx/x, with rz treated as a free frame change). They reproduce the structural failure modes above, not vendor-exact pulse counts. Treat a GO as "passed these checks", not as a hardware guarantee.

Limitations

  • The "buggy compiler" is emulated (Device.with_native_equivalences(direct_rzz=False)), not a run of IonQ's real software.
  • Noise rates are representative presets, not live calibration data.
  • A GO means the circuit passed these checks, not that it will work on hardware.

Development

pip install -e ".[dev]"
pytest

MIT licensed.

Metadata

Release files for py-quantum-verifier 0.1.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 py-quantum-verifier 0.1.0
File Size Uploaded Provenance Actions
py_quantum_verifier-0.1.0.tar.gz 22.3 kB Without provenance Details for py_quantum_verifier-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-quantum-verifier 0.1.0
File Interpreter ABI Platform Actions
py_quantum_verifier-0.1.0-py3-none-any.whl Python 3 none any Details for py_quantum_verifier-0.1.0-py3-none-any.whl

Total release size: 46.0 kB

Release files / py_quantum_verifier-0.1.0.tar.gz

Download URL py_quantum_verifier-0.1.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a5260bdd3a59d5dc7e998140d32680582e4d31748a92e3993f0f118631918cdc
BLAKE2b-256 checksum
How to use checksums
0adb50d5f65042806c82e48129f8c260d94e1437e596607ad557a381a66bfa8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / py_quantum_verifier-0.1.0-py3-none-any.whl

Download URL py_quantum_verifier-0.1.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36fe3f3833bad1721ec905d9461530e942674788ce910a186453ceb0795afe8a
BLAKE2b-256 checksum
How to use checksums
f9861acf055c30e2daffa9f1921f067794d7182839bf9c40ea805204384bf9ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for py-quantum-verifier 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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