-
Notifications
You must be signed in to change notification settings - Fork 121
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
fix: Support single-register measurements in from_ir
#934
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #934 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 133 133
Lines 8905 8906 +1
Branches 2006 2007 +1
=========================================
+ Hits 8905 8906 +1 ☔ View full report in Codecov by Sentry. |
@@ -799,6 +799,24 @@ def test_from_ir_with_measure(): | |||
assert Circuit.from_ir(source=ir.source, inputs=ir.inputs) == expected_circ | |||
|
|||
|
|||
def test_from_ir_with_single_measure(): |
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 add tests to do a round trip transformation? Circuit -> OQ3 -> Circuit.from_ir
and assert that the original and the parsed circuit are the same
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 will add a round trip test.
This test_from_ir_with_single_measure
test would not have the same OpenQASM output though because Circuit.from_ir
would not output b = measure q
since the BDK does not handle the measure assignment.
So instead it would output:
b[0] = measure q[0];
b[1] = measure q[1];
from_ir
assert new_ir == ir | ||
assert Circuit.from_ir(source=ir.source, inputs=ir.inputs) == 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.
This is already covered by other test cases, right? Not that I'm complaining.
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.
Yes, it is covered by other test cases
Issue #, if available:
Currently, the statement
b = measure q
in an OpenQASM program results in the following error:ValueError: Operator qubit count 1 must be equal to size of target qubit set QubitSet([Qubit(0), Qubit(1)])
This is because a
measure
instruction is always a 1 qubit instruction but right now, all the targets get added to the measure instruction even if there are more than 1 qubit measured.To reproduce this issue:
Description of changes:
Testing done:
tox
andtox -e integ-tests
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.