Batching and Parallelization #28
PardhavMaradani
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @orbeckst, @jeremyleung521, @amruthesht, @HeydenLabASU,
Given there were a few questions about how batching and parallelization work during yesterday's sync-up, here is a brief writeup on how they are currently implemented:
Each analysis widget has two attributes that specify it's 'run frequency' and 'run mode' respectively.
_run_frequencyspecifies how often the widget is run. It takes one of two values:every-frameorbatch._run_modespecifies how the widget code is run. It takes one of two values:serialorparallel.Both the attributes are mutually exclusive.
Here are the defaults as specified in the
WidgetBaseclass:A widget class can make these attributes dynamically changeable at runtime as well by making them as inputs, which then show corresponding options in the GUI.
ROGandDSSPwidgets are current examples where both of these are configurable at runtime from the GUI._run_frequencyAs the name indicates, this specifies how often the widget is run.
When
_run_frequencyisevery-frame, a method is invoked for every frame of the trajectory iteration.When
_run_frequencyisbatch, a method is invoked when a new batch of timesteps is full. A global 'Batch size' under 'Settings > Universe Configuration' controls the size of the timesteps buffer.The method that is invoked depends on the
_run_mode.If the
_run_modeisparallel, see the next section to see what gets invoked.If the
_run_modeisserial:When
_run_frequencyisevery-framearun_every_framemethod is invoked.When
_run_frequencyisbatch, arun_batchmethod is invoked._run_modeThis attribute specifies how the widget analysis code is run.
If the
_run_modeisparallelfor a given widget instance, aget_parallel_jobmethod is invoked to retrieve the parallel job (ajoblib.delayedtuple). A global 'Parallel Jobs' under 'Settings > Dashboard Configuration' controls the total number of jobs run in parallel during each iteration (n_jobsparam ofjoblib.Parallelcall).If a widget has
_run_modeasparallel, after the parallel job is completed, aapply_parallel_resultsmethod is invoked where the results from the parallel job are passed back to the instance. The instance can apply the results back to its data structures (like updating it's valuesdequeetc).If a widget has
_run_modeasserial, one of the methods described in the previous section are invoked.Timesteps buffer
Irrespective of when or how they are invoked, all the methods described above have access to the full timesteps buffer - last 'n' frames including the current frame (The size of this buffer is the 'Batch size') and can use regular indexing to access them.
The
ROGanalysis widget shows an example of how this buffer is manually iterated in batch mode. TheDSSPanalysis widgets shows an example of how to invoke theAnalysisBase-run()in both batch / every-frame mode.Hopefully this info will help with how we add new analysis widgets.
Thanks
ps. The implementation above closely follows what was discussed in Execution of Dashboard widgets
Beta Was this translation helpful? Give feedback.
All reactions