-
Notifications
You must be signed in to change notification settings - Fork 69
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 qasm measurement #555
add qasm measurement #555
Conversation
Thanks @MashAliK! 🤩 I've requested reviews from our team. |
# only X and CNOT queued (not 4 x qml.measure) | ||
assert len(recorder.queue) == 2 | ||
# X and CNOT queued with 4 x qml.measure | ||
assert len(recorder.queue) == 6 |
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.
this is what "breaks" by defaulting to None
instead of []
above
This is looking good, thanks @MashAliK 🎉 There are some failing tests, but I don't think they are related to your PR (most of them definitely aren't). We'll work on getting that updated and get back to you soon, don't worry about it for now. Don't forget to update the changelog to include the change, and list yourself as a contributor! This should definitely go under "Improvements". As mentioned above, we may also want to include a second entry for it in "Breaking changes" - let's see what people think makes sense. |
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.
The testing issue from the master branch should be resolved very soon!
In the meantime, there are a couple of minor checks that are failing for documentation and formatting that should be updated here, so I've left a few comments :)
"""Loads a PennyLane template from a QASM string. | ||
Args: | ||
qasm_string (str): the name of the QASM string | ||
measurements (None | pennylane.measurements.MeasurementProcess | list[pennylane.measurements.MeasurementProcess]): | ||
the PennyLane `measurements <https://docs.pennylane.ai/en/stable/introduction/measurements.html>`_ | ||
that override the terminal measurements that may be present in the input circuit |
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.
Something here is causing Sphinx build for the docs to fail - I think you need to add a blank line here before the Returns
section for the docs to render correctly
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.
Great, looks like the build succeeds now!
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 @MashAliK, good work! Leaving a couple of suggestions similar to Lillian's.
"""Loads a PennyLane template from a QASM string. | ||
Args: | ||
qasm_string (str): the name of the QASM string | ||
measurements (None | pennylane.measurements.MeasurementProcess | list[pennylane.measurements.MeasurementProcess]): | ||
the PennyLane `measurements <https://docs.pennylane.ai/en/stable/introduction/measurements.html>`_ | ||
that override the terminal measurements that may be present in the input circuit |
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.
that override the terminal measurements that may be present in the input circuit | |
that override the terminal measurements that may be present in the input circuit | |
tests/test_converter.py
Outdated
|
||
def test_qasm_measure(self): | ||
"""Tests that measurements specified as an argument are added to the converted circuit.""" | ||
qasm_string = 'include "qelib1.inc";' "qreg q[2];" "creg c[2];" "h q[0];" "cx q[0], q[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.
Could we rewrite the string as the one below in test_qasm_mid_circuit_measure
? (i.e., one instruction in one line)
@lillian542 @obliviateandsurrender Thanks for the suggestions! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #555 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 553 554 +1
=========================================
+ Hits 553 554 +1 ☔ 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.
Looks good to go!
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 @MashAliK!
**Context:** Update to `from_qasm` to work with an update to the `pennylane-qiskit` library (PennyLaneAI/pennylane-qiskit#555) so that optional measurements can be added as a function argument and mid-circuit measurements convert correctly. **Description of the Change:** Added optional `measurements` argument to `from_qasm`. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** #5646 --------- Co-authored-by: lillian542 <[email protected]> Co-authored-by: Utkarsh <[email protected]>
For PennyLaneAI/pennylane#5646.
Updated
load_qasm
to take optional measurements as an argument and added the ability for it to make mid-circuit measurements.Tests added in
tests/test_converter.py
.