Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add caching to the autograd batch interface #1508
Add caching to the autograd batch interface #1508
Changes from all commits
0c57919
674604b
688f4a2
9a8476b
0413307
6b44284
35e1848
67e216a
d0e40f8
89bdd8d
f415d9f
a4592da
9153c45
6c5dc72
11f20b3
122194c
e98c835
5956967
8e3159f
3cbfc22
b36ec30
3bd36bf
d644228
81bd371
9a19ce2
44ca01d
b4bb9d2
102d551
55be8f2
49412da
b5e4665
11ebfe1
ff2ecb0
efa7c49
4f8342a
0818184
815e1f3
59572bf
378bcd4
1ca227a
1942afb
96b567e
2e5e9a9
0ad93f6
2057b86
6d77f3e
c1ccb0d
6aebd37
3e0c909
2f7aeac
c540c53
5fb9a4b
cbbb5f0
9e749ef
57b747a
029e5bf
64e0dd1
b7a58cf
77e5df1
3d2b9b6
34b379b
aec3cc0
9e0eb7a
142a662
ec0bf60
354aec9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Clever recombination :)
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.
Clever, but this ends up being slow if there is no tape duplication/caching 🤔
It seems that there is always a tug of war between reducing quantum evals, and reducing classical compute time
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.
Do we have an idea of the memory implications of this? 🤔
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.
Assuming you do not pass a
cache
object manually to theexecute
function, thecache
will be created insideexecute
. What this means is that - as soon asexecute
has exited, the cache is out of scope and will be garbage collected by Python.I am 99.99% sure of this, but don't know how to sanity check 😖
This is from the last time I tried to explore this: #1131 (comment)
Do you have any ideas on how to double check that the cache is deleted after execution?
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.
well-explained!
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.
Nice
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.
Probably my unfamiliarity with the recent changes, but do we expect to need caching for device-based gradients? I thought this was mainly for parameter shift.
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.
Caching is only needed for device-based gradients if
mode="backwards"
. Backwards mode essentially means:This means that there will always be 1 additional eval required -- caching therefore reduces the number of evals by 1 😆
Worth it?
I mean, I'd expect 99% of users to use device gradients with
mode="forward"
.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.
Sounds good!
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.
Does this supersede #1341?
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.
No this complements it for now 🙂
#1341 added the
use_device_state
keyword argument which instructsQubitDevice.adjoint_jacobian()
to use the existing device state and avoid a redundant forward pass.When
mode="forward"
, we can pass this option: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.
Oh, surprised this wasn't there yet!
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.
It was on the
CircuitGraph
, but not the tape!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.
Also needed to compute hashes?