OracQ
English · 简体中文
An embedded quantum language for oracle-based scientific computing.
OracQ (ORACular Quantum) is embedded in Python and designed for quantum algorithm researchers. Composable algorithms are written against declared access models and compiled to a register-level intermediate representation (RIR) that preserves module structure and unimplemented oracle slots. Open programs can be validated, saved, and restored before choosing compatible gate-network, QRAM, or reversible-arithmetic implementations. A separate binding pass attaches these realizations, allowing the same stored algorithm to be compared across implementations through numerical validation and resource analysis.
The Python package, import name, and command-line entry point are oracq.
The current package version is 0.1.2 and the RIR format is 0.1 (full specification). Algorithms declare inputs and outputs through plain Python protocols; no language-level type-system extension is required.
Core concepts at a glance
| Concept | One-liner | Manual / spec | API reference |
|---|---|---|---|
| RIR | Register-level IR; module calls and Repeat structures survive to the text form | RIR 0.1 spec | ir |
| Builder | Builder/Operation three-stage generation of modules and programs |
Core concepts | builder |
| Registers and views | bits/uint/qubit interpretations, slicing, reinterpretation; index 0 is the least significant bit | Core concepts | ir |
| Open oracles and binding | Declare first, bind later: capability conjunction, candidate comparison, QRAM capture | Binding tutorial | linking |
| Algorithm contracts | Checkable input protocols, capability specifications, and acceptance reports | Contracts | contracts |
| Structural validation | Generation-time checks of bit widths, overlaps, and structural constraints | Core concepts | validation |
| Serialization | RIR defaults to YAML with optional JSON; both text forms agree field by field | RIR spec | serialization |
| Execution and readout | Register reference executor and host readout | Backends | execution, readout |
| QMem | Pointer-style reads/writes and multidimensional views over QRAM resources | QMem | qmem |
| QRAM data files | Loading and writing *.qram.yaml memory definitions |
QRAM memory | qram_schema |
| Math-function frontend | Python callables compiled into reversible circuits | Math functions | mathfunc |
| Resource estimation | Counting models and open analysis for T gates / rotations / QRAM accesses | Resource estimation | estimate |
| Backend export | OriginIR-ext, strict netlist, PySparQ, quantikz | Backends | backends |
A minimal program
from oracq import Bits, Builder, export_originir, simulate
b = Builder("bell_pair", {"pair": Bits(2)})
b.h(b["pair"][0])
b.xor(b["pair"][0], b["pair"][1])
program = b.finish().program()
print(simulate(program).amplitudes)
print(export_originir(program).text)
The result has equal amplitudes on 00 and 11. Module calls and Repeat
structures are preserved in RIR and in the YAML/JSON text forms; they are not
expanded during generation.
APIs used in this example: Builder ·
Bits ·
simulate ·
export_originir.
For a step-by-step walkthrough see the
first register program tutorial.
Typical workflow
| Step | Entry point | Further reading |
|---|---|---|
| 1. Declare open oracles | declare, capabilities and specs |
Algorithm contracts |
| 2. Build the program | Builder composing module calls |
Tutorial: first program |
| 3. Validate structure | validate |
Core concepts |
| 4. Bind implementations | bind; bind_with_report compares candidates |
Tutorial: replacing oracles, algorithm-research tutorial |
| 5. Export / execute / estimate | export_originir, simulate, estimate_resources |
Backends, resource estimation |
Algorithm library
The algorithm library is organized into ten subpackages by purpose; the complete catalog with selection guidance is the algorithm index, with one manual page per algorithm (interface, implementation notes, validation approach, and known gaps). Representatives per category:
| Category | Representative algorithm pages |
|---|---|
| Query and search | Grover search, amplitude estimation, quantum counting |
| Basic query algorithms | Deutsch–Jozsa, Simon, Bernstein–Vazirani |
| Fourier and arithmetic | QFT, Fourier addition, order finding |
| Hamiltonian evolution | Trotter, QSP phase synthesis, QSVT HamSim |
| Estimation and testing | QPE, Hadamard test, Swap test |
| Quantum linear systems | Costa walk, CKS, VTAA-CKS |
| QODE / QPDE | Schrödingerization, LCHS, Carleman |
| Variational and optimization | VQE, QAOA MaxCut, DQI |
| Quantum walks | coined walk, Szegedy, MNRS |
| Quantum machine learning | QPCA, QCNN, KP recommendation (API; manual page pending) |
| Data loading and input models | state preparation, XOR database, Select-Swap QROM |
| Quantum error correction | repetition codes |
Input models and operators
Algorithms consume inputs through five composable access-model families:
- Operator wrappers and basic composition (
identity/product/scale/LCU): manual, API; block-encoding algebra in block_encoding. - Oracle paradigms (XorDatabase, StatePreparation, StateOracle, SparseAccess): API.
- Quantum data structures QVector/QMatrix: manual, API.
- Density matrices and Gibbs states, spectral and low-rank decompositions: density, spectral, lowrank.
Applications
- QFVM (quantum fluid solving): manual, API, input-model review spec.
- QHAM (PDE → HAM → QHAM pipeline): manual, derivation spec, API, tutorial.
- Roe matrix elements: roe, roe_formulas.
- Case catalog: 33 reference workloads (catalog) and the gallery generator (gallery, tutorial).
Documentation map
Pick a reading path by role:
- Getting started: first program → core concepts → replacing oracles.
- Algorithm research: algorithm-research tutorial → algorithm index → validation coverage matrix; applicability boundaries in validation and scope.
- Differential-equation applications: tutorial → manual → QHAM manual.
- Backend engineering: backend manual → compatibility review → infrastructure API.
- Language and specs: RIR spec, generation-layer boundary, open IR, QRAM memory format, math IR.
Install · build · check
uv sync --locked --extra dev --extra docs
uv run python tools/build_docs.py --lang all
This builds both language trees (warnings are errors): English HTML to
out/docs (the published site root) and Chinese HTML to out/docs/zh, plus
doctest runs whose output goes to out/docs-doctest/{en,zh}. Open
out/docs/index.html to browse the generated site. Algorithm
gallery and engineering checks:
uv run python examples/algorithm_gallery.py
uv run python tools/check_project.py --docs
The algorithm gallery generates RIR, OriginIR-ext, and readout notes for 22
small examples. The full native check requires a separate environment with
pysparq and uniqc installed:
PYTHONPATH=src /path/to/backend/python examples/algorithm_gallery.py --native
The language core requires Python 3.11 or newer and depends only on PyYAML for
text serialization. The optional pyqsp extra (uv sync --extra pyqsp)
installs pyqsp for the replaceable QSP phase-synthesis adapter. Optional
backends are imported at their execution entry points; generated artifacts,
environments, and build files are never committed. See
CONTRIBUTING.md for the development workflow and the
documentation style guide; source-tree
classification and migration notes are in architecture
and import paths. Documentation is also
maintained in Chinese: see README.zh-CN.md.
Advanced algorithms such as QLSS/QODE/QHAM still have pending verification items on numerical accuracy, success channels, or convergence (per-item status in the validation coverage matrix). A general-purpose QSP-HamSim kernel is still to be provided; the current modular multiplication uses finite-size permutation synthesis, and classical optimizers for VQE/QAOA are chosen by the application.
Metadata
Release files for oracq 0.1.2
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 | Actions |
|---|---|---|---|---|
| oracq-0.1.2.tar.gz | 1.6 MB | With provenance | Details for oracq-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oracq-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for oracq-0.1.2-py3-none-any.whl |
Total release size: 2.0 MB
Release files / oracq-0.1.2.tar.gz
| Download URL | oracq-0.1.2.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa0d0d6684d7f729444b3c270e91eb315d424921ce2e661effc93dfa71d86de9
|
|
BLAKE2b-256 checksum How to use checksums |
d0ba4952c2fcd581509f0ff12bf90369320ad179c0337148c71ac1b2a61920c8
|
| 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 Nov 8, 2026.
Transparency logRelease files / oracq-0.1.2-py3-none-any.whl
| Download URL | oracq-0.1.2-py3-none-any.whl |
|---|---|
| Size | 438.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a51e428e31226c9b581536c51b09cf3d11cfd74b295fcbb8d8da123a2b5812cd
|
|
BLAKE2b-256 checksum How to use checksums |
69d5e0c3a94e6997305ff12319e22a81cef4ff60a32dcc16b2df58852d3236dc
|
| 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 Nov 8, 2026.
Transparency logSecurity for oracq 0.1.2
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
Both files in this release have been uploaded with provenance metadata.
Attestation for oracq-0.1.2.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 Nov 8, 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.