braintools.trainer.get_strategy

Contents

braintools.trainer.get_strategy#

braintools.trainer.get_strategy(strategy='auto', **kwargs)[source]#

Get a distributed training strategy by name.

Parameters:
  • strategy (str | Strategy | None) – Strategy name or instance. Options: ‘auto’, ‘single’, ‘ddp’, ‘dp’, ‘fsdp’, ‘sdp’

  • **kwargs – Additional arguments passed to the strategy constructor.

Returns:

The requested strategy instance.

Return type:

Strategy

Examples

>>> import braintools
>>> braintools.trainer.get_strategy('ddp').name
'data_parallel'
>>> braintools.trainer.get_strategy('single').name
'single_device'
>>> strategy = braintools.trainer.get_strategy('auto', prefer_fsdp=True)
>>> type(strategy).__name__
'AutoStrategy'