XLAStrategy¶
- class lightning.fabric.strategies.XLAStrategy(accelerator=None, parallel_devices=None, checkpoint_io=None, precision=None, sync_module_states=True)[source]¶
Bases:
ParallelStrategyStrategy for training multiple TPU devices using the
torch_xla.distributed.xla_multiprocessing.spawn()method.- all_gather(tensor, group=None, sync_grads=False)[source]¶
Function to gather a tensor from several distributed processes.
- all_reduce(output, group=None, reduce_op=None)[source]¶
Reduces the given tensor (e.g. across GPUs/processes).
- barrier(name=None, *args, **kwargs)[source]¶
Synchronizes all processes which blocks processes until the whole group enters this function.
- process_dataloader(dataloader)[source]¶
Wraps the dataloader if necessary.
- Parameters:
dataloader¶ (
DataLoader) – iterable. Ideally of type:torch.utils.data.DataLoader- Return type:
MpDeviceLoader
- save_checkpoint(path, state, storage_options=None, filter=None)[source]¶
Save model, optimizer, and other state as a checkpoint file.
- Parameters:
path¶ (
Union[str,Path]) – A path to where the file(s) should be savedstate¶ (
dict[str,Union[Module,Optimizer,Any]]) – A dictionary with contents to be saved. If the dict contains modules or optimizers, their state-dict will be retrieved and converted automatically.storage_options¶ (
Optional[Any]) – Additional options for theCheckpointIOpluginfilter¶ (
Optional[dict[str,Callable[[str,Any],bool]]]) – An optional dictionary of the same format asstatemapping keys to callables that return a boolean indicating whether the given parameter should be saved (True) or filtered out (False).
- Return type:
- setup_environment()[source]¶
Setup any processes or distributed connections.
This must be called by the framework at the beginning of every process, before any distributed communication takes place.
- Return type: