Skip to content

Commit 5fc675f

Browse files
Merge pull request #4 from RQM-Technologies-dev/copilot/update-docs-rqm-optimize-stack
docs: align rqm-optimize positioning with modern RQM stack
2 parents 1114a96 + 8d05c22 commit 5fc675f

2 files changed

Lines changed: 72 additions & 10 deletions

File tree

README.md

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# rqm-optimize
22

3-
> `rqm-optimize` is the SU(2)-aware optimization layer for the RQM ecosystem. It compresses contiguous single-qubit gate runs into shorter equivalent forms, reducing unnecessary depth while preserving circuit behavior up to global phase.
3+
> `rqm-optimize` is an optional, backend-adjacent SU(2)-aware compression layer for the RQM ecosystem. It compresses contiguous single-qubit gate runs into shorter equivalent forms, reducing unnecessary depth while preserving circuit behavior up to global phase. It operates on Qiskit `QuantumCircuit` objects after the compiler and lowering stages — it is not the primary optimization stage and does not own the public circuit schema.
44
55
[![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
@@ -9,28 +9,75 @@
99

1010
## Purpose
1111

12-
RQM is not only a representation layer — it is a **performance layer**.
12+
`rqm-optimize` is a practical SU(2)-aware compression layer for backend-native circuits.
13+
It operates after the circuit has already been lowered to a Qiskit `QuantumCircuit` — that is, after `rqm-compiler` optimization and `rqm-qiskit` lowering have already run.
1314

14-
`rqm-optimize` accepts a Qiskit `QuantumCircuit`, scans it for contiguous single-qubit gate runs, fuses those runs into minimal SU(2)-equivalent operations, and returns a simplified circuit that is unitary-equivalent to the original up to global phase.
15+
It accepts a Qiskit `QuantumCircuit`, scans it for contiguous single-qubit gate runs, fuses those runs into minimal SU(2)-equivalent operations, and returns a simplified circuit that is unitary-equivalent to the original up to global phase.
16+
17+
`rqm-optimize` is **complementary to** `rqm-compiler`, not a replacement for it:
18+
19+
- **`rqm-compiler`** optimizes in its own internal circuit model, before lowering to a backend.
20+
- **`rqm-optimize`** compresses in backend-native / Qiskit circuit space, after lowering.
21+
22+
Use `rqm-optimize` when you want an extra 1-qubit compression pass after the compiler and lowering stages.
23+
24+
The canonical external/public circuit IR lives in `rqm-circuits` upstream. `rqm-optimize` does **not** consume or define the public wire format — it works on `QuantumCircuit` objects only.
1525

1626
---
1727

1828
## Stack placement
1929

2030
```text
21-
rqm-core → canonical quaternion / SU(2) / Bloch math
22-
rqm-compiler → circuit construction / normalization
31+
rqm-core → math foundation (quaternion / SU(2) / Bloch)
32+
rqm-circuits → canonical external/public circuit IR
33+
rqm-compiler → internal optimization / rewriting engine
2334
rqm-qiskit → Qiskit lowering / execution bridge
2435
rqm-braket → Braket lowering / execution bridge
25-
rqm-optimize → optimization / compression layer ← this package
36+
rqm-optimize → optional backend-adjacent optimization / compression layer ← this package
2637
```
2738

28-
The intended end-to-end workflow is:
39+
`rqm-optimize` is downstream of `rqm-circuits`, `rqm-compiler`, and usually `rqm-qiskit`.
40+
It is an **optional** later-stage pass — the rest of the stack functions without it.
41+
42+
---
43+
44+
## Typical data flow
2945

3046
```text
31-
construct (rqm-compiler) → lower (rqm-qiskit) → optimize (rqm-optimize) → run
47+
Studio / API / SDK
48+
49+
rqm-circuits payload (public circuit IR — parsed/validated upstream)
50+
51+
rqm-compiler (internal optimization / rewriting)
52+
53+
rqm-qiskit (lowering to Qiskit QuantumCircuit)
54+
55+
rqm-optimize (optional: backend-adjacent 1-qubit compression)
56+
57+
backend run
3258
```
3359

60+
Some users also call `rqm-optimize` directly on a hand-written Qiskit `QuantumCircuit` without going through the full stack — that is a fully supported and practical mode of use.
61+
62+
---
63+
64+
## What rqm-optimize owns / does not own
65+
66+
**Owns:**
67+
68+
- Backend-adjacent single-qubit compression in Qiskit circuit space
69+
- SU(2)-aware fusion of contiguous one-qubit runs
70+
- Optional native-basis preferences for emitted decompositions (`ibm`, `zyz`)
71+
- Optimization metadata about that compression step (`OptimizationResult`)
72+
73+
**Does NOT own:**
74+
75+
- Canonical external/public circuit schema → `rqm-circuits`
76+
- Compiler rewrite / canonicalization logic → `rqm-compiler`
77+
- Quaternion / SU(2) / Bloch / spinor math primitives → `rqm-core`
78+
- API wire format → `rqm-api`
79+
- Studio payload format → Studio + `rqm-api`
80+
3481
---
3582

3683
## Installation
@@ -51,6 +98,8 @@ pip install -e ".[dev]"
5198

5299
## Quickstart
53100

101+
This example shows **direct backend-native usage** — passing a hand-written Qiskit `QuantumCircuit` directly to `optimize`. This is a real and useful mode, though not the canonical ecosystem entry point (which starts at an `rqm-circuits` payload parsed upstream).
102+
54103
```python
55104
from qiskit import QuantumCircuit
56105
from rqm_optimize import optimize
@@ -75,10 +124,17 @@ print(result.circuit)
75124

76125
### Compiler-path integration
77126

127+
API and Studio users typically originate in `rqm-circuits` upstream. By the time `rqm-optimize` is called, the circuit has already crossed the public IR boundary (parsed from an `rqm-circuits` payload) and the compiler boundary (`rqm-compiler` optimization). `rqm-optimize` is a later-stage, backend-adjacent compression pass applied after `rqm-qiskit` lowering:
128+
129+
```text
130+
public circuit (rqm-circuits) → optimize in compiler space (rqm-compiler)
131+
→ lower to Qiskit (rqm-qiskit) → optional backend-native compression (rqm-optimize) → run
132+
```
133+
78134
If you are using `rqm-compiler` to construct circuits and `rqm-qiskit` to lower them to Qiskit, pass the lowered circuit directly to `optimize`:
79135

80136
```python
81-
# construct → lower → optimize → run
137+
# public IR → compile → lower → optional compress → run
82138
from rqm_qiskit import to_qiskit # rqm-qiskit lowering bridge
83139
from rqm_optimize import optimize
84140

src/rqm_optimize/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
"""rqm-optimize — SU(2)-aware circuit compression for quantum workflows.
1+
"""rqm-optimize — optional backend-adjacent SU(2)-aware compression for quantum workflows.
2+
3+
rqm-optimize is a later-stage compression pass that operates on Qiskit
4+
``QuantumCircuit`` objects, downstream of ``rqm-circuits`` (public IR),
5+
``rqm-compiler`` (internal optimization), and usually ``rqm-qiskit`` (lowering).
6+
It does not own the canonical public circuit schema and is not a replacement
7+
for rqm-compiler.
28
39
Public API::
410

0 commit comments

Comments
 (0)