-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
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!
@@ -158,11 +159,17 @@ def test_expectation(self): | |||
all_ops = [x_ops, y_ops, z_ops] | |||
|
|||
# Check with reduce True (this is the default) | |||
# TODO(#71): Decoration yields an error seemingly coming from TFQ: | |||
# LookupError: gradient registry has no entry for: TfqAdjointGradient |
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.
in case it's helpful: I think this happens when one attempts to differentiate a TFQ gradient. I've seen this for Hessians
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.
Here there is just the Jacobian, so there should be no second derivatives, which is why this behavior is surprising. The documentation on custom_gradient
says:
It should be noted tf.GradientTape is still watching the forward pass of a tf.custom_gradient, and will use the ops it watches. As a consequence, calling tf.function while the tape is still watching leads to a gradient graph being built. If an op is used in tf.function without registered gradient, a LookupError will be raised.
So it seems to be caused by some combination of tf.function
decorating and custom_gradient
calls in TFQ. But still, the confusing thing is that it does not happen for regular first derivatives, just jacobians.
* Enable tracing of QuantumCircuit __add__ (#131) * Weighted average utility (#134) * Add new style QHBMs (#125) * Replace custom code with TF op (#141) * Enable EBM seed (#143) * Add modular Hamiltonian expectation (#135) * Energy expectation (#150) * Update TF, TFP, and TFQ versions (#152) * try updating * update python versions * Tests passing * increase tolerance for flaky test * update setup.py * Utility function tests (#153) * Eager toggle decoration completion (#155) * circuits test passing * expectation test failing * parameter change * more tests * start refactor * add parameters to circuits * test passing * format * remove lint * revert superfluous changes * Restart CI * Update hamiltonian_infer_test.py * address review comments * restart CI Co-authored-by: Faris Sbahi <farissbahi@gmail.com>
* Enable tracing of QuantumCircuit __add__ (#131) * Weighted average utility (#134) * Add new style QHBMs (#125) * Replace custom code with TF op (#141) * Enable EBM seed (#143) * Add modular Hamiltonian expectation (#135) * start function * function written * start test fixture * initial test completed * test passing * remove lint * do not restrict to layers * typo * format * Initial gradient function written * Energy expectation (#150) * Update TF, TFP, and TFQ versions (#152) * try updating * update python versions * Tests passing * increase tolerance for flaky test * update setup.py * tests passing again * rempve extra layers * generalize derivative code * Enable tracing of QuantumCircuit __add__ (#131) * Weighted average utility (#134) * Add new style QHBMs (#125) * Replace custom code with TF op (#141) * Enable EBM seed (#143) * Add modular Hamiltonian expectation (#135) * Energy expectation (#150) * Update TF, TFP, and TFQ versions (#152) * try updating * update python versions * Tests passing * increase tolerance for flaky test * update setup.py * Utility function tests (#153) * Eager toggle decoration completion (#155) * basic test passing again * initial analytic expectation test * add broken utils test * weighted average now uses einsum * tests passing * tests passing * format * remove lint * update args to tensors * format * add tf function togfgle to test * remove lint * extend linter timeout window * remove tape argument * check gradients are gapped away from zero * change to atol * change to atol * tweak tolerances * remove superfluous argument to inner function * format * update docstring * add gradient graph test * add todo * format * change docstring * remove lint Co-authored-by: Faris Sbahi <farissbahi@gmail.com>
* Enable tracing of QuantumCircuit __add__ (#131) * Weighted average utility (#134) * Add new style QHBMs (#125) * Replace custom code with TF op (#141) * Enable EBM seed (#143) * Add modular Hamiltonian expectation (#135) * Energy expectation (#150) * Update TF, TFP, and TFQ versions (#152) * try updating * update python versions * Tests passing * increase tolerance for flaky test * update setup.py * Utility function tests (#153) * Eager toggle decoration completion (#155) * generalize QuantumInference expectation * removed reduced tests * inferece change * revert * genralize expectation * circuit infer tests passing * update infer * checkout energy files * format * circuit tests passing * updated h infer test passing * circuit tests passing * inference tests passing * format * remove lint * vqt tests passing * format * remove lint * start updating circuit infer * infere * update infere * energy tests passing * update infer * move arg * hamuiltonian inference tests passing * format * circuit infer test * remove lint * update vqt tets * format * tolerance update * lint Co-authored-by: Faris Sbahi <farissbahi@gmail.com>
Add
tf.function
tracing tests.Added the tracing to non-initialization tests of the various classes. Resolves #136.