For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python class
PipelineStage
PipelineStage
class max.pipelines.lib.pipeline_parallel.PipelineStage(index, num_stages, layers, boundary_types=None, trace_only=False, partition=None, draft_slots=0)
Bases: object
One stage of a decoder cut into pipeline stages.
-
Parameters:
boundary_types
boundary_types: Tree[TensorType] | None = None
The types of what the previous stage’s decoder returns, in the tree it
returns them, or None on the first stage.
draft_slots
draft_slots: int = 0
Cache slots the last stage holds past its layers for the layers it drafts with inside the model’s own caches, such as GLM-5.3-Flash’s MTP layer. The stages share one KV pool, so every stage holds them, whether or not it builds with the speculative config.
index
index: int
The stage’s position in the pipeline, from zero.
is_first
property is_first: bool
Whether the stage takes the model’s inputs rather than a cut’s.
is_last
property is_last: bool
Whether the stage returns the model’s outputs rather than a cut’s.
layers
layers: range
The decoder layers the stage builds.
num_stages
num_stages: int
The number of stages in the pipeline.
partition
Every stage’s layer count, in stage order, or None when only this
stage’s layers are known. A decoder whose stages share one KV pool sizes
each stage’s caches from the whole partition, so that every stage holds
the same slots per leaf.
stage_ranges
The layers of every stage, in stage order.
-
Raises:
-
ValueError – If the partition is unknown, or disagrees with this stage’s layers.
trace_only
trace_only: bool = False
Whether the build ends with
StageTraced once the stage knows
what it hands the next, before anything compiles. An exporter traces the
stages before the one it builds, to learn that stage’s boundary types.