Skip to main content

OracQ

English · 简体中文

CI Docs PyPI Python License: MIT

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.

Run oracq gui for the self-contained local compiler studio: edit a pure function, compare checkpoint space and gate costs at the same precision, and export standard RIR JSON or a strict modular gate netlist. See the CLI manual for its bounded editor and the general compile-function command.

The current package version is 0.2.0 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

Documentation map

Pick a reading path by role:

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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oracq 0.3.0
File Size Uploaded Provenance Actions
oracq-0.3.0.tar.gz 1.6 MB With provenance Details for oracq-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oracq 0.3.0
File Interpreter ABI Platform Actions
oracq-0.3.0-py3-none-any.whl Python 3 none any Details for oracq-0.3.0-py3-none-any.whl

Total release size: 2.1 MB

Release files / oracq-0.3.0.tar.gz

Download URL oracq-0.3.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
41398ed0cc355977ff5cf8144e482c53dccde55c632821c9d2c450f205f78d30
BLAKE2b-256 checksum
How to use checksums
f2a7990e714d955f12d2605e8b35c638f05c102bd4f47801c7a0a1d484893759
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 9, 2026.

Transparency log

Release files / oracq-0.3.0-py3-none-any.whl

Download URL oracq-0.3.0-py3-none-any.whl
Size 449.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
650ae07e0155874028bea76bebc48a98e7d7af89ae505c8867c6947126331879
BLAKE2b-256 checksum
How to use checksums
73380d5ab555099af2c6868fc5de80a114317f9e2c0b6c9792cac3671ea7f4d8
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 9, 2026.

Transparency log

Security for oracq 0.3.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for oracq-0.3.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 Nov 9, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page