Skip to content

Simplify decomposition of controlled eigengates with global phase #7383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented May 29, 2025

Fixes #7238

  1. Create a flag in DecomposeContext to configure extraction of terminal gates' global phases into distinct GlobalPhaseGates.
    a. This flag defaults to False for backward compatibility.
  2. Instrument the terminal decomposition gates (X, Y, Z, CZ) to check this flag and extract global phase if it exists.
    a. Added some convenience methods in GlobalPhaseGate to help.
    b. Updated some unrelated existing code to use these convenience methods for clarity.
  3. Update ControlledGate.decompose to attempt decompose the subgate before attempting the brute-force approach.
    a. This is what ultimately simplifies the decomposition result.
    b. Step 2 also allowed removal of the entire CZPowGate instanceof block there, since it was about extracting global phase.
  4. Add unit tests for each change.
@daxfohl daxfohl requested review from vtomole and a team as code owners May 29, 2025 05:04
@daxfohl daxfohl requested a review from 95-martin-orion May 29, 2025 05:04
@github-actions github-actions bot added the size: L 250< lines changed <1000 label May 29, 2025
@daxfohl daxfohl changed the title Remove controlled cz case May 29, 2025
Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (3578631) to head (0ce2c14).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7383   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files        1112     1112           
  Lines       97641    97707   +66     
=======================================
+ Hits        96359    96426   +67     
+ Misses       1282     1281    -1     

☔ View full report in Codecov by Sentry.
📢 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
1 participant