nemo_automodel.components.distributed.pipelining.autopipeline
nemo_automodel.components.distributed.pipelining.autopipeline
Module Contents
Classes
Functions
Data
API
Orchestrates pipeline-parallel training on top of torch.distributed.pipelining.
Build pipeline microbatch chunking metadata for keyword inputs.
PyTorch’s default schedule chunking splits every tensor kwarg on dim 0.
Most AutoModel batch tensors are batch-major and should keep that
default, but some model-owned input layouts place batch on another axis.
The canonical local model part can declare those exceptions by implementing
get_pipeline_kwargs_chunk_dims(kwargs) -> dict[str, int].
Parameters:
Mapping passed to the pipeline schedule. Tensor values may have arbitrary model-defined layouts; the model hook identifies any nonstandard batch axis.
Returns: dict[str, Any] | None
A chunk-spec mapping with the same nested structure as kwargs,
Build the pipeline: validate -> init meta -> split -> schedule.
Run one pipeline schedule step with model-owned input chunking.
Parameters:
Tensor of shape [batch, …] containing the first pipeline stage’s input. Ignored on ranks without the first stage.
Tensor with a model-defined target layout, or None on
ranks without the last pipeline stage.
Mutable list populated with scalar loss tensors, or None
on ranks without the last pipeline stage.
Whether the last stage keeps every microbatch’s output
and returns them merged. This costs two copies of the last stage’s
output for the whole local batch, so pass True only when the
caller reads it.
Keyword schedule inputs. Tensor values may have arbitrary model-defined layouts; model-owned metadata identifies any nonstandard batch axis.
Returns: Any
The last stage’s output for the whole local batch, merged along the
Reset pipeline stage infrastructure for a new sequence length.
VLM training batches can have wildly different sequence lengths across steps (image batches vs. text-only batches). PyTorch’s PipelineStage locks in recv buffer sizes on the first step, causing a shape-mismatch error on later steps with different seq_lens.
Call this before every schedule.step() to update the stage shapes without
running an expensive forward pass. Stage reset is a no-op when seq_len
has not changed; model-owned runtime initializers are still prepared.
Parameters:
Sequence length of the upcoming batch (input_ids.shape[1]).
Runtime state produced by pipeline-parallel setup.
Context in which new pipeline stages give each directed rank edge its own communicator.
PipelineStage reads PyTorch’s torch.distributed.config.pipeline_per_edge_p2p when it is
constructed, and the schedule then creates one two-rank child communicator per directed edge and
preconnects it before the first step. Without it, PyTorch 2.15 sends every stage’s activations and
gradients through the pipeline process group’s single communicator, so the traffic to the previous
and the next stage is serialized and an interleaved 1F1B step loses the overlap it had under
PyTorch 2.14. The option is patched only for the duration of the context. Older PyTorch builds
lack the option, and some lack torch.distributed.config entirely. On those builds the stages
keep PyTorch’s default communicators.
Parameters:
Whether stages constructed inside the context use per-edge communicators.
Returns: AbstractContextManager
A context manager that patches the option, or a no-op context when enabled is False or