-
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
[WIP] Make a separate base quantum tape class #829
Conversation
Codecov Report
@@ Coverage Diff @@
## master #829 +/- ##
=======================================
Coverage 97.68% 97.68%
=======================================
Files 135 136 +1
Lines 9107 9117 +10
=======================================
+ Hits 8896 8906 +10
Misses 211 211
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.
💯
To fix the failing Sphinx CI, you'll need to update the
:meth:`~.jacobian`
to be
:meth:`~.JacobianTape.jacobian`
in the QuantumTape.trainable_params
docstring
Co-authored-by: Josh Izaac <josh146@gmail.com>
…into make_baseqnode_class
Did not review the PR, but if @josh146 approves, go for it! |
For future development, for example when introducing a batch tape, it would be cleaner to have a "base" quantum tape class that only implements functionality for constructing, evaluating and validating circuits. The current
QuantumTape
class would inherit from this base class and add functionality for differentiation.The aim of this PR is to check and discuss how invasive such a change would be.
About naming: we reserve the name
QuantumTape
for the new base tape class, and introduceJacobianTape
for the tape that implements differentiation.JacobianTape
has all functionality of the currentQuantumTape
class. While this is much clearer, it makes the PR quite large, even though most changes are just renamings.Advantages: Conceptually, the representation of a circuit and the ability to compute its Jacobian are two separate features, one extending the other. Classes can now inherit from the base tape without inheriting a specific implementation of the
jacobian
method.Disadvantages: Differentiation and circuit construction are not entirely distinct, since the circuit construction uses logic on differentiable and non-differentiable parameters. It seems that the only function that lives at this intersection is
_update_gradient_info()
, which adds the preferred diff method to trainable parameters. Here, this function is made a property of the jacobian quantum tape.Note: At the moment, the PR does not contain any changes to documentation, which would have to be added if we decide to follow this route.