Skip to content

Arithmetic template qfunc decompositions #7779

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 55 commits into from
Jul 24, 2025

Conversation

comp-phys-marc
Copy link
Contributor

@comp-phys-marc comp-phys-marc commented Jul 3, 2025


Context: We would like to refactor our templates to use quantum functions in their decompositions in order to make them compatible with the new decompositions system.

Description of the Change: Base branch for arithmetic template refactoring, starting with Arithmetic templates.

Benefits: Allows us to decompose using decompositions that are program capture compatible. Tape based decompositions are still available as a backwards compatible fallback.

Possible Drawbacks:

Related ShortCut Story: [sc-95395]

@comp-phys-marc comp-phys-marc changed the title Template refactoring [WIP] Template refactoring Jul 3, 2025
@comp-phys-marc comp-phys-marc changed the title [WIP] Template refactoring [WIP] Adder template refactoring Jul 4, 2025
@PennyLaneAI PennyLaneAI deleted a comment from github-actions bot Jul 4, 2025
@comp-phys-marc comp-phys-marc changed the title [WIP] Adder template refactoring Adder template refactoring Jul 4, 2025
@comp-phys-marc comp-phys-marc marked this pull request as ready for review July 4, 2025 19:43
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.68%. Comparing base (a51adeb) to head (ed5250a).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7779      +/-   ##
==========================================
- Coverage   99.68%   99.68%   -0.01%     
==========================================
  Files         540      540              
  Lines       55386    55575     +189     
==========================================
+ Hits        55214    55402     +188     
- Misses        172      173       +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.

Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

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

These PRs are not "refactors", can you rename them to just say something along the lines of "add qfunc decompositions for ..."?

@comp-phys-marc
Copy link
Contributor Author

These PRs are not "refactors", can you rename them to just say something along the lines of "add qfunc decompositions for ..."?

Yeah when I created them I thought I would be doing refactors but as it turned out we just left the existing tape decompositions as they are...

@comp-phys-marc comp-phys-marc changed the title Adder template refactoring Adder template qfunc decomposition Jul 8, 2025
Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

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

This is optional, but maybe you can add a decomposition for "C(Adder)" (controlled Adder) that works by applying control only on the PhaseAdder in the middle? It is a nice trick because the QFT and the Adjoint(QFT) cancels out nicely when the middle PhaseAdder isn't applied. This will be significantly more resource efficient than the default, which is to apply control on every single op in the decomposition.

@PennyLaneAI PennyLaneAI deleted a comment from github-actions bot Jul 11, 2025
comp-phys-marc and others added 2 commits July 11, 2025 14:37
------------------------------------------------------------------------------------------------------------

**Context:** We would like the `ControlledSequence` to have a quantum
function based decomposition that is compatible with the new
decomposition system.

**Description of the Change:** Adds a quantum function based
decomposition and resource keys, params.

**Benefits:** Makes the template compatible with the new system.

**Possible Drawbacks:**

**Related ShortCut Stories:** [sc-94491]
@comp-phys-marc comp-phys-marc changed the title Adder template qfunc decomposition Template qfunc decompositions Jul 14, 2025
@comp-phys-marc comp-phys-marc changed the title Template qfunc decompositions Arithmetic template qfunc decompositions Jul 14, 2025
@astralcai astralcai self-requested a review July 14, 2025 19:00
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Thanks @comp-phys-marc!

comp-phys-marc and others added 2 commits July 18, 2025 14:53
Co-authored-by: Mudit Pandey <[email protected]>
Co-authored-by: Mudit Pandey <[email protected]>
Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

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

Nice Work! 🚀

Co-authored-by: Astral Cai <[email protected]>
@comp-phys-marc comp-phys-marc enabled auto-merge July 23, 2025 18:17
@comp-phys-marc comp-phys-marc added this pull request to the merge queue Jul 24, 2025
Merged via the queue into master with commit 135cf76 Jul 24, 2025
54 checks passed
@comp-phys-marc comp-phys-marc deleted the feature/template-refactoring branch July 24, 2025 14:20
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