Skip to content

Axis-aware S³ compression: emit rx/ry/rz for Cartesian-aligned fused rotations#3

Merged
RQM-Technologies-dev merged 3 commits intomainfrom
copilot/add-quaternion-form-theory
Mar 20, 2026
Merged

Axis-aware S³ compression: emit rx/ry/rz for Cartesian-aligned fused rotations#3
RQM-Technologies-dev merged 3 commits intomainfrom
copilot/add-quaternion-form-theory

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

Single-qubit gate runs that fuse to a Cartesian-axis rotation were emitting a generic U gate. They should emit a named rx/ry/rz — lower semantic complexity, directly hardware-aligned (notably, rz is virtual/"free" on IBM backends).

What changed

geometry.pyaxis_aligned_rotation

Pure-math helper operating on the S³ quaternion. Returns ("x"/"y"/"z", theta) if the rotation axis is within tolerance of a Cartesian unit vector; None for generic or near-identity rotations.

qiskit_adapter.pyemit_axis_aligned_gate + two-pass build_optimized_circuit

emit_axis_aligned_gate converts the fused SU(2) matrix to its quaternion, runs the axis check, and appends rx/ry/rz (returns 1) or does nothing (returns 0).

build_optimized_circuit now uses a two-pass approach per fused run:

  1. Axis-aware pass — fires first; emits named gate if axis-aligned and skips to next segment
  2. Euler decomposer — existing fallback for generic rotations, unchanged

tests/test_axis_aware.py — 26 new tests

Unit tests for axis_aligned_rotation (per-axis detection, generic → None, near-identity → None, custom atol) and integration tests through optimize().

Example

from qiskit import QuantumCircuit
from rqm_optimize import optimize

qc = QuantumCircuit(1)
qc.rz(0.3, 0)
qc.rz(0.5, 0)

opt = optimize(qc)
print([i.operation.name for i in opt.data])
# Before: ['u']
# After:  ['rz']
Run Before After
rz(a) rz(b) U(0, 0, a+b) rz(a+b)
rx(a) rx(b) U(θ, φ, λ) rx(a+b)
ry(a) ry(b) U(θ, φ, λ) ry(a+b)
rx(a) ry(b) rz(c) U(θ, φ, λ) U(θ, φ, λ) (unchanged)

PyPI auto-publish

publish.yml already triggers on v*.*.* tag pushes (created by GitHub releases). No changes needed.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: RQM-Technologies-dev <267137213+RQM-Technologies-dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Incorporate quaternion form theory for quantum states and gates Implement quaternion-based SU(2) representation in geometry.py and use it in fusion.py Mar 20, 2026
… rotations

Co-authored-by: RQM-Technologies-dev <267137213+RQM-Technologies-dev@users.noreply.github.com>
Copilot AI changed the title Implement quaternion-based SU(2) representation in geometry.py and use it in fusion.py Axis-aware S³ compression: emit rx/ry/rz for Cartesian-aligned fused rotations Mar 20, 2026
@RQM-Technologies-dev RQM-Technologies-dev marked this pull request as ready for review March 20, 2026 03:25
@RQM-Technologies-dev RQM-Technologies-dev merged commit 1114a96 into main Mar 20, 2026
5 checks passed
@RQM-Technologies-dev RQM-Technologies-dev deleted the copilot/add-quaternion-form-theory branch March 20, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants