metatron-qso (Python)
Python bindings for QSO, a validated quantum simulator written in
pure Rust (metatron-qso-rs): exact state-vector and density-matrix
simulation, VQE and QAOA with exact gradients, Grover search, QFT and phase
estimation, and continuous-time quantum walks on arbitrary graphs —
including Metatron's Cube. Every algorithm is tested against closed-form or
literature results.
Install
pip install metatron-qso
Wheels target the stable ABI (abi3, one wheel for CPython ≥ 3.9) and are
provided for Linux (x86_64, aarch64; glibc and musl), macOS (Intel and Apple
silicon) and Windows (x86_64, arm64). The only runtime dependency is NumPy. On other platforms
pip builds from the source distribution, which needs a Rust toolchain
≥ 1.89.
From a clone of the repository:
pip install maturin
maturin develop --release -m metatron_qso_py/Cargo.toml # into the active venv
Conventions
- Qubit 0 is the least significant bit of a basis index (as in Qiskit); bit
strings print qubit n−1 first (
"001"means qubit 0 is 1). - Rotations are
R_P(θ) = exp(−iθP/2); time evolution isexp(−iHt). - Vectors and matrices are NumPy
float64/complex128arrays; array arguments accept lists, tuples or arrays. - Invalid input raises
ValueErrorwith a descriptive message. - Long-running calls (VQE, QAOA, walks, simulation) release the GIL.
Examples
Circuits, sampling and observables:
import metatron_qso as q
bell = q.Circuit(2).h(0).cx(0, 1)
state = q.simulate(bell)
print(state.amplitudes) # complex128 array of length 4
print(state.sample(1000, seed=1)) # {'00': ..., '11': ...}
print(state.expectation(q.PauliSum("Z0 Z1"))) # 1.0
print(state.entanglement_entropy([0])) # 1.0 (bits)
Symbolic parameters, exact gradients and OpenQASM 2.0:
import numpy as np
import metatron_qso as q
c = q.Circuit(2)
a, b = c.new_parameters(2)
c.ry(0, a).cx(0, 1).rz(1, 2.0 * b + 0.5)
h = q.PauliSum("0.5*Z0 Z1 - X0")
value, grad = q.expectation_and_gradient(c, h, [0.3, 0.1]) # adjoint method
_, fd = q.expectation_and_gradient(c, h, [0.3, 0.1], method="finite_difference")
assert np.allclose(grad, fd, atol=1e-6)
text = c.to_qasm([0.3, 0.1], measure=True)
again = q.Circuit.from_qasm(text)
Ground state of H₂ (STO-3G) with VQE:
import metatron_qso as q
h2 = q.h2_sto3g()
result = q.run_vqe(h2["hamiltonian"], q.real_amplitudes(2, 1), restarts=4)
print(result["energy"] + h2["nuclear_repulsion"]) # -1.137306 Ha (full CI)
QAOA for MaxCut (depth 1 on a ring gives exactly 3/4):
import metatron_qso as q
qaoa = q.MaxCutQaoa(q.Graph.cycle(8), p=1)
result = qaoa.optimize(restarts=8, seed=0)
print(result["approximation_ratio"]) # 0.75
print(result["most_likely_bitstring"]) # an optimal cut, e.g. '10101010'
Quantum walks on Metatron's Cube (the complete graph K13 on the 13 Fruit-of-Life centres):
import math
import metatron_qso as q
cube = q.Graph.metatron_cube()
print(cube.automorphism_group_order()) # 6227020800 = 13!
walk = q.ContinuousWalk(cube) # H = γL, γ = 1
print(walk.limiting_distribution(0)[:2] * 169) # [145. 2.]
search = q.SpatialSearch(cube, marked=[4], gamma=1 / 13)
print(search.success_probability(math.pi * math.sqrt(13) / 2)) # 1.0
Noise:
import metatron_qso as q
bell = q.Circuit(2).h(0).cx(0, 1)
rho = q.DensityMatrix.simulate(bell, noise=q.NoiseModel.depolarizing(0.01, 0.02))
print(rho.purity(), rho.fidelity_with_pure(q.simulate(bell)))
energy = q.estimate_expectation(bell, q.PauliSum("Z0 Z1"), shots=10_000,
noise=q.NoiseModel.depolarizing(0.01, 0.02))
More complete scripts are in
examples/;
the user guide has tutorials and the full
API reference.
API overview
| Area | Names |
|---|---|
| Graphs | Graph (from_spec, metatron_cube, fruit_of_life, metatron_distance_graph, complete, cycle, path, star, complete_bipartite, hypercube, petersen, grid, platonic, random_regular, erdos_renyi, heawood; girth, triangle_count, automorphisms, spectra), metatron_line_lengths |
| Circuits | Circuit, Parameter, qft, inverse_qft, grover_circuit |
| States | StateVector, simulate, PauliSum, bitstring |
| Models | h2_sto3g, transverse_field_ising, heisenberg_xxz, maxcut_cost |
| Variational | real_amplitudes, efficient_su2, hardware_efficient, qaoa_maxcut_circuit, expectation_and_gradient, run_vqe, MaxCutQaoa, optimize_qaoa_layerwise, VariationalClassifier, GraphClassifier |
| Textbook | grover_search, estimate_phase |
| Walks | ContinuousWalk, SpatialSearch (optimize tunes rate and time jointly), DephasingWalk, classical_walk_probabilities, classical_hitting_times |
| Noise | Channel, NoiseModel, DensityMatrix, estimate_expectation |
| Boson sampling | BosonSampler, permanent, haar_unitary, beam_splitter |
Graph.from_spec accepts the graph specifications of the qso command-line
tool, e.g. "metatron", "metatron:1", "hypercube:4", "platonic:cube"
(full list in the
main README).
Type information ships with the package (_core.pyi, py.typed).
Optimisers for run_vqe / MaxCutQaoa.optimize: lbfgs (default), adam,
gradient_descent, nelder_mead, spsa. Gradient methods: adjoint
(default), parameter_shift, finite_difference.
Tests
pip install pytest
pytest metatron_qso_py/tests -q
License
Apache-2.0
Metadata
Release files for metatron-qso 1.2.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 | |
|---|---|---|---|---|
| metatron_qso-1.2.0.tar.gz | 222.2 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| metatron_qso-1.2.0-cp39-abi3-win_arm64.whl | CPython 3.9 | abi3 | Windows ARM64 | Details |
| metatron_qso-1.2.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ x86-64 | Details |
| metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ ARM64 | Details |
| metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| metatron_qso-1.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) | Details |
Total release size: 8.2 MB
Release files / metatron_qso-1.2.0.tar.gz
| Download URL | metatron_qso-1.2.0.tar.gz |
|---|---|
| Size | 222.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
215a3fe4eb79e8d152a9400a6ff2a41531ba78673fb48c251d33ae3339758a36
|
|
BLAKE2b-256 checksum How to use checksums |
949c638ed5e5e426615315594e43df8cc7936042eb13e55d6b1b804ffc2fac43
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-win_arm64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 826.2 kB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
7c278f077e8a3be88318747d767502dbf403f217a99953cf25abd51cfbc65363
|
|
BLAKE2b-256 checksum How to use checksums |
48b4f7c72afd80b5c9bc184353196d108c7462a32b824312b64b6c8ee945f24e
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-win_amd64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 907.4 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5119fd8226133529272e5717bab6136b5f07927fc93ca68c33d2ef2dfedf13eb
|
|
BLAKE2b-256 checksum How to use checksums |
638c22df1bbfcc3c13da435a527908a950d8e6e6b02a296f1c424cf3c0b1e0e4
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
715dfec5053dd7458432c76d62242a18f9d26bd7b673e1b236202fb995b389a4
|
|
BLAKE2b-256 checksum How to use checksums |
2f5dce44e2288c686e7b7fed198cb0b9dadfeb60d44de01ffc8f2ab189aae222
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d3705f0a31de52efd00066884ff91f5f64b2477fe779b3c4ea3df0745e3ddfb4
|
|
BLAKE2b-256 checksum How to use checksums |
d256ccda1ce75073ea6a5a44c68eaa3484f22016328c0fc1d508f6368edf20be
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5dc37117c77ae44f3440b58a16be176e6740526dd45909bd46b4b1dbfac2a520
|
|
BLAKE2b-256 checksum How to use checksums |
4a65d8a5563b6eed751d72b7bae80434932a0dd7d82d38130d57f93d956518b4
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 973.2 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
3294a7e6103d6a4843aeb88093763da4e926ca311670514a7847b043a4fa95d8
|
|
BLAKE2b-256 checksum How to use checksums |
c3348a0e73654cf3a023aad73fc53655346687a776728d3a62573e1c01bea79e
|
| 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 Oct 24, 2026.
Transparency logRelease files / metatron_qso-1.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | metatron_qso-1.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dee621f1644e84e50d5ef8a5f1401fa4447128c7c6e7c9b7b79ca961670c547a
|
|
BLAKE2b-256 checksum How to use checksums |
08a1a02cfaadbc8b725c35dc5b69f1331f45de2fbb0dbf1992e2290834d4d206
|
| 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 Oct 24, 2026.
Transparency logSecurity for metatron-qso 1.2.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
All 8 files in this release have been uploaded with provenance metadata.
Attestation for metatron_qso-1.2.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 Oct 24, 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.