Quaternionic quantum compiler for the RQM ecosystem
Project description
rqm-compiler
rqm-compiler is the backend-neutral compilation layer for the RQM ecosystem.
It converts RQM circuit objects into canonical gate descriptors that can be translated
by execution backends such as Qiskit and Amazon Braket.
Ecosystem position
RQM physics / math
↓
rqm-core
↓
rqm-compiler ← this repo
↓
rqm-qiskit rqm-braket
rqm-compiler sits between the physics math layer (rqm-core) and the vendor execution
layers. It does not implement quantum math and does not import vendor SDKs.
Quick start
from rqm_compiler import Circuit, compile_circuit
c = Circuit(2)
c.h(0)
c.cx(0, 1)
c.measure(0, key="m0")
c.measure(1, key="m1")
compiled = compile_circuit(c)
print(compiled.descriptors)
# [
# {'gate': 'h', 'targets': [0], 'controls': [], 'params': {}},
# {'gate': 'cx', 'targets': [1], 'controls': [0], 'params': {}},
# {'gate': 'measure', 'targets': [0], 'controls': [], 'params': {'key': 'm0'}},
# {'gate': 'measure', 'targets': [1], 'controls': [], 'params': {'key': 'm1'}},
# ]
Installation
pip install rqm-compiler
Or in development mode from the repository root:
pip install -e ".[dev]"
Core concepts
Canonical descriptor
Every gate operation is represented as a plain dictionary:
{
"gate": "rx", # lowercase gate name
"targets": [0], # list of target qubit indices (always present)
"controls": [], # list of control qubit indices (always present)
"params": {"angle": 1.5707963267948966} # parameter dict (always present)
}
This is the source of truth for the entire ecosystem. Backend repos translate these descriptors into their respective SDK objects.
Circuit
Circuit(num_qubits) is the canonical circuit container. It provides a fluent builder API:
from rqm_compiler import Circuit
c = Circuit(3)
# Single-qubit gates
c.i(0); c.x(0); c.y(1); c.z(2); c.h(0); c.s(1); c.t(2)
# Parameterised single-qubit gates
c.rx(0, 1.57).ry(1, 0.78).rz(2, 3.14).phaseshift(0, 0.5)
# Two-qubit gates
c.cx(0, 1).cy(1, 2).cz(0, 2)
c.swap(0, 1).iswap(1, 2)
# Measurement
c.measure(0, key="m0")
# Barrier
c.barrier()
# Export
descriptors = c.to_descriptors()
compile_circuit
compile_circuit(circuit) is the main entry point:
from rqm_compiler import compile_circuit
compiled = compile_circuit(c)
compiled.descriptors # list of canonical descriptor dicts
compiled.num_qubits # int
compiled.metadata # dict with compilation metadata
The pipeline: validate → normalize → canonicalize → flatten → export.
IO helpers
from rqm_compiler.io import circuit_to_dict, circuit_from_dict
data = circuit_to_dict(c) # serialize to JSON-compatible dict
restored = circuit_from_dict(data) # reconstruct Circuit from dict
Supported gates (v0)
| Category | Gates |
|---|---|
| Single-qubit | i x y z h s t |
| Parameterised single-qubit | rx ry rz phaseshift (param: angle) |
| Two-qubit | cx cy cz swap iswap |
| Other | measure barrier |
Backend integration
Backend repos use rqm-compiler like this:
from rqm_compiler import compile_circuit
compiled = compile_circuit(circuit)
for op in compiled.descriptors:
translate_to_backend(op)
The backend never needs to re-implement normalization, validation, or gate naming conventions.
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Architecture rules
See AGENTS.md for the full list of contributor boundary rules.
Project details
Release history Release notifications | RSS feed
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 rqm_compiler-0.1.5.tar.gz.
File metadata
- Download URL: rqm_compiler-0.1.5.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20d4a45bd02cc05488a93649a60c1a4b3afc55b86bade6829ae1d8d2f5c7277a
|
|
| MD5 |
c7a23b341738de00a77f2f4d8e5f740f
|
|
| BLAKE2b-256 |
5cc27da93480da51dd596af2b4fae0a572c7ad45b8bbc518f2784f2bdab865e7
|
Provenance
The following attestation bundles were made for rqm_compiler-0.1.5.tar.gz:
Publisher:
publish.yml on RQM-Technologies-dev/rqm-compiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rqm_compiler-0.1.5.tar.gz -
Subject digest:
20d4a45bd02cc05488a93649a60c1a4b3afc55b86bade6829ae1d8d2f5c7277a - Sigstore transparency entry: 1140721051
- Sigstore integration time:
-
Permalink:
RQM-Technologies-dev/rqm-compiler@94e21a6313ac0bddf9610ea4b180e50b23e0b9aa -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/RQM-Technologies-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@94e21a6313ac0bddf9610ea4b180e50b23e0b9aa -
Trigger Event:
release
-
Statement type:
File details
Details for the file rqm_compiler-0.1.5-py3-none-any.whl.
File metadata
- Download URL: rqm_compiler-0.1.5-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7029fff27bf3af508705566edf07249b8461e1d87c1eb2a287c1afed4e9d8050
|
|
| MD5 |
3cd84b8c0c3dc936d40c21733e5d6509
|
|
| BLAKE2b-256 |
f1d91083b001164c4543b0d238adff10b2e0047319cb3cb4afeb71a2f04d3396
|
Provenance
The following attestation bundles were made for rqm_compiler-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on RQM-Technologies-dev/rqm-compiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rqm_compiler-0.1.5-py3-none-any.whl -
Subject digest:
7029fff27bf3af508705566edf07249b8461e1d87c1eb2a287c1afed4e9d8050 - Sigstore transparency entry: 1140721146
- Sigstore integration time:
-
Permalink:
RQM-Technologies-dev/rqm-compiler@94e21a6313ac0bddf9610ea4b180e50b23e0b9aa -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/RQM-Technologies-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@94e21a6313ac0bddf9610ea4b180e50b23e0b9aa -
Trigger Event:
release
-
Statement type: