Gradient fix#1
Draft
oscar-wallis wants to merge 5 commits intomainfrom
Draft
Conversation
* Add support for `Python 3.13` * Add note for tutorial tests * Add support for `Python 3.13` * Add note for tutorial tests * Update .github/workflows/main.yml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Update `def __eq__` in optimizers * Implement the convention `def __eq__(self, other: object) -> bool:` * Fix typos * Fix shape in steppable optimizer --------- Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
… also vendoring _circuit_key() function
|
@oscar-wallis you could try with the new code in 0.9, and see if you get a speedup on this proj. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
I have added
self._isa_circuit_cachedictionaries to the base gradient methods to act as a cache. The cache stores the ISA circuits for each gradient method with a circuit key from Qiskit 1.4_circuit_keyfunction, which I have vendored here. The idea being that before a circuit is transpiled, the gradient object checks if the transpilation has already occurred and, if so, pulls the previously transpiled circuit.Details and comments
I have been testing that this works using a script I will share internally, and I have noticed 2 things,
The gradient calculations are still incredibly slow. I assume that this is due to the GenericBackend jobs and not our code, though it would be worth testing with some other backend to check.
Adding the caches is making the runtime longer, which is less than ideal. I am guessing this is because the computation time added by the caching is longer than the computation time saved by not transpiling on the small instances I have checked. I have not been able to check larger circuit sizes as the run time is just nuts.
To Do