Skip to content

Improved decomposition of DiagonalQubitUnitary #7370

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

Merged
merged 66 commits into from
May 15, 2025
Merged

Conversation

dwierichs
Copy link
Contributor

@dwierichs dwierichs commented May 2, 2025

Context:
A diagonal unitary operator can be decomposed iteratively into RZ multiplexers (SelectPauliRot) and a global phase.
PennyLane is not using this quite established decomposition yet.
Similar to the QubitUnitary decomposition implemented in #7277, the method implemented here stems from Shende et al. (2004).
It uses fewer CNOTs that the current implementation, but has larger classical computing/memory cost.

Description of the Change:
Replace current decomposition of DiagonalQubitUnitary by multiplexer-based decomposition.

Also fixes a validation in __init__ of SelectPauliRot to allow for parameter broadcasting.

Benefits:
Quantumly cheaper decomposition of DiagonalQubitUnitary.

Possible Drawbacks:
Increase classical computing /memory cost if the decomposition is carried out down to elementary gates (due to SelectPauliRot decomposition).
This increased classical cost is remedied by #7377

Related GitHub Issues:

[sc-90706]

@dwierichs dwierichs marked this pull request as ready for review May 8, 2025 07:10
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.69%. Comparing base (b1db988) to head (48bdc6f).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7370      +/-   ##
==========================================
- Coverage   99.69%   99.69%   -0.01%     
==========================================
  Files         529      529              
  Lines       50745    50738       -7     
==========================================
- Hits        50590    50583       -7     
  Misses        155      155              

☔ 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.

@dwierichs dwierichs changed the title [WIP] Improved decomposition of DiagonalQubitUnitary Improved decomposition of DiagonalQubitUnitary May 8, 2025
@dwierichs dwierichs added the review-ready 👌 PRs which are ready for review by someone from the core team. label May 8, 2025
Base automatically changed from selectpaulirot-fwh to master May 8, 2025 07:44
@dwierichs dwierichs requested review from astralcai and KetpuntoG May 8, 2025 13:54
Copy link
Contributor

@KetpuntoG KetpuntoG left a comment

Choose a reason for hiding this comment

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

Looks great and works perfectly! ✅

@dwierichs dwierichs requested a review from astralcai May 13, 2025 08:41
@dwierichs dwierichs enabled auto-merge May 15, 2025 13:54
@dwierichs dwierichs added this pull request to the merge queue May 15, 2025
Merged via the queue into master with commit 11de009 May 15, 2025
53 checks passed
@dwierichs dwierichs deleted the better-diag-decomp branch May 15, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants