Skip to content

Move capture code closer to its equivalent use case #7608

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 6 commits into
base: master
Choose a base branch
from

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Jun 4, 2025

Context:

When we first started, I tried to keep program cpature code isolated so it wouldn't cause confusion and complexity during standard developement. Now it's much more fleshed out, and instead it causes problems with module dependencies.

Description of the Change:

Moves operator, measurement, and gradient capture code closer to the code that it captures.

Benefits:

Clearer chain of dependencies.

Possible Drawbacks:

As program capture is still fairly experimental, I'm not concerned about moving things breaking anything.

Related GitHub Issues:

[sc-92605]

@albi3ro albi3ro requested a review from andrijapau June 4, 2025 21:55
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.60%. Comparing base (5322c9b) to head (8d9a089).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7608      +/-   ##
==========================================
- Coverage   99.68%   99.60%   -0.08%     
==========================================
  Files         531      530       -1     
  Lines       51979    52040      +61     
==========================================
+ Hits        51815    51835      +20     
- Misses        164      205      +41     

☔ 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

@andrijapau andrijapau 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 great, could you make a story in the circular dependencies epic for this?

@albi3ro albi3ro requested a review from andrijapau June 5, 2025 13:51
@albi3ro albi3ro requested a review from JerryChen97 June 6, 2025 15:47
@@ -204,21 +201,19 @@ def create_measurement_wires_primitive(
if not has_jax:
return None

from .custom_primitives import QmlPrimitive # pylint: disable=import-outside-toplevel
from ..capture.custom_primitives import QmlPrimitive # pylint: disable=import-outside-toplevel
Copy link
Contributor

Choose a reason for hiding this comment

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

😨

Copy link
Contributor

Choose a reason for hiding this comment

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

Will this cause any potential risk?

Copy link
Contributor

@andrijapau andrijapau left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

Pure move-around, I can't think of any obvious issue! Let's see how CI feels

@@ -204,21 +201,19 @@ def create_measurement_wires_primitive(
if not has_jax:
return None

from .custom_primitives import QmlPrimitive # pylint: disable=import-outside-toplevel
from ..capture.custom_primitives import QmlPrimitive # pylint: disable=import-outside-toplevel
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this cause any potential risk?

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