Skip to content

Commit 1c1fa6b

Browse files
Merge pull request #4 from RQM-Technologies-dev/copilot/update-rqm-docs
docs: add rqm-optimize as optimization layer across ecosystem documentation
2 parents 0bb0f31 + 221959a commit 1c1fa6b

5 files changed

Lines changed: 133 additions & 15 deletions

File tree

docs/architecture.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ The compiler resolves logical gate names to explicit unitary matrices using `rqm
2424

2525
Neither backend reimplements math or compilation logic. They each implement the same interface contract, which is why the same program runs on either backend without modification.
2626

27-
### 4. Documentation lives in `rqm-docs`
27+
### 4. Optimization lives in `rqm-optimize`
28+
29+
`rqm-optimize` is the optimization layer. It accepts circuits already translated to a backend format and applies SU(2)-aware passes — gate fusion, redundancy elimination, and depth reduction — using exact quaternion arithmetic from `rqm-core`.
30+
31+
Optimization is a post-compilation, pre-execution step. It is optional for simulation but recommended for hardware runs where gate count directly affects decoherence.
32+
33+
### 5. Documentation lives in `rqm-docs`
2834

2935
`rqm-docs` (this site) organizes and explains the platform. It does not introduce new algorithms, theory, or notebook content. Its job is to make everything else discoverable, understandable, and usable.
3036

@@ -46,6 +52,12 @@ rqm-compiler
4652
rqm-qiskit rqm-braket
4753
(Qiskit circuit) (Braket circuit)
4854
│ │
55+
└────────┬─────────┘
56+
57+
rqm-optimize
58+
(SU(2) fusion, compression)
59+
60+
┌────────┴─────────┐
4961
▼ ▼
5062
simulator/hardware simulator/hardware
5163
│ │
@@ -60,15 +72,17 @@ The program is defined once. The compiler processes it once. Execution backends
6072
## Dependency Graph
6173

6274
```
63-
rqm-braket ──► rqm-compiler ──► rqm-core
64-
rqm-qiskit ──► rqm-compiler ──► rqm-core
75+
rqm-braket ──► rqm-compiler ──► rqm-core
76+
rqm-qiskit ──► rqm-compiler ──► rqm-core
77+
rqm-optimize ──► rqm-core
6578
rqm-notebooks ──► rqm-qiskit, rqm-braket
6679
```
6780

6881
- `rqm-core` has no ecosystem dependencies.
6982
- `rqm-compiler` depends on `rqm-core`.
7083
- `rqm-qiskit` depends on `rqm-compiler` (and transitively `rqm-core`).
7184
- `rqm-braket` depends on `rqm-compiler` (and transitively `rqm-core`).
85+
- `rqm-optimize` depends on `rqm-core` for SU(2) and quaternion primitives. It is applied at runtime to circuits already translated to a backend format — it is not a package-level dependency of `rqm-qiskit` or `rqm-braket`.
7286
- `rqm-notebooks` depends on the execution backends.
7387
- `rqm-docs` references all packages but has no runtime dependency on any of them.
7488

@@ -82,6 +96,7 @@ rqm-notebooks ──► rqm-qiskit, rqm-braket
8296
| Compiler | `rqm-compiler` | Normalizes programs to a backend-agnostic IR |
8397
| Execution | `rqm-qiskit` | Maps IR to Qiskit circuits and simulators |
8498
| Execution | `rqm-braket` | Maps IR to Braket circuits and simulators |
99+
| Optimization | `rqm-optimize` | SU(2)-aware gate fusion and circuit compression |
85100
| Learning | `rqm-notebooks` | Teaches and demonstrates the platform through notebooks |
86101
| Documentation | `rqm-docs` | Explains, organizes, and guides users |
87102

@@ -98,6 +113,7 @@ rqm-notebooks ──► rqm-qiskit, rqm-braket
98113
| Qiskit circuit from IR | `rqm-qiskit` |
99114
| Braket circuit from IR | `rqm-braket` |
100115
| Circuit execution helpers | `rqm-qiskit` / `rqm-braket` |
116+
| SU(2)-aware gate fusion and compression | `rqm-optimize` |
101117
| Tutorial notebook | `rqm-notebooks` |
102118
| Concept explanation | `rqm-docs` |
103119
| API reference guide | `rqm-docs` |
@@ -111,6 +127,7 @@ Separating math, compilation, and execution into distinct layers provides concre
111127
- **`rqm-core` stays dependency-light** and can be tested in isolation without any quantum framework installed.
112128
- **`rqm-compiler` is backend-neutral** — optimization and normalization passes apply once and benefit all backends.
113129
- **Backends evolve independently** — changes to Qiskit's API do not affect the Braket backend, and vice versa.
130+
- **`rqm-optimize` is geometry-correct** — gate fusion uses exact SU(2) arithmetic from `rqm-core`, not floating-point heuristics.
114131
- **Programs are portable** — the same program description runs on any registered backend.
115132
- **Documentation is independently deployable**`rqm-docs` has no runtime dependencies on the packages it documents.
116133

docs/ecosystem.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ RQM is a compiler-first quantum software platform built from focused, composable
3838
- **Exposes `BraketBackend`** with `run_local()` and `run_device()` methods
3939
- **Returns normalized results** compatible with the RQM result contract
4040

41+
### `rqm-optimize` — Optimization Layer
42+
43+
`rqm-optimize` applies SU(2)-aware circuit optimization and compression to compiled circuits before they are submitted to a backend. It uses quaternion composition from `rqm-core` to fuse, simplify, and reduce gate sequences with geometric correctness.
44+
45+
- **Depends on `rqm-core`** for SU(2) and quaternion primitives
46+
- **Backend-compatible** — accepts circuits already translated to a backend format (Qiskit or Braket)
47+
- **Drop-in step** — insert `optimize(qc)` between translation and execution without restructuring the pipeline
48+
49+
See the [Optimization guide](optimization.md) for details and usage examples.
50+
4151
### `rqm-notebooks` — Demos and Learning
4252

4353
`rqm-notebooks` is a curated collection of Jupyter notebooks that guide users from first principles through practical quantum circuit execution.
@@ -51,10 +61,11 @@ RQM is a compiler-first quantum software platform built from focused, composable
5161
## Architecture Diagram
5262

5363
```
54-
rqm-core → canonical math (quaternions, spinors, SU(2))
55-
rqm-compiler → instruction generation and normalization
56-
rqm-qiskit → Qiskit execution backend
57-
rqm-braket → AWS Braket execution backend
64+
rqm-core → canonical math (quaternions, spinors, SU(2))
65+
rqm-compiler → instruction generation and normalization
66+
rqm-qiskit → execution bridge (Qiskit)
67+
rqm-braket → execution bridge (AWS Braket)
68+
rqm-optimize → optimization layer (SU(2)-aware gate fusion and compression)
5869
```
5970

6071
```
@@ -68,14 +79,21 @@ rqm-braket → AWS Braket execution backend
6879
┌─────────────┐ ┌──────────────┐ ┌───────────────┐
6980
│ rqm-core │ │ rqm-compiler │ │ rqm-notebooks │
7081
│ (math/core) │◄│ (compiler) │ │ (learning) │
71-
└─────────────┘ └──────┬───────┘ └───────────────┘
72-
73-
┌───────────┴───────────┐
74-
▼ ▼
75-
┌─────────────┐ ┌──────────────┐
76-
│ rqm-qiskit │ │ rqm-braket │
77-
│ (Qiskit) │ │ (Braket) │
78-
└─────────────┘ └──────────────┘
82+
└──────┬──────┘ └──────┬───────┘ └───────────────┘
83+
│ │
84+
│ ┌───────────┴───────────┐
85+
│ ▼ ▼
86+
│ ┌─────────────┐ ┌──────────────┐
87+
│ │ rqm-qiskit │ │ rqm-braket │
88+
│ │ (Qiskit) │ │ (Braket) │
89+
│ └──────┬──────┘ └──────┬───────┘
90+
│ │ │
91+
│ └──────────┬───────────┘
92+
│ ▼
93+
│ ┌─────────────────────┐
94+
└───────►│ rqm-optimize │
95+
│ (optimization layer)│
96+
└─────────────────────┘
7997
```
8098

8199
---
@@ -88,6 +106,7 @@ rqm-braket → AWS Braket execution backend
88106
| Understand the compiler | [`rqm-compiler`](https://github.com/RQM-Technologies-dev/rqm-compiler) + [Architecture](architecture.md) |
89107
| Run on Qiskit | [`rqm-qiskit`](https://github.com/RQM-Technologies-dev/rqm-qiskit) + [API guide](api/rqm-qiskit-api.md) |
90108
| Run on Braket | [`rqm-braket`](https://github.com/RQM-Technologies-dev/rqm-braket) |
109+
| Optimize circuits | [`rqm-optimize`](https://github.com/RQM-Technologies-dev/rqm-optimize) + [Optimization guide](optimization.md) |
91110
| Learn interactively | [`rqm-notebooks`](https://github.com/RQM-Technologies-dev/rqm-notebooks) + [Notebooks guide](notebooks.md) |
92111
| Read architecture rationale | [Architecture page](architecture.md) |
93112
| Install packages | [Installation guide](installation.md) |

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RQM is structured as a layered pipeline from canonical math to backend execution
2222
| Compiler | [`rqm-compiler`](https://github.com/RQM-Technologies-dev/rqm-compiler) | Instruction generation, gate normalization, and IR lowering |
2323
| Execution | [`rqm-qiskit`](https://github.com/RQM-Technologies-dev/rqm-qiskit) | Qiskit circuit execution backend |
2424
| Execution | [`rqm-braket`](https://github.com/RQM-Technologies-dev/rqm-braket) | AWS Braket execution backend |
25+
| Optimization | [`rqm-optimize`](https://github.com/RQM-Technologies-dev/rqm-optimize) | SU(2)-aware circuit optimization and compression layer |
2526

2627
The math layer has no backend dependency. The compiler layer transforms programs into a normalized instruction set. Execution backends consume that normalized form — they do not reimplement math or compiler logic.
2728

@@ -45,11 +46,17 @@ RQM is a compiler-first quantum software platform. It separates three concerns t
4546
- **Mathematical representation** — handled by `rqm-core`, which defines canonical quaternion, spinor, and SU(2) structures with no backend dependency.
4647
- **Compilation** — handled by `rqm-compiler`, which transforms those structures into a normalized instruction set that any backend can consume.
4748
- **Execution** — handled by `rqm-qiskit` and `rqm-braket`, which map the compiled instructions onto their respective runtimes.
49+
- **Optimization** — handled by `rqm-optimize`, which applies SU(2)-aware gate fusion and circuit compression before execution.
4850

4951
This separation means the same program can run on Qiskit or Amazon Braket without modification. Swapping backends is a one-line change.
5052

5153
---
5254

55+
!!! tip "New: rqm-optimize"
56+
**rqm-optimize** is now part of the RQM ecosystem — an SU(2)-aware circuit optimization and compression layer. Insert `optimize(qc)` between translation and execution to reduce gate count before hardware runs. See the [Optimization guide](optimization.md).
57+
58+
---
59+
5360
!!! tip "New to the platform?"
5461
Start with [Quickstart](quickstart.md) for a working example, then read [Concepts](concepts.md) to understand the architecture.
5562

docs/optimization.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# rqm-optimize
2+
3+
`rqm-optimize` is the optimization layer of the RQM platform. It sits above the execution backends and applies SU(2)-aware circuit transformations to reduce gate count, circuit depth, and backend resource usage — before the circuit is submitted to a simulator or hardware device.
4+
5+
---
6+
7+
## What It Does
8+
9+
`rqm-optimize` accepts a compiled quantum circuit (produced by `rqm-compiler` and translated to a backend format by `rqm-qiskit` or `rqm-braket`) and applies a sequence of geometry-aware optimization passes:
10+
11+
- **SU(2) gate fusion** — merges consecutive single-qubit rotations into a single SU(2) operation using exact quaternion composition
12+
- **Redundancy elimination** — detects and removes gate pairs that compose to the identity
13+
- **Depth reduction** — reorders commuting operations to minimize circuit depth without changing the program semantics
14+
- **Compression** — collapses equivalent gate sequences into canonical forms defined by `rqm-core`
15+
16+
All passes are geometry-aware: they use the quaternion and SU(2) primitives from `rqm-core` to reason about gate equivalence exactly, not approximately.
17+
18+
---
19+
20+
## When to Use It
21+
22+
Use `rqm-optimize` when:
23+
24+
- You want to reduce the number of gates before submitting to hardware (fewer gates → less decoherence)
25+
- You are running on a backend with a limited native gate set and want to minimize transpilation overhead
26+
- You have long circuits with repeated rotation patterns that can be fused
27+
- You want reproducible, geometry-correct optimization rather than heuristic transpilation
28+
29+
`rqm-optimize` is optional. If you are running on a simulator and circuit depth is not a concern, you can skip it. For hardware runs, it is recommended.
30+
31+
---
32+
33+
## Example
34+
35+
```python
36+
from rqm_compiler import compile_circuit
37+
from rqm_qiskit import compiled_circuit_to_qiskit
38+
from rqm_optimize import optimize
39+
40+
# Step 1: compile the program to a backend-agnostic IR
41+
qc = compile_circuit(program)
42+
43+
# Step 2: translate to a Qiskit circuit
44+
qc = compiled_circuit_to_qiskit(qc)
45+
46+
# Step 3: apply SU(2)-aware optimization
47+
qc = optimize(qc)
48+
49+
# Step 4: run on a backend as usual
50+
result = backend.run(qc)
51+
```
52+
53+
The `optimize()` call is a drop-in step. It accepts and returns the same circuit type, so it can be inserted into any existing workflow without restructuring the pipeline.
54+
55+
---
56+
57+
## Position in the Stack
58+
59+
`rqm-optimize` operates after compilation and translation, and before execution:
60+
61+
```
62+
rqm-core → canonical math (quaternions, spinors, SU(2))
63+
rqm-compiler → circuit construction and IR lowering
64+
rqm-qiskit → execution bridge (Qiskit)
65+
rqm-braket → execution bridge (AWS Braket)
66+
rqm-optimize → optimization layer (SU(2)-aware gate fusion and compression)
67+
```
68+
69+
It depends on `rqm-core` for geometry primitives and operates on circuits already in a backend format. It does not re-enter the compiler pipeline.
70+
71+
---
72+
73+
!!! tip "Optimization is geometry-correct"
74+
Unlike heuristic transpilers, `rqm-optimize` uses exact SU(2) arithmetic from `rqm-core` to determine gate equivalences. Two gates are fused only when their quaternion product is provably correct — never based on floating-point approximation alone.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ nav:
4949
- Home: index.md
5050
- Quickstart: quickstart.md
5151
- Ecosystem: ecosystem.md
52+
- Optimization: optimization.md
5253
- Concepts: concepts.md
5354
- Architecture: architecture.md
5455
- Install: installation.md

0 commit comments

Comments
 (0)