-
Notifications
You must be signed in to change notification settings - Fork 575
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
Circuit cutting: Add input validation checks #2251
Conversation
[sc-14724] |
Codecov Report
@@ Coverage Diff @@
## master #2251 +/- ##
=======================================
Coverage 99.27% 99.27%
=======================================
Files 231 231
Lines 18381 18392 +11
=======================================
+ Hits 18247 18258 +11
Misses 134 134
Continue to review full report at Codecov.
|
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.
Thanks @trbromley! Minor suggestions but good to go (looks like codecov isn't as happy as me though 🤔 )
@@ -941,6 +940,33 @@ def circuit(x): | |||
>>> qml.grad(cut_circuit)(x) | |||
-0.506395895364911 | |||
""" | |||
if len(tape.measurements) != 1: |
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.
Do we want to exclude tapes without measurements? Would be fairly simple to return fragment tapes. Though use cases for this is questionable
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.
I think it makes sense to exclude the zero-measurements case:
- It seems strange to go through the (potentially huge) process of cut placement and fragment execution, to contract a tensor network to nothing
- I'm also not sure if it works in the current pipeline in practice
- This is anyway quite an edge case because QNodes will always have at least one measurement. So only if a user applies the transform to a tape could they see this warning.
- It's assumed in this PR
Co-authored-by: anthayes92 <34694788+anthayes92@users.noreply.github.com>
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.
Thanks @anthayes92!
@@ -941,6 +940,33 @@ def circuit(x): | |||
>>> qml.grad(cut_circuit)(x) | |||
-0.506395895364911 | |||
""" | |||
if len(tape.measurements) != 1: |
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.
I think it makes sense to exclude the zero-measurements case:
- It seems strange to go through the (potentially huge) process of cut placement and fragment execution, to contract a tensor network to nothing
- I'm also not sure if it works in the current pipeline in practice
- This is anyway quite an edge case because QNodes will always have at least one measurement. So only if a user applies the transform to a tape could they see this warning.
- It's assumed in this PR
Context:
Adds input validation to the
cut_circuit
transform and supporting tests.