Skip to main content

oracq

English · 简体中文

CI Docs PyPI Python License: MIT

oracq is a scientific-computing algorithm implementation framework for quantum algorithm researchers. Composable algorithms are written in Python against access models and compiled to a register-level intermediate representation (RIR) that preserves module structure; oracle placeholders stay unimplemented until you compare gate-network, QRAM, and reversible-arithmetic candidates, bind them, and proceed to numerical validation and resource analysis.

The current package version is 0.1.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 to out/docs/en/html and Chinese to out/docs/zh/html, plus doctest runs. Open out/docs/en/html/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 depends only on PyYAML for text serialization. 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 QLS/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.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.1.0
File Size Uploaded
oracq-0.1.0.tar.gz 1.3 MB Details

Built distribution (wheel)

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

Total release size: 1.7 MB

Release files / oracq-0.1.0.tar.gz

Download URL oracq-0.1.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
6b570c0b967988fbece3f0c787d33fdba351a651e0283dfab3a304d5528b0b5d
BLAKE2b-256 checksum
How to use checksums
ba4de361cc2ac19a4d93f88ceadfbed4d798b3e77d96ab259cad5e3e1c753fab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

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

Download URL oracq-0.1.0-py3-none-any.whl
Size 404.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f78cace9d38677b8f9a0fd8a61a1e894231695d98e7f5262befc4cfab174d9ae
BLAKE2b-256 checksum
How to use checksums
e88487fd30870d233db90068e90ef4a0ce192646b6ae472e05c78a2ce43d5b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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