-
Notifications
You must be signed in to change notification settings - Fork 27
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
Efficient Gradients with the Adjoint Method #90
Closed
Closed
Conversation
This file contains 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
basically didn't change anything except added targtet state and reversed the counting index.
However the legs are not pointing the correct direction: TODO Also added the lists that store the forwardprop and backprop as well as the lines that append the nodes to the list in the correct place
Each tensor in the backprop now has its legs swapped (either through numpy swapaxes in _get_pt_mpos_backprop in the for loop, or alternatively is transposed in the case of the system operators. The network is propagated upwards as described in the visual diagrams, but because of the axes swaps, time now runs downwards in those diagrams
Created the high level functions that the user will use, and a class to contain the gradient results. Added the loop into the backprop that combines the forwardprop and backprpop tensors. This deviates from my private version of the code where this loop was entirely seperate to the forwardprop and backprop. The reason for this change is to allow me to delete the forwardprop tensors as I generate the backprop. This reduceds the amount of memory needed for the adjoint method by 50%.
I haven't debugged it but it has all of the methods it needs for now.
Did not debug this prob doesn't work, or even compile.
Only imports PT and v barebones right now
now get index for chain rule using interp1d which makes way more sense as it removes all of the floating point error bullshit A lot of the old method by searching sorted lists was deleted in this commit so if you're missing something and you want to look how the previous method searched through a sorted list look at the previous commit
fixed the lines that store the backpropagated tensors and delete them accordingly Also fixed a bug where in the backpropagation the indices were one ahead of what they should have been, because since we are propagating backwards, the propagators we are actually interested in are the ones associated with the previous step in the forwardprop
Forgot that i need N(MPOs)+1 dprop lists, not N.
'Tis bugged.....
i had a z and an x mi8xed up, gradients still aren't correct, however they're currently considerably better They're wrong because i'm taking the derivative across two half timesteps, but i'm not reintroducing the second when i'm combinging the derivatives with dprop dsys, next update.....
finds two numbers that differ by one ascending in a list, and checks if the first one is even this is the condition necessary for adjacent operators in the algorithm
added a brif sketch of what the code should look like when i add the ability to use two propagators. this code is currently broken, debugging....
Basically made the previous algorithm i introduced defunct as i'm not convinced it adds any time saving that would warrent the increase in complexity and modes of failure of the code. Instead added the extra node necessary during the chain rule, which i previously forgot to add. Whole thing is still bug, one is because i haven't treated the first and last half propagator seperately as they're a special case, but there is more bugs that i don't know about
I felt like what i was doing was too long-winded for a single tutorial so I decided it'd be better to split it up into a very introductory tutorial and then a seperate one to talk about optimisation and how that would be done. This is in addition to a seperate tutorial that will talk about the chain rule and finite differencing / autograd
where foreward and backprop lists are both specified. this wouldn't have affected the other case where i delete the foreward and backprop lists and just give total derivitives (which are still bugged)
but i don't like it i'm prob gonna change some stuff
I think it's currently bugged, this will be converted into a jupyter notebook when it's done. it's currently pretty hardcoded.
improved dprop accessability and understandability, and tested it to make sure it works properly
deleted script that had no purpouse other than a proof of concept
Basically reverted previous change and made the gradient function return the dynamics object so can reuse adjoint calculation for different dprop lists
christ that was awful
Updated the frontend comments / documentation Added the retain forward-prop and back-prop user flag to the frontend (previously it was just in the backend)
get_hamiltonian now makes way more sense.....
it's at the start of the tutorial As piper suggested
Deleted redundant tutorials
piperfw
changed the title
Effecient Gradients with the Adjoint Method
Efficient Gradients with the Adjoint Method
Mar 21, 2023
_chain_rule now uses correct dfidelity
ebutler414
force-pushed
the
eoin_gradients
branch
from
January 4, 2024 15:24
1e863e9
to
9c54639
Compare
added ParametrizedSystem, as well as an example of how this script should work. Most of this was originally written by gerald
This approach will break my previous code, but retains all of it's power and is more succient. This should work perfectly as is with gerald's example
Plan is for it to instead inherit from a propegator based class, seperate for gradient code, that just supplies a list of propagators instead of a hamiltonian
The PropagatorSystem should be pretty functional, the other one, is very much not
This PR is a previous draft of #127. |
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.
Efficient Gradients with the Adjoint Method
As per email correspondence, the end UI could be improved and the explanations contained in the tutorial are in a pretty raw state, but the code is hopefully in less of a raw state ;)
I have left a lot of these tasks unchecked until the final form of the end UI has been decided
Best
Eoin
tox -e py36
(to runpytest
) the code tests.tox -e style
(to runpylint
) the code style tests.tox -e docs
(to runsphinx
) generate the documentation./docs/pages/modules.rst
has been updated./docs/pages/api.rst
has been updated.