Axis-aware S³ compression: emit rx/ry/rz for Cartesian-aligned fused rotations#3
Merged
RQM-Technologies-dev merged 3 commits intomainfrom Mar 20, 2026
Merged
Conversation
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
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single-qubit gate runs that fuse to a Cartesian-axis rotation were emitting a generic
Ugate. They should emit a namedrx/ry/rz— lower semantic complexity, directly hardware-aligned (notably,rzis virtual/"free" on IBM backends).What changed
geometry.py—axis_aligned_rotationPure-math helper operating on the S³ quaternion. Returns
("x"/"y"/"z", theta)if the rotation axis is within tolerance of a Cartesian unit vector;Nonefor generic or near-identity rotations.qiskit_adapter.py—emit_axis_aligned_gate+ two-passbuild_optimized_circuitemit_axis_aligned_gateconverts the fused SU(2) matrix to its quaternion, runs the axis check, and appendsrx/ry/rz(returns 1) or does nothing (returns 0).build_optimized_circuitnow uses a two-pass approach per fused run:tests/test_axis_aware.py— 26 new testsUnit tests for
axis_aligned_rotation(per-axis detection, generic → None, near-identity → None, custom atol) and integration tests throughoptimize().Example
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.ymlalready triggers onv*.*.*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.