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, PennyLane, and Cirq, 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 or a Cirq Circuit 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], qlens[cirq], or any combination. 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. Hovering names the gate at a column and the others running alongside it; zooming in gives each basis state its own row back once the range fits the panel. 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 plug in as separate packages certified against a shipped conformance suite. Qiskit, PennyLane, and Cirq all register through it, with no private shortcuts.
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.
The viewer bundles two typefaces, Space Grotesk and Commit Mono, both under
the SIL Open Font License 1.1. Their licences ship beside them in
src/qlens/viewer/static/fonts/.
Built by Mo Shehu — mohammedshehu.com
Release files for qlens 0.5.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.5.0.tar.gz | 312.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qlens-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 581.1 kB
Release files / qlens-0.5.0.tar.gz
| Download URL | qlens-0.5.0.tar.gz |
|---|---|
| Size | 312.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ca4e5e856648ab34f37329eb6ad55ab05b7790a3675a8217c0bad694f8d3a7c
|
|
BLAKE2b-256 checksum How to use checksums |
68020c7af864b60cac8d28950a68b9466d52477d53fb7b35bae0128800826cf8
|
| 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 11, 2026.
Transparency logRelease files / qlens-0.5.0-py3-none-any.whl
| Download URL | qlens-0.5.0-py3-none-any.whl |
|---|---|
| Size | 269.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1ef120ff7d1ab02bb0a37bfa38b76e7cb473d5f153206a429387e13c812ee44
|
|
BLAKE2b-256 checksum How to use checksums |
6f215d075b23b4c01c82981a472098041589bf3e63b0634da427637cfdb5a82e
|
| 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 11, 2026.
Transparency log