Skip to content

Matrix free gradients and minor utilities/bugfixes - #5

Open
erikbaeske wants to merge 21 commits into
mbruno46:masterfrom
erikbaeske:feature/matrxifreegradients
Open

Matrix free gradients and minor utilities/bugfixes#5
erikbaeske wants to merge 21 commits into
mbruno46:masterfrom
erikbaeske:feature/matrxifreegradients

Conversation

@erikbaeske

Copy link
Copy Markdown

The changes add some utilities for (complex) observables:

  • obs.sqrt(), obs.abs(), obs.re, obs.im
  • pyobs.observable.from_data() wrapper combining obs = pyobs.observable() and obs.create()
  • Ellipses slicing and obs.iloc[] for numpy-like slicing (dropping dimensions if indexed by an integer)
  • tensor utilities: obs.T for transposition, obs.contraction() for einsums of a single tensor and obs.inv() for inversion
  • some printing improvements

The main feature included in these changes is the matrix free gradient mode accessed via pyobs.set_matrixfreegrad(option):

  • if option is False then the gradients are applied as Na x Ni matrices on the Ni x Ncnfg fluctuations as before (default)
  • if option is True all gradients are applied per configuration to each fluctuation vector
  • if option is an integer a mixed mode routes to the matrix free gradient mode if the size of the observable is above the threshold specified by option

The advantage of the gradient free mode is that the Na x Ni gradients 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 single N x N matrix and the memory footprint

image

…ot holomorphic) functions, check that error of the imaginary part of z+z* vanishes identically
…functions (non-issue for default gradient which constructs the matrix during the eagerly during the loop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant