-
Notifications
You must be signed in to change notification settings - Fork 627
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
Docstrings construct QuantumTape
via initialization instead of queuing
#4243
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4243 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 352 352
Lines 31733 31733
=======================================
Hits 31665 31665
Misses 68 68
|
QuantumTape
via initialization instead of queuingQuantumTape
via initialization instead of queuing
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.
exciting stuff!
Co-authored-by: Matthew Silverman <matthews@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.
Overall sounds good! 👍
Co-authored-by: Tom Bromley <49409390+trbromley@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.
Formatting suggestions, but otherwise looks good to go 😄
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
This PR updates the documentation for our circuit representation
QuantumTape
to reflect the recommended way of constructing the circuit object.This change has a range of benefits:
Showing external power users how to construct
QuantumTape
directly upon initializationDirect construction avoids the black magic and confusion that occurs with the queuing system. WIth direct construction, what the programmer provides upon initialization is exactly what is in the circuit. The programmer doesn't have to worry about removing a given operation. For example, the circuit could contain both
op
andadjoint(op)
.Direct construction allows the same operation to be used multiple times in a circuit:
It also allows the same operations or measurements to be used in multiple different circuits:
Unifying documentation and source code practices
Right now, our documentation demonstrates a different way of doing things than implement in our source code. Our source code and tests never keep around an
AnnotatedQueue
object after program capture. We always capture the program in anAnnotatedQueue
, and then construct a circuit object (QuantumScript
) via initialization. This allows us to directly control what is going into the circuit, not carry around information we don't need anymore, and leave the circuit (mostly) untouched after initialization.Since external power users, external developers, and new developers do not know that we do something completely different in source code, this leads to confusion and new code that goes against our desired best practices.
By having the documentation reflect our recommend best practices, it will help new developers understand how we want to actually write code.
Freeing up required future changes to PennyLane
Since this documentation change gets power users familiar with the "construction upon initialization" syntax, it frees us up to remove
AnnotatedQueue
fromQuantumTape
in the future. This change will be required to makeQuantumTape
immutable.Immutability will forbid certain classes of bugs, allow
QuantumTape
to better function in a distributed system, improve integration with jax and other machine learning libraries, and open up performance improvements with caching.By making our circuit representation independent of queuing, we also make anything that relies on
QuantumTape
robust to changes to how we perform circuit capture. When we change our user interface and how we capture user circuits, these docstrings should still be valid.