-
Notifications
You must be signed in to change notification settings - Fork 643
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
Support drawing qml.cond
: Part 1
#4803
Conversation
[sc-49112] |
[sc-49764] |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4803 +/- ##
==========================================
- Coverage 99.65% 99.64% -0.02%
==========================================
Files 385 385
Lines 34719 34569 -150
==========================================
- Hits 34599 34446 -153
- Misses 120 123 +3 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
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 looking really and an impressive amount of work 🎉
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.
amazing! some of the content can be a bit tough to parse through... but that's tape_text for ya
This PR depends on #4832 and #4803  [sc-48302] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
This PR depends on #4832 and #4803  [sc-48302] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Context:
Adding support for
qml.cond
for mid-circuit measurement drawing withqml.draw
. This PR adds support for using one mid-circuit measurement with multipleqml.cond
s, where eachqml.cond
uses the same mid-circuit measurement. An example of the drawing is shown below:Note: This PR contains work that is foundational for follow up PRs but isn't used for drawing the cases mentioned above. I'll add arbitrary testing to get full coverage, but the aforementioned cases will be the only ones considered to currently be complete.
Description of the Change:
drawable_layers
:drawable_layers
no longer stacks mid-circuit measurements used by aqml.cond
in the same layer.drawable layers
now considers all wires under a mid-circuit measurement used for conditioning to be used.drawable_layers
now considers all wires under aqml.cond
to be used.tape_text
:tape_text.py
for correctly adding labels for mid-circuit measurements andqml.cond
s, as well as for correctly padding the width of the layers for unused wires.tape_text.py
for getting information about connectivity between mid-circuit measurements and conditional operations to keep track of when to start and stop drawing classical bits.tape_text()
now tracks abit_map
, which stores a mapping between mid-circuit measurements and classical bits that are drawn for them. Classical bits are drawn using double lines═
, and are placed under the wires in the drawing. Each mid-circuit measurement used for conditioning uses a classical bit. Measurements not used for conditioning are not allocated a bit.tape_text()
now pads the classical bits between each layer of the drawing along with the wires.tape_text.py::_add_measurements()
.Other changes:
label
toqml.transforms.Conditional
.qml.equal
to consider postselection when comparingMidMeasureMP
s. This was missed in Allow postselecting on mid-circuit measurements #4604.Benefits:
Drawing support for mid-circuit measurements is better :)
Possible Drawbacks:
Code in
tape_text.py
is less readable. After a discussion with @trbromley , we decided that the best course of action is to leave refactoring as technical debt for the end of the release cycle. Reviews pertaining to major refactors are still appreciated :)Related GitHub Issues:
#4809