Matrix free gradients and minor utilities/bugfixes - #5
Open
erikbaeske wants to merge 21 commits into
Open
Conversation
…ot holomorphic) functions, check that error of the imaginary part of z+z* vanishes identically
… and obs.create()
… vector_obs type multiplciation
…functions (non-issue for default gradient which constructs the matrix during the eagerly during the loop)
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.
The changes add some utilities for (complex) observables:
obs.sqrt(),obs.abs(),obs.re,obs.impyobs.observable.from_data()wrapper combiningobs = pyobs.observable()andobs.create()obs.iloc[]for numpy-like slicing (dropping dimensions if indexed by an integer)obs.Tfor transposition,obs.contraction()for einsums of a single tensor andobs.inv()for inversionThe main feature included in these changes is the matrix free gradient mode accessed via
pyobs.set_matrixfreegrad(option):optionisFalsethen the gradients are applied asNa x Nimatrices on theNi x Ncnfgfluctuations as before (default)optionisTrueall gradients are applied per configuration to each fluctuation vectoroptionis an integer a mixed mode routes to the matrix free gradient mode if the size of the observable is above the threshold specified byoptionThe advantage of the gradient free mode is that the
Na x Nigradients don't have to be allocated which reduces the memory footprint and is then needed to apply functions to very large observables. For small observables it is typically not neeeded and there is a certain trade-off in speed (batched matrix vector products vs python loops). See for example the graph below showcasing the time it takes to calculate the inverse of a singleN x Nmatrix and the memory footprint