Skip to content

[Decomposition] Clean up custom logic for adjoint and pow #7352

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 73 commits into from
May 21, 2025

Conversation

astralcai
Copy link
Contributor

@astralcai astralcai commented Apr 29, 2025

Context:

This is a follow-up PR to #7347

Description of the Change:

There was previously a lot of custom logic for retrieving decomposition rules of symbolic operators. With the infrastructure added in #7347, this PR is able to clean up most of it.

  • We no longer hard-code a list of operators whose adjoint is an instance of the same type. Instead, each operator with a custom adjoint decomposition registers a decomposition rule for the adjoint of itself. For example, Hadamard was previously hardcoded as an operator that is its own adjoint, now there is a decomposition rule for "Adjoint(Hadamard)" which produces an instance of the base operator.
  • We removed the constraint that powers of an operator must be integers. Non-integer powers can be supported by adding custom decomposition rules for "Pow(SomeOp)". All operators in PL which overrides pow now has a custom decomposition rule registered under the power of itself.
  • Defined some general stock decomposition rules that can be registered under any operator. For example, a self_adjoint decomposition rule is defined, and it is registered with all operators that are self-adjoint (to avoid having duplicate code)

Related Shortcut Stories:

[sc-90114]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.69%. Comparing base (0346190) to head (66b2bfb).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #7352    +/-   ##
========================================
  Coverage   99.69%   99.69%            
========================================
  Files         537      537            
  Lines       50954    51197   +243     
========================================
+ Hits        50799    51042   +243     
  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.

Base automatically changed from symbolic-rules-01 to master May 20, 2025 21:57
@astralcai astralcai enabled auto-merge May 21, 2025 03:32
@astralcai astralcai added this pull request to the merge queue May 21, 2025
Merged via the queue into master with commit a62034a May 21, 2025
53 checks passed
@astralcai astralcai deleted the symbolic-rules-02 branch May 21, 2025 04:09
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