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.1.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.
Metadata
Release files for bornlens 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 | Actions |
|---|---|---|---|---|
| bornlens-0.1.0.tar.gz | 10.5 kB | With provenance | Details for bornlens-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bornlens-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bornlens-0.1.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / bornlens-0.1.0.tar.gz
| Download URL | bornlens-0.1.0.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47c706d540fd1feb4c26f0a07e8ded4dbbbba9224c302789cdbccd9765f4c945
|
|
BLAKE2b-256 checksum How to use checksums |
1945d6cd9833254e9baecafc5ae3afeaf6efb68f1fcd390c25c4c1d1a0abbbec
|
| 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 logRelease files / bornlens-0.1.0-py3-none-any.whl
| Download URL | bornlens-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f74bbfcb6150713fa6e558b16abf31d3aaab1b2a4b3a1f5bed9c3e85a1b826c
|
|
BLAKE2b-256 checksum How to use checksums |
bad05954ed1dcd3e1aaa167bfa52fb6bec5edb571d5e0e74eacca1acef2afa4b
|
| 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 logSecurity for bornlens 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
Both files in this release have been uploaded with provenance metadata.
Attestation for bornlens-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 Nov 27, 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.