Skip to content

Produce Correct Rotation on PauliSumExponential with Identity Inputs - #8188

Closed
Acciaccatura wants to merge 5 commits into
quantumlib:mainfrom
Acciaccatura:issue6598
Closed

Produce Correct Rotation on PauliSumExponential with Identity Inputs#8188
Acciaccatura wants to merge 5 commits into
quantumlib:mainfrom
Acciaccatura:issue6598

Conversation

@Acciaccatura

@Acciaccatura Acciaccatura commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

this PR allows cirq.PauliSumExponential to produce proper unitaries with PauliStrings containing I operations.

concretely, the following changes are made:

  • PauliString does not support remembering qubits with I operations. this is documented in its docstring. this PR adds support for maintaining these qubits in PauliString for any computation that requires them to be present.
  • PauliSum is also updated to ensure I operations of its constituent PauliString are not dropped.
  • PauliSumExponential calculates its unitaries based off PauliStringPhasor objects, however PauliStringPhasor calculates its unitaries based off operations produced by its _decompose_ function. it is unclear to me how to insert identity operations into this process, so instead, this PR calculates the PauliSumExponential unitary based on its own formula:
    1. calculate the final unitary size $\lvert U \rvert$ by taking all referenced qubits from its constituent PauliStrings
    2. split its representation into $e^{i\theta \sum P_i} = \prod e^{i\theta P_i}$
    3. use Euler's formula to compute $e^{i\theta P_i} = I\cos{\theta} + iP_i\sin{\theta}$ with properly sized $I$ and $P_i$ based on (i).

I am concerned this PR might produce some further confusion for clients as to how PauliString works given that this update changes its behavior to track identity operations now, but separately from its main qubit map. consultation from the Cirq team would be appreciated :)

edit: I see there is also #8170, if they decide a separate class would be the way to go to fix #6598

Fixes #6598

@github-actions github-actions Bot added the size: M 50< lines changed <250 label Jul 11, 2026
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.60%. Comparing base (daf1fa6) to head (5c6dcf4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8188   +/-   ##
=======================================
  Coverage   99.60%   99.60%           
=======================================
  Files        1118     1118           
  Lines      101349   101370   +21     
=======================================
+ Hits       100945   100966   +21     
  Misses        404      404           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Acciaccatura
Acciaccatura marked this pull request as ready for review July 11, 2026 02:36
@Acciaccatura
Acciaccatura requested a review from a team as a code owner July 11, 2026 02:36
@Acciaccatura
Acciaccatura requested a review from senecameeks July 11, 2026 02:36
@Acciaccatura

Copy link
Copy Markdown
Contributor Author

edit: I think I'm actually going to close this as I think $e^{A+B} = e^Ae^B$ is not true in general, so the unitary calculation is likely incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a gate to represent a PauliRotation

1 participant