TorchftConfig#
- class ray.train.torch.TorchftConfig(lighthouse_kwargs: Dict[str, Any], **kwargs)[source]#
Bases:
TorchConfigConfiguration for fault-tolerant training with torchft.
Pass this as the
torch_configof aTorchTrainerto train with torchft. Ray Train then starts the torchft Lighthouse server as an actor on the node that runs the Ray Train controller, which is usually the head node. It sets theTORCHFT_LIGHTHOUSEenvironment variable on every training worker and creates one process group per replica group instead of one process group across all workers. Each Ray Train worker is its own replica group. When a worker fails, Ray Train replaces only that replica group instead of restarting the whole worker group, and the replacement recovers model and optimizer state from a live peer through torchft.Your training function must also create a
torchft.Managerand wrap the model and optimizer with the torchft primitives. See Fault-tolerant training with torchft for a complete example.Example
from ray.train import FailureConfig, RunConfig, ScalingConfig from ray.train.torch import TorchftConfig, TorchTrainer trainer = TorchTrainer( train_func, scaling_config=ScalingConfig(num_workers=2), torch_config=TorchftConfig( lighthouse_kwargs={"min_replicas": 1}, backend="gloo", ), run_config=RunConfig( failure_config=FailureConfig(max_failures=3), ), )
- Parameters:
lighthouse_kwargs (Dict[str, Any]) – Keyword arguments for the
torchft.coordination.LighthouseServerconstructor.min_replicasis required: the minimum number of replica groups that must be alive to form a quorum and keep training.binddefaults to"[::]:0", which binds the Lighthouse to a free port on the Lighthouse’s node. The torchft version you install defines the remaining keys, such asjoin_timeout_ms,quorum_tick_ms, andheartbeat_timeout_ms.**kwargs – Additional keyword arguments for the
TorchConfigconstructor, such asbackend="gloo"orbackend="nccl".
PublicAPI (alpha): This API is in alpha and may change before becoming stable.
Methods
Attributes
The
Backendclass that sets up this framework on the workers.The training framework this config sets up.
The context manager class wrapping each worker's training function.