mixle.utils.parallel.torch_training module¶
Executable PyTorch distributed-gradient backend.
This is the native path for arbitrary Mixle nn.Module objects. It uses
public PyTorch APIs: DeviceMesh/DTensor tensor parallelism, FSDP2 (including
HSDP), DDP, distributed checkpoint-compatible optimizer state, and the
experimental context-parallel SDPA context manager. Pipeline and expert
parallel transformer training belong to the Megatron backend, whose model
partitioner owns those semantics.
- class TorchDistributedBackend[source]
Bases:
objectNative backend for Mixle modules that remain ordinary PyTorch modules.
- class TorchDistributedSession(module, *, plan, capabilities, mesh, device, optimizer, optimizer_receipt, parameter_layouts, precision, max_grad_norm, scheduler=None, manual_data_parallel=False)[source]
Bases:
objectA transformed module plus optimizer and explicit process-mesh semantics.
- Parameters:
- train_batch(inputs, targets)[source]
Accumulate one local batch and commit when the configured clock fires.
- discard_accumulation()[source]
Explicitly discard pending gradients without changing parameters or optimizer state.
- Return type:
StepReceipt | None
- save_checkpoint(path, *, loader_state=None, typed_scheduler_state=None, extra=None, asynchronous=False)[source]
Save all state needed to resume this session.
- load_checkpoint(path, *, allow_world_size_change=False)[source]
Restore this transformed model/optimizer and resume its step clock.