Skip to content

added one-qb and two-qb rotations to ppvm-pauli-sum-2 - #314

Open
JonhasA wants to merge 3 commits into
trait-2/ppvm-pauli-sum-2from
trait-2/pauli-sum-2-rots
Open

JonhasA wants to merge 3 commits into
trait-2/ppvm-pauli-sum-2from
trait-2/pauli-sum-2-rots

Conversation

@JonhasA

@JonhasA JonhasA commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Adds rotation support to Sum using buffered accumulation: update all original coefficients before merging generated terms, so collisions cannot cause contributions to be processed twice.

  • Implement single- and two-qubit rotations and their batch interfaces.
  • Add T, T†, U3, RotXY, and CRx.
  • Specialize RXX, RYY, and RZZ for performance.
  • Preserve explicit reduction/truncation and the reference’s surviving-site loss behavior.

@JonhasA
JonhasA requested a review from david-pl November 23, 2026 05:09
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/ppvm/pr-preview/pr-314/

Built to branch gh-pages at 2026-11-23 05:20 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@david-pl david-pl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the RotationTwo impl could be much simpler. Other than that, I think it's good.

}

#[inline]
fn rxx(&mut self, a: usize, b: usize, theta: A) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these overrides? Shouldn't the generic rotate_2 method be enough here?

// |1><1| ⊗ X = (IX - ZX)/2. The two generators commute.
// Loss follows the constituent rotations' surviving-site convention.
let half = theta * 0.5;
self.rx(target, half.clone());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always executed on the target. If the control is lost or |0>, rounding errors could still lead to small branching. Probably not much of an issue in practice, but this could also be bad for performance since you'd have to do a branch -> truncate pass in order to get rid of that.

impl<S: Support, P, A> RotXY<S::Coeff, A> for Sum<S, P>
where
Self: RotationOne<S::Coeff, A>,
A: Angle<S::Coeff> + Clone + std::ops::Neg<Output = A>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove Neg here? Current symbolic angles don't have it implemented.

impl<S: Support, P, A> CRx<S::Coeff, A> for Sum<S, P>
where
Self: RotationOne<S::Coeff, A> + RotationTwo<S::Coeff, A>,
A: Angle<S::Coeff> + Clone + std::ops::Mul<f64, Output = A> + std::ops::Neg<Output = A>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, okay, we may need some follow-up work on ppvm-sym-2. I don't think we can currently represent theta * 0.5 with symbolic angles. Let's keep that out of this PR though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it might make sense to immediately use the Halvable trait here? I can have a look at what the ppvm-sym-2 changes have to be after, but it is probably easier if the angle just needs to support .half().
(

pub trait Halvable: Coefficient {
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it but Halvable is not implemented for angles, but for Coefficient. But essentially, yes, it might be re-used. We basically need some symbolic representation of a half-angle, I think.


[dev-dependencies]
ppvm-pauli-sum = { path = "../ppvm-pauli-sum" }
criterion = "0.8.2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

This branch has not been deployed

No deployments
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.

3 participants