rqm-pennylane
rqm-pennylane adds differentiable and hybrid quantum workflows to the RQM ecosystem through PennyLane-compatible wrappers, gradient-friendly gates, and variational utilities built on top of rqm-core.
Standard-Compatible Quaternion Coordinates
A complete quaternion and a complete conventional complex/SU(2) or matrix representation carry the same transformation information. RQM uses quaternions because they make ordered rotation composition, inverses, normalization, sign handling, residuals, canonicalization, and lowering explicit in one structured coordinate system.
Any claimed benefit must come from a measured implementation or workflow—not from additional physics or information in the representation. This adapter does not establish better trainability, convergence, sample complexity, measurement, or algorithm discovery.
Ecosystem placement
rqm-pennylane is the differentiable / variational entrypoint in the RQM stack.
It consumes canonical math from rqm-core and circuit descriptors from
rqm-compiler, then exposes them through PennyLane-native operations.
┌──────────────────┐
│ rqm-pennylane │
│ differentiable │
│ workflows │
└────────┬─────────┘
│
┌──────────────────┼──────────────────┐
│ │ │
┌─────┴──────────┐ ┌─────┴──────────┐ ┌────┴────────────┐
│ rqm-core │ │ rqm-compiler │ │ rqm-optimize │
│ canonical math │ │ canonical IR │ │ circuit form │
└────────────────┘ └────────────────┘ └─────────────────┘
rqm-pennylane does not duplicate math or compiler logic — it bridges them.
Features
- Wrappers — convert RQM quaternion, spinor, and Bloch objects to PennyLane-ready values
- Gradient-friendly gates —
RQMRotation,apply_quaternion_rotation,parameterized_su2 - Variational templates —
single_qubit_layer,entangling_layer,hardware_efficient_ansatz,rqm_angle_embedding - Optimization helpers —
expectation_cost,parameter_shift_gradients,make_variational_qnode,optimize_step - Device utilities —
default_qubit_device,lightning_device - Export bridge — minimal
rqm-compiler→ PennyLane callable bridge
Installation
python -m pip install rqm-pennylane
This installs rqm-core (canonical quaternion / spinor / Bloch math) and
pennylane automatically as required dependencies.
For development:
python -m pip install "rqm-pennylane[dev]"
Quickstart
import pennylane as qml
from pennylane import numpy as pnp
from rqm_pennylane import (
default_qubit_device,
hardware_efficient_ansatz,
optimize_step,
)
dev = default_qubit_device(wires=2)
@qml.qnode(dev)
def cost_circuit(params):
hardware_efficient_ansatz(params, wires=[0, 1], depth=2)
return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
params = pnp.array([[[ 0.1, 0.2, 0.3],
[ 0.4, 0.5, 0.6]],
[[ 0.7, 0.8, 0.9],
[ 0.1, 0.2, 0.3]]], requires_grad=True)
opt = qml.GradientDescentOptimizer(stepsize=0.2)
for step in range(5):
cost = float(cost_circuit(params))
params = optimize_step(opt, cost_circuit, params)
print(f"step {step} cost = {cost:.4f}")
Architecture rules
- Do not duplicate quaternion / spinor / SU(2) math from
rqm-core. - Do not invent a circuit IR; use
rqm-compilerabstractions. - Do not add circuit simplification; that belongs in
rqm-optimize. - Focus on PennyLane interoperability and differentiable parameterized workflows.
- Keep the package backend-agnostic except for PennyLane-specific integration points.
- Public API must feel lightweight, Pythonic, and useful for researchers.
See AGENTS.md for the full contributor guidelines.
Examples
| File | Description |
|---|---|
examples/basic_quaternion_rotation.py |
Apply a quaternion-derived rotation and measure expectation value |
examples/variational_single_qubit.py |
Train a single-qubit variational circuit |
examples/hybrid_cost_example.py |
Hybrid classical-quantum cost minimization |
Run any example directly:
python examples/basic_quaternion_rotation.py
v0.1.0 API
Gates / operations
RQMRotation(phi, theta, omega, wires)— one-qubit Euler rotationapply_quaternion_rotation(q, wires)— quaternion-derived rotationparameterized_su2(alpha, beta, gamma, wires)— SU(2)-equivalent decomposition
Templates
single_qubit_layer(params, wires)— per-qubit Rot layersentangling_layer(params, wires)— Rot + CNOT ringhardware_efficient_ansatz(params, wires, depth)— stacked entangling layersrqm_angle_embedding(features, wires)— angle encoding
Variational helpers
expectation_cost(qnode, params)— scalar cost from QNodeparameter_shift_gradients(qnode, params)— PennyLane gradient helpermake_variational_qnode(device, circuit_fn, measure_fn)— QNode factoryoptimize_step(optimizer, cost_fn, params)— one-step optimization
Export bridge
compiled_operation_to_pennylane(op, wires_override)— single-op bridgecompiled_circuit_to_qnode_ops(compiled_circuit)— circuit-level bridge
Supported gates in the export bridge: rx, ry, rz, h, x, y, z, cnot, cz, swap.
Roadmap
- v0.2.0 — expanded
rqm-compilerexport coverage, noise model helpers - v0.3.0 — optional JAX / Torch backend hints, batched gradient helpers
- v1.0.0 — stable API, full
rqm-compilergate coverage, documentation site
License
Apache License 2.0 — see LICENSE.
Metadata
Release files for rqm-pennylane 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rqm_pennylane-0.1.3.tar.gz | 32.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rqm_pennylane-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.7 kB
Release files / rqm_pennylane-0.1.3.tar.gz
| Download URL | rqm_pennylane-0.1.3.tar.gz |
|---|---|
| Size | 32.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
164d3fd2e7330861675faa6e06ad9aef82c8fe42b76b12b382a901661ba6d6c6
|
|
BLAKE2b-256 checksum How to use checksums |
3106151036f4e9d7261bd78b87df4b392576023f5c708cce9b06f9c86f8e4d2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 29, 2026.
Transparency logRelease files / rqm_pennylane-0.1.3-py3-none-any.whl
| Download URL | rqm_pennylane-0.1.3-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
241fb19227d65560798ad70f40aef9068158f21b4c52a64e2b9457d85c47a427
|
|
BLAKE2b-256 checksum How to use checksums |
fef2e8fd2c865573da383caac26dc19ce236c366aac38ee443e93b12eb69cab8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 29, 2026.
Transparency log