DataParallelStrategy#
- class braintools.trainer.DataParallelStrategy(devices=None, axis_name='batch')#
Data parallel strategy using pmap.
Replicates the model across all devices and splits data batches. Gradients are synchronized using all-reduce.
- Parameters:
Examples
>>> strategy = DataParallelStrategy() >>> trainer = Trainer(strategy=strategy)
- broadcast(tensor, src=0)[source]#
Broadcast tensor from the source replica to all replicas.
Implemented via
all_gather+ index rather thanppermute: a broadcast is one-source-to-many-destinations, whichppermutecannot express (it requires unique sources and destinations). (T-D)- Return type: