Repository navigation
gradient engine speed improvements (approx. 25% for 4 modes, 1024x 1024) with managing fft shifts - #153
Merged
Conversation
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.
What and why
GradientEngine iterations spent much of their GPU time on FFT shifts that copy every probe mode's full field. These changes apply the shifts to smaller arrays (the patch, the probe and the summed intensity), which gives the same results faster.
PtyLab/Engines/GradientEngine/propagation.py: addKernelPropagator.unshifted, the same propagation without the outerfftshift/ifftshift.PtyLab/Engines/GradientEngine/models.py:forwardshifts the object patch, the probe and the summed intensity instead of every mode's field.illuminationsquares a shared probe once instead of once per frame.PtyLab/Engines/GradientEngine/engine.py: clearercompiledocstring.How it was tested
New
test_forward_matches_centered_fields: the new path gives the same intensities and gradients as the centered fields for all propagators, with mixed states and OPR. The full test suite passes.Notes
Results are unchanged, and data, background and masks stay in centered order. With 4 probe modes at 1024 x 1024 an iteration is about 25 % faster on an H200; with one mode the speed is about the same, except scaledASP, which is about 17 % faster. ASP is unchanged. The shifts reuse temporary memory, so saves memory traffic, but the peak memory use is unaffected.