Qlens
A testing, debugging, and observability SDK for quantum programs, simulator-first.
Quantum software development lacks the testing and debugging ergonomics classical developers take for granted. Qlens packages statevector inspection, statistical output validation, and circuit equivalence checking into one pip-installable SDK for Qiskit and PennyLane, with a pytest-native testing API built on instrumented execution that captures the statevector after every gate.
import qlens
from qiskit import QuantumCircuit
def test_bell_distribution():
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
result = qlens.run(circuit)
qlens.assert_distribution(result, {"00": 0.5, "11": 0.5}, seed=0)
The same test body works against a PennyLane QNode unchanged, and produces the same canonical results: Qlens defines one semantic convention (big-endian bitstrings, canonical basis ordering) and every backend converts at its own boundary.
Install
pip install qlens[qiskit]
Extras: qlens[qiskit], qlens[pennylane], or both. Python 3.11+. Simulator-only; no quantum hardware access is involved anywhere.
What it does
qlens.run(circuit): instrumented execution capturing the statevector after every gate, with lazy sampled counts.qlens.assert_distribution(result, expected): validates measurement output against an expected distribution by chi-square, a simulated p-value, total variation distance, or KS. When a method's assumptions don't hold for your data, Qlens says so and names the alternatives rather than switching methods behind your back.qlens.assert_state(result, expected, at=96): the statevector at any point in the run, compared by fidelity up to global phase.at=works onassert_distributiontoo, so checks mark the position they apply to.qlens.assert_unitary(circuit): unitarity within numerical tolerance.qlens.assert_equivalent(a, b): same unitary up to global phase, across different gate decompositions.qlens.inspect(result): step-through debugging over the captured snapshots (cursor, per-position probabilities, state diffs with fidelity), with no re-execution.qlens.run(circuit, trace=True): records the run as a TraceAct trace with statevector sidecars, assertion pass/fail events, and per-run event budgets.qlens view traces.jsonl: a local viewer over recorded runs — the amplitude waterfall across every gate position, the statevector at any point against what a test expected, an A/B diff between two positions, and clickable assertion markers. A built-in reading guide explains all of it for people new to quantum computing.qlens view --demoopens it on sample runs.- Project settings in
pyproject.tomlunder[tool.qlens], orqlens.configure(), choosing how distributions are compared and what happens when a test's assumptions don't hold. Any call overrides them, and the settings in force are recorded onto the run. - A bundled pytest plugin: fixtures, a
qlensmarker, and automatic trace finalization per test. - A public backend contract with entry-point discovery, so further frameworks (Cirq and beyond) plug in as separate packages certified against a shipped conformance suite.
Documentation
- USAGE.md: the full manual with runnable examples.
- CONVENTIONS.md: the semantic conventions every backend follows.
- ARCHITECTURE.md: component diagram and contracts.
- CHANGELOG.md: dated changes per version.
Status
Published on PyPI. Early: the public API follows semver and the surfaces described here are the ones to build against, but expect it to keep growing quickly.
License
MIT.
Built by Mo Shehu — mohammedshehu.com
Release files for qlens 0.4.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 | |
|---|---|---|---|
| qlens-0.4.0.tar.gz | 126.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qlens-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 225.8 kB
Release files / qlens-0.4.0.tar.gz
| Download URL | qlens-0.4.0.tar.gz |
|---|---|
| Size | 126.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f625b5a7e17651df5a540028183af47495282058cbfccfca5c21ecf9421104b
|
|
BLAKE2b-256 checksum How to use checksums |
9fcba52c57f45c0c69d88f04eeab76ac12c7a19bbc8e54dd1f77d6a062a4d740
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 10, 2026.
Transparency logRelease files / qlens-0.4.0-py3-none-any.whl
| Download URL | qlens-0.4.0-py3-none-any.whl |
|---|---|
| Size | 99.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e767f548cf25feb686ae65492c9ed3eba041e0be0ed1b93611732c623dd9215
|
|
BLAKE2b-256 checksum How to use checksums |
5a5b4ae58ad1ae7e6377b162a1f8914fa5e0787cfa5009aea3a6de53d6941859
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 10, 2026.
Transparency log