IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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)

source

Bases: object

One stage of a decoder cut into pipeline stages.

Parameters:

boundary_types​

boundary_types: Tree[TensorType] | None = None

source

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

source

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

source

The stage’s position in the pipeline, from zero.

is_first​

property is_first: bool

source

Whether the stage takes the model’s inputs rather than a cut’s.

is_last​

property is_last: bool

source

Whether the stage returns the model’s outputs rather than a cut’s.

layers​

layers: range

source

The decoder layers the stage builds.

num_stages​

num_stages: int

source

The number of stages in the pipeline.

partition​

partition: tuple[int, ...] | None = None

source

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​

property stage_ranges: list[range]

source

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

source

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.