Differentiable and hybrid quantum workflows for the RQM ecosystem, built on PennyLane and rqm-core.
Project description
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.
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
MIT — see LICENSE.
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_pennylane-0.1.0.tar.gz.
File metadata
- Download URL: rqm_pennylane-0.1.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19bb8adc18bd0337ea9b3af4e0afa6ff30995e4c383bdf6e4d8ecc4db87b0737
|
|
| MD5 |
7552a22d97ba638c6d887e1377c259c1
|
|
| BLAKE2b-256 |
29597202d52621f01437128ed880b3161ab9c1746a672e83ea81e68f8bc8c9b3
|
Provenance
The following attestation bundles were made for rqm_pennylane-0.1.0.tar.gz:
Publisher:
publish.yml on RQM-Technologies-dev/rqm-pennylane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rqm_pennylane-0.1.0.tar.gz -
Subject digest:
19bb8adc18bd0337ea9b3af4e0afa6ff30995e4c383bdf6e4d8ecc4db87b0737 - Sigstore transparency entry: 1141344923
- Sigstore integration time:
-
Permalink:
RQM-Technologies-dev/rqm-pennylane@f4745fccf4d519f8c592d9059fe920dfaa2f9644 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/RQM-Technologies-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f4745fccf4d519f8c592d9059fe920dfaa2f9644 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rqm_pennylane-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rqm_pennylane-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7495c087b9fb8e9c4c5d0ae245b6779f3460ff0afea447e3ae2661e0d9b97db4
|
|
| MD5 |
c28853d26afb9d5e5913fe9f882aafd4
|
|
| BLAKE2b-256 |
cde65ff087bf1911ff22aedb98f8948e368a803c34460637f135e00d3d8fc7e2
|
Provenance
The following attestation bundles were made for rqm_pennylane-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on RQM-Technologies-dev/rqm-pennylane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rqm_pennylane-0.1.0-py3-none-any.whl -
Subject digest:
7495c087b9fb8e9c4c5d0ae245b6779f3460ff0afea447e3ae2661e0d9b97db4 - Sigstore transparency entry: 1141345089
- Sigstore integration time:
-
Permalink:
RQM-Technologies-dev/rqm-pennylane@f4745fccf4d519f8c592d9059fe920dfaa2f9644 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/RQM-Technologies-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f4745fccf4d519f8c592d9059fe920dfaa2f9644 -
Trigger Event:
release
-
Statement type: