Skip to content

Name all decomp rules - #10492

Open
comp-phys-marc wants to merge 76 commits into
mainfrom
chore/names_on_decomp_rules
Open

comp-phys-marc wants to merge 76 commits into
mainfrom
chore/names_on_decomp_rules

Conversation

@comp-phys-marc

@comp-phys-marc comp-phys-marc commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Context: We would like to provide names for all decomposition rules that are user-friendly.

Description of the Change: Provides names for all decomp rules. Standardizes everything to the following format.

Item Pattern SWAP example
Public name <strategy> to_cnot
Rule function _<operator>_<strategy> _swap_to_cnot
Resource function _<operator>_<strategy>_resources _swap_to_cnot_resources
Work-wire helper _<operator>_<strategy>_work_wires

Benefits: Better UI, we always have a name to go in the decomp rule tables in the docs.

Possible Drawbacks: Large automated change.

Related GitHub Issues: [sc-135010]

Assisted by Codex.

@comp-phys-marc
comp-phys-marc marked this pull request as ready for review November 9, 2026 15:45
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.60784% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.39%. Comparing base (2faa29b) to head (cbfa881).

Files with missing lines Patch % Lines
pennylane/ops/op_math/controlled_ops.py 96.34% 3 Missing ⚠️
pennylane/decomposition/decomposition_rule.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10492   +/-   ##
=======================================
  Coverage   99.38%   99.39%           
=======================================
  Files         613      613           
  Lines       67668    67686   +18     
=======================================
+ Hits        67255    67274   +19     
+ Misses        413      412    -1     

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

@comp-phys-marc

Copy link
Copy Markdown
Contributor Author

🤖

I would approve as-is based on the static review. The explicit naming API and migration appear consistent in the inspected paths.

@andrijapau

Copy link
Copy Markdown
Contributor

@comp-phys-marc , mind fixing up CI before I take a look? 🙏🏼

@comp-phys-marc

comp-phys-marc commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@comp-phys-marc , mind fixing up CI before I take a look? 🙏🏼

You mean just the pylint and sphinx?

@andrijapau andrijapau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Screenshot 2026-11-16 at 1 01 22 PM

Why is this _impl?


@register_resources(_multi_rz_decomposition_resources)
def _multi_rz_decomposition(theta: TensorLike, wires: WiresLike):
@register_name("standard")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Idk if standard is a good name. It seems pretty subjective. Can we instead just say to_rz_cnot_ladder or something?

There are a few places this was done, not just this operator.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andrijapau andrijapau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another thing I've noticed is that we have decomposition rules that are called to_ppr but really emit PauliRot classes rather than our PPR classes. Can we make them say to_paulirot instead? 🤔

Screenshot 2026-11-16 at 1 11 09 PM

Comment thread pennylane/ops/op_math/controlled_ops.py Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@comp-phys-marc

Copy link
Copy Markdown
Contributor Author

Just for the sake of communication: in offline discussion with @andrijapau and @isaacdevlugt we have landed on neither the register_name nor the decomposition_rule option, but rather passing names into register_resources which was the original implementation, at least for the release. So will be reverting the decomposition_rule change as well as the register_name changes and going back to that. Thanks everyone for the discussion.

@andrijapau andrijapau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy to approve. Thanks for the hard work 🚀 💪🏼

Let's make sure we get an approval from product.

Co-authored-by: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com>

@isaacdevlugt isaacdevlugt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Looks amazing 😁. A few comments.

Q: Any way we can make key errors list the available names when providing an incorrect name to, e.g., list_decomps, inspect_decomps and fixed_decomps?

Claude findings:

  • the subcircuit rule name regressed to MyOpdecomp. pennylane/ops/functions/subcircuit.py:55 changed qfunc.name + "_decomp" to qfunc.name + "decomp". That looks like an automated find-and-replace. The changelog example and the docstring were updated to show MyOpdecomp rather than flagging it. It should probably stay MyOp_decomp, or use a strategy-style name like body.

Comment thread pennylane/ops/op_math/controlled_ops.py Resolved
@comp-phys-marc

comp-phys-marc commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude findings:

the subcircuit rule name regressed to MyOpdecomp. pennylane/ops/functions/subcircuit.py:55 changed qfunc.name + "_decomp" to qfunc.name + "decomp". That looks like an automated find-and-replace. The changelog example and the docstring were updated to show MyOpdecomp rather than flagging it. It should probably stay MyOp_decomp, or use a strategy-style name like body.

Fixed the bug that Claude found dff9317

@comp-phys-marc

Copy link
Copy Markdown
Contributor Author

Nice! Looks amazing 😁. A few comments.

Q: Any way we can make key errors list the available names when providing an incorrect name to, e.g., list_decomps, inspect_decomps and fixed_decomps?

We now list the available names db0e25f

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.

4 participants