You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-9Lines changed: 65 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# rqm-optimize
2
2
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.
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.
13
14
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.
15
25
16
26
---
17
27
18
28
## Stack placement
19
29
20
30
```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
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`)
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
+
54
103
```python
55
104
from qiskit import QuantumCircuit
56
105
from rqm_optimize import optimize
@@ -75,10 +124,17 @@ print(result.circuit)
75
124
76
125
### Compiler-path integration
77
126
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
+
78
134
If you are using `rqm-compiler` to construct circuits and `rqm-qiskit` to lower them to Qiskit, pass the lowered circuit directly to `optimize`:
79
135
80
136
```python
81
-
#construct → lower → optimize → run
137
+
#public IR → compile → lower → optional compress → run
82
138
from rqm_qiskit import to_qiskit # rqm-qiskit lowering bridge
0 commit comments