Shortcuts

HorovodStrategy

class pytorch_lightning.strategies.HorovodStrategy(accelerator=None, parallel_devices=None, checkpoint_io=None, precision_plugin=None)[source]

Bases: pytorch_lightning.strategies.parallel.ParallelStrategy

Plugin for Horovod distributed training integration.

all_gather(result, group=None, sync_grads=False)[source]

Perform a all_gather on all processes.

Return type:

Tensor

barrier(*args, **kwargs)[source]

Synchronizes all processes which blocks processes until the whole group enters this function.

Parameters:

name – an optional name to pass into barrier.

Return type:

None

broadcast(obj, src=0)[source]

Broadcasts an object to all processes.

Parameters:
  • obj (TypeVar(TBroadcast)) – the object to broadcast

  • src (int) – source rank

Return type:

TypeVar(TBroadcast)

model_to_device()[source]

Moves the model to the correct device.

Return type:

None

post_backward(closure_loss)[source]

Run after precision plugin executes backward.

Return type:

None

reduce(tensor, group=None, reduce_op='mean')[source]

Reduces a tensor from several distributed processes to one aggregated tensor.

Parameters:
  • tensor (Union[Any, Tensor]) – the tensor to sync and reduce

  • group (Optional[Any]) – the process group to gather results from. Defaults to all processes (world)

  • reduce_op (Union[ReduceOp, str, None]) – the reduction operation. Defaults to ‘mean’/’avg’. Can also be a string ‘sum’ to calculate the sum during reduction.

Return type:

Union[Any, Tensor]

Returns:

reduced value, except when the input was not a tensor the output remains is unchanged

setup(trainer)[source]

Setup plugins for the trainer fit and creates optimizers.

Parameters:

trainer (Trainer) – the trainer instance

Return type:

None

teardown()[source]

This method is called to teardown the training process.

It is the right place to release memory and free other resources.

Return type:

None

property handles_gradient_accumulation: bool

Whether the plugin handles gradient accumulation internally.

property root_device: torch.device

Return the root device.