Skip to main content

BornLens

BornLens compares a Pauli expectation before and after a quantum circuit change. It reports the measured change, a finite-sample confidence interval and a tolerance verdict. Part of the PhaseTensor Quantum Computing Suite.

Install from a checkout with python -m pip install .. For ideal Qiskit simulation use python -m pip install '.[qiskit]'.

from bornlens import Sample, compare, shots_per_circuit

before = Sample("Z", plus=7500, minus=2500)
after = Sample("Z", plus=7550, minus=2450)
result = compare(before, after, tolerance=0.05)
print(result.verdict, result.delta, result.interval)
# within_tolerance, approximately 0.01 and (-0.0284, 0.0484)
print(shots_per_circuit(0.05))  # 5903 shots per circuit at 95% confidence

Statistical protocol

Fix the observable, tolerance, confidence and sample sizes before collecting data. Assume independent shots within and between circuits, with a stable outcome distribution for each circuit. Each measured eigenvalue is +1 or -1. The sample mean is (plus - minus) / shots. The estimated change is mean B minus mean A.

For confidence 1 - alpha, apply the two-sided Hoeffding bound to the weighted sum of the independent signed outcomes. Each A contribution has range width 2/nA and each B contribution has width 2/nB. The resulting half-width is sqrt(2 log(2/alpha) (1/nA + 1/nB)). Intersect the interval with [-2, 2]. For the identity observable the change is exactly zero. Hoeffding gives a conservative finite-sample bound even for unanimous outcomes. A normal approximation using empirical variance can give zero width for those samples.

An interval contained in the closed tolerance band gives within_tolerance. An interval strictly above or below the band gives beyond_tolerance. All other intervals give inconclusive. Touching a boundary from outside is inconclusive. Coverage concerns one prespecified comparison. Drift, correlated shots, repeated looks and multiple comparisons require separate treatment.

For equal sample sizes the sufficient shots per circuit for half-width h are ceil(4 log(2/alpha) / h²). This controls precision. The verdict also depends on the distance of the true change from the tolerance boundary.

Reference: Hoeffding (1963), Probability Inequalities for Sums of Bounded Random Variables.

Qiskit

from qiskit import QuantumCircuit
from bornlens.qiskit import compare_circuits

a = QuantumCircuit(1)
b = a.copy()
b.x(0)
result = compare_circuits(a, b, "Z", shots_a=1000, shots_b=1500,
                          tolerance=0.1, seed=17)
print(result.verdict)  # beyond_tolerance

Pass bound gate circuits before measurements. Rightmost Pauli factor acts on qubit 0. The adapter rotates X with H and Y with S-dagger followed by H, then computes parity over nonidentity factors. For external integer counts use from_counts(counts, label) after applying these basis rotations and measuring qubit i into classical bit i of one full-width register. The caller supplies the measurement basis and mapping. The simulator uses separate random streams for A and B. Run the checks with python -m unittest discover -s tests -v.

Validation and release 0.1.0

Install the release with python -m pip install bornlens==0.2.0. For development install the checkout with the Qiskit extra and run python benchmarks/coverage.py to reproduce the benchmark counts. Each row contains 5,000 independent trials with a fixed seed, tolerance 0.1 and nominal coverage 95%. The samples follow the exact Z measurement law of ideal single-qubit Ry circuits. Incorrect counts exclude inconclusive decisions. The benchmark covers five true changes and three shot budgets. It measures ideal fixed-shot behavior; hardware drift and correlated noise require separate experiments.

Statistical extensions

Install the stats extra with python -m pip install 'bornlens[stats]'. See methods, power and hardware evidence and the changelog.

Metadata

Release files for bornlens 0.2.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 bornlens 0.2.0
File Size Uploaded Provenance Actions
bornlens-0.2.0.tar.gz 23.2 kB With provenance Details for bornlens-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bornlens 0.2.0
File Interpreter ABI Platform Actions
bornlens-0.2.0-py3-none-any.whl Python 3 none any Details for bornlens-0.2.0-py3-none-any.whl

Total release size: 35.2 kB

Release files / bornlens-0.2.0.tar.gz

Download URL bornlens-0.2.0.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e3ae7ec32a4f584b6558983402fd6489809a372fe33222e5076fa78ed40e8a26
BLAKE2b-256 checksum
How to use checksums
44e516ecd9850ce0a9d374148167ceb1612744501cafd1ae1f686e6dcf34b113
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 Nov 27, 2026.

Transparency log

Release files / bornlens-0.2.0-py3-none-any.whl

Download URL bornlens-0.2.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d224fd3253d74fc9068ae8cefb551903883bbe65ebbc2b9d523b32d2e6cfe4a2
BLAKE2b-256 checksum
How to use checksums
fe0a0489818a9a26a8599c02b0e4d4f225e558b33ec361f7494de916f0f9ed8c
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 Nov 27, 2026.

Transparency log

Security for bornlens 0.2.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bornlens-0.2.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 Nov 27, 2026.

Transparency log

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.2.0 This release

2 release files Full 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