Quantum computing state vector simulator with linear XEB benchmarking
Project description
Qomputing Simulator
A lightweight, pure Python state-vector simulator with linear cross-entropy benchmarking (XEB). For contributors and users who install from source.
Install
From the project root:
git clone <this-repo-url>
cd simulator # or your clone directory
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
[dev]addspytest. For a normal (non-editable) install:pip install .
Without cloning (if the package is published):
pip install qomputing
# Optional: pip install qomputing[dev]
Usage
CLI
# Random circuit + XEB
qomputing-sim random-circuit --qubits 3 --depth 5 --shots 1000
# Simulate from JSON
qomputing-sim simulate --circuit path/to/circuit.json --shots 512 --seed 42
Optional: --max-qubits, --max-shots to cap resources; --single-qubit-gates, --two-qubit-gates, --multi-qubit-gates to override default gate sets.
Library
Backend API:
from qomputing import QomputingSimulator, QuantumCircuit
backend = QomputingSimulator.get_backend("state_vector")
qc = QuantumCircuit(4, 4)
qc.h(0).cx(0, 1).measure(range(3), range(3))
result = backend.run(qc, shots=1024)
print(result.get_counts())
Direct run:
from qomputing import run, QuantumCircuit, run_xeb, random_circuit
qc = QuantumCircuit(2)
qc.h(0).cx(0, 1)
result = run(qc, shots=1000, seed=42)
print(result.final_state, result.probabilities, result.counts)
qc = random_circuit(num_qubits=3, depth=5, seed=7)
xeb = run_xeb(qc, shots=1000, seed=7)
print(xeb.fidelity, xeb.sample_probabilities)
Rotation gates use qubit first, then angle: e.g. qc.rz(qubit, theta), qc.ry(qubit, theta).
Measure takes sequences: e.g. qc.measure([0], [0]) for one qubit; qc.measure_all() if num_clbits >= num_qubits.
Repository layout
qomputing/
├── circuit.py # QuantumCircuit, gates, measure, JSON (de)serialization
├── circuit_builders.py # random_circuit for XEB
├── gates/ # Single-, two-, multi-qubit gate implementations
├── engine/ # State vector core, measurements, registry
├── linalg.py # Tensor / linear algebra helpers
├── cli.py # qomputing-sim entry point
├── xeb.py # Linear XEB fidelity
├── backend.py # QomputingSimulator, Result
├── run.py # run(), load_circuit(), run_xeb()
├── visualisation*.py # Circuit drawer and Bloch (optional)
tools/
├── cirq_comparison.py # Parity tests vs Cirq
tests/ # Pytest: parity, limits, XEB, drawer, bugs
Circuit JSON format
{
"num_qubits": 2,
"gates": [
{"name": "h", "targets": [0]},
{"name": "cx", "controls": [0], "targets": [1]},
{"name": "rz", "targets": [0], "params": {"theta": 1.5708}}
]
}
Supported gates: single-qubit id, x, y, z, h, s, sdg, t, tdg, sx, sxdg, rx, ry, rz, u1, u2, u3; two-qubit cx, cy, cz, cp, csx, swap, iswap, sqrtiswap, rxx, ryy, rzz; multi-qubit ccx, ccz, cswap.
Testing
pytest
Parity vs Cirq (optional):
export PYTHONPATH="$PWD"
python tools/cirq_comparison.py --min-qubits 1 --max-qubits 5 --depths 3 5 --circuits-per-config 3 --shots 256 --seed 7
Development
- Run
pytestbefore committing. - Use
CONTRIBUTING.mdfor contribution guidelines (if present). - Build package:
python -m build(createsdist/). For publishing to PyPI, use./scripts/publish-to-pypi.sh(maintainer only).
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qomputing-0.1.6.tar.gz.
File metadata
- Download URL: qomputing-0.1.6.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c23e46167629d3b9c61fe15e0f35ac1326397199586e609d672c1e971ae4081
|
|
| MD5 |
bb11b979f95ffd1ea360be0d7ad2c0a1
|
|
| BLAKE2b-256 |
2598865c6241700f6c74bd2dee502d136479b0492017f58e0786fa9a645f30eb
|
File details
Details for the file qomputing-0.1.6-py3-none-any.whl.
File metadata
- Download URL: qomputing-0.1.6-py3-none-any.whl
- Upload date:
- Size: 37.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a155f88f700db2fac906cc85cf11b8e6ca53cfdb465dcee6cd443b4ed3bf5b
|
|
| MD5 |
ef6030605fcd6013a9ef4c2ba5a97bbc
|
|
| BLAKE2b-256 |
bfabfd4474fcc852cb33a436f12567cac81044cf05d847db791c50212dbde900
|