Qiberis
A small, backend-agnostic quantum circuit API. Write a circuit once against a minimal intermediate representation (IR), and run it unmodified on Qiskit Aer, Cirq, or PennyLane (lightning.qubit) — with results returned in one normalized format.
from qiberis import Circuit
from qiberis.backends.qiskit_backend import QiskitAerBackend
from qiberis.backends.cirq_backend import CirqSimulatorBackend
from qiberis.backends.pennylane_backend import PennyLaneLightningBackend
# Build a 3-qubit GHZ state, once.
circuit = Circuit(3)
circuit.h(0).cx(0, 1).cx(1, 2).measure_all()
for backend_cls in (QiskitAerBackend, CirqSimulatorBackend, PennyLaneLightningBackend):
backend = backend_cls()
result = backend.run(circuit, shots=1000)
print(result)
Why
Qiskit, Cirq, and PennyLane each have their own circuit objects, gate names,
execution APIs, and — critically — their own bit-ordering conventions for
returned counts. Comparing results across them, or writing code that should
work regardless of which simulator is installed, means re-solving the same
translation problem every time. Qiberis solves it once.
Install
pip install -e ".[all]" # all three backends
pip install -e ".[qiskit]" # just Qiskit Aer
pip install -e ".[cirq]" # just Cirq
pip install -e ".[pennylane]" # just PennyLane
Each backend is an optional dependency — the core package
(qiberis.Circuit, qiberis.Result) has zero hard dependencies, and each
adapter raises a clear ImportError telling you what to install if you try
to use a backend you haven't installed.
Architecture
qiberis/
circuit.py # Circuit + Instruction: the backend-agnostic IR
result.py # Result: normalized counts/probabilities
backends/
base.py # Backend ABC — one method: run(circuit, shots) -> Result
qiskit_backend.py
cirq_backend.py
pennylane_backend.py
tests/
test_cross_backend.py # runs the same circuits on every installed backend
# and checks they agree with each other
Supported gates: h, x, y, z, s, t, rx, ry, rz, cx, cz, swap, ccx, barrier, measure. Extending to a new gate means adding one line to each adapter's
translation table.
Bit-ordering convention
This is the part that silently breaks most "universal circuit" projects.
Qiskit's native count strings are little-endian (clbit 0 is the
rightmost character); Cirq and PennyLane's qml.counts(wires=...) are
naturally ordered with the first wire/clbit leftmost.
Qiberis's convention: in every Result.counts key, the leftmost
character is always clbit/qubit 0. The Qiskit adapter reverses its native
strings to match; Cirq and PennyLane need no adjustment. This is covered by
a dedicated regression test, test_bit_ordering, which runs an asymmetric
circuit (X on qubit 0 only) through every backend and checks all three
report the same string.
Adding a new backend
- Create
qiberis/backends/your_backend.py - Subclass
Backend, implementrun(self, circuit, shots) -> Result - Translate
Circuit.instructionsinto your library's native circuit object - Normalize your library's raw output into Qiberis's bit-ordering convention
- Add your backend to the
BACKENDSlist intests/test_cross_backend.py— the existing GHZ, bit-ordering, and cross-agreement tests will immediately validate it against the others
Roadmap
- Real hardware backends (IBM Quantum, AWS Braket QPUs) behind the same interface
- A transpiler/optimization pass operating directly on the IR
- Parametric circuits / variational workflows (bind params without rebuilding)
- Statevector + expectation-value result modes, not just counts
- More gates:
u,crx/cry/crz,iswap, multi-controlled gates
License
MIT
Metadata
Release files for Qiberis 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 | |
|---|---|---|---|
| qiberis-0.1.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qiberis-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.3 kB
Release files / qiberis-0.1.0.tar.gz
| Download URL | qiberis-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae20286aeb892dc3874e852d1b03676ee1672805ad7c0ebe7bd2870a698720f9
|
|
BLAKE2b-256 checksum How to use checksums |
04d9c3efbec0f98b88ceb77443aaeae0df2c603b6c3803d063a32e413067db72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / qiberis-0.1.0-py3-none-any.whl
| Download URL | qiberis-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76d89d7d17f492b272b2ab579a13bc4a732cfc25d0ef8da119ce88084a24148c
|
|
BLAKE2b-256 checksum How to use checksums |
d33a73b0d08fb9e706e5944b1bf877c0901ce5d2e27b0dd73640636270a4b57d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|