XLAStrategy
- class lightning.fabric.strategies.XLAStrategy(accelerator=None, parallel_devices=None, checkpoint_io=None, precision=None, sync_module_states=True)
Bases:
ParallelStrategyStrategy for training multiple TPU devices using the
torch_xla.distributed.xla_multiprocessing.spawn()method.- _configure_launcher()
Attach the launcher based on Strategy.
- Return type:
- all_gather(tensor, group=None, sync_grads=False)
Function to gather a tensor from several distributed processes.
- all_reduce(output, group=None, reduce_op=None)
Reduces the given tensor (e.g. across GPUs/processes).
- barrier(name=None, *args, **kwargs)
Synchronizes all processes which blocks processes until the whole group enters this function.
- broadcast(obj, src=0)
Broadcasts an object to all processes.
- module_to_device(module)
Moves the model to the correct device.
- Return type:
- process_dataloader(dataloader)
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)
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()
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:
- setup_module(module)
Performs setup for the model, e.g., by wrapping it by another class.
- Return type:
- property root_device: device
Returns the root device.
Was this page helpful?
Thanks for the feedback.