-
Notifications
You must be signed in to change notification settings - Fork 586
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
Add support for mid-circuit measurement program capture #6015
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6015 +/- ##
==========================================
+ Coverage 99.52% 99.66% +0.13%
==========================================
Files 430 430
Lines 41835 41452 -383
==========================================
- Hits 41637 41312 -325
+ Misses 198 140 -58 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems pretty good! Just a few questions for my own understanding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 💯
I'm guessing you abandoned cond(m, fun)()
?
I also vaguely remember at the start you told me that other primitives that have been implemented didn't work with measure yet because it didn't exist, and that you would need to update those. Was that just the measurement processes of mcms or do you remember if there was anything else?
@dime10 That's in a different PR #6058 (though that needs to be updated as well)
It was just the measurement processes of MCMs, which is working in this PR. |
Context:
This PR is following up on the new program capture effort by adding support for capturing mid-circuit measurements. Currently, mid-circuit measurements can be captured, classically processed, and executed, with specific constraints, but cannot be used with
qml.cond
Description of the Change:
qml.measure
. This primitive's concrete implementation is basically the same as the original, where it queues aMidMeasureMP
and returns aMeasurementValue
, but its abstract eval returns abooleaninteger tracer. Follow up work will take advantage of this.Benefits:
jnp.sin(m)
,jnp.array([m1, m2])
, and evenjnp.max(jnp.array([m1, m2])
! All of this can be captured, but not executed.qml.RX(m, 0)
, can be captured, but not executed.qml.capture.enable()
. This only works when the circuit does not classically process MCMs or appliesqml.cond
with MCMs in the predicate.