Skip to main content

parallel_step

Function parallel_step 

Source
pub fn parallel_step<O, A, D>(
    optimizer: &mut O,
    params_list: &[Array<A, D>],
    grads_list: &[Array<A, D>],
) -> Result<Vec<Array<A, D>>>
where O: Optimizer<A, D> + Clone + Send + Sync, A: Float + ScalarOperand + Debug + Send + Sync, D: Dimension, Array<A, D>: Clone + Send + Sync,
Expand description

Helper function to update several parameter groups with a single optimizer

This is a convenience function for one-off multi-group processing without creating a ParallelOptimizer instance.

The update is delegated to Optimizer::step_list, which keeps an independent state slot per parameter-group index. Consequently the optimizer state is preserved across calls and groups never share moments.

§Note on parallelism

A single &mut O cannot be mutated from several threads at once, so this helper walks the groups sequentially. Use ParallelOptimizer::step_parallel_groups when you want the groups themselves processed in parallel: it keeps one optimizer instance per group and therefore both parallelizes and preserves state.

§Arguments

  • optimizer - The optimizer to use (its per-index state is updated in place)
  • params_list - List of parameter arrays
  • grads_list - List of gradient arrays

§Returns

Updated parameter arrays