For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python module
max.pipelines.context
Concrete context classesβ
TextContext | A base class for model context, specifically for Text model variants. |
|---|---|
TextAndVisionContext | A base class for model context, specifically for Vision model variants. |
PixelContext | A model-ready context for image/video generation requests. |
Generation statusβ
GenerationStatus | Enum representing the status of a generation process in the MAX API. |
|---|
Constantsβ
FUTURE_TOKEN | int([x]) -> integer int(x, base=10) -> integer |
|---|
Context protocolsβ
BaseContext | Core interface for request lifecycle management across all of MAX, including serving, scheduling, and pipelines. |
|---|
Type variablesβ
BaseContextType | Type variable. |
|---|---|
TextGenerationContextType | Type variable. |
VLMContextType | Type variable. |
PixelGenerationContextType | Type variable. |
Samplingβ
SamplingParams | Request specific sampling parameters that are only known at run time. |
|---|---|
SamplingParamsInput | Input dataclass for creating SamplingParams instances. |
SamplingParamsGenerationConfigDefaults | Default sampling parameter values extracted from a model's GenerationConfig. |
Output typesβ
TextGenerationOutput | Represents the output of a text generation operation. |
|---|---|
GenerationOutput | Output container for image generation pipeline operations. |
TextGenerationResponseFormat | Represents the response format specification for a text generation request. |
LogProbabilities | Log probabilities for an individual output token. |
Token managementβ
TokenBuffer | A dynamically resizable container for managing token sequences. |
|---|---|
ImageMetadata | Metadata about an image in the prompt. |
Range | Represents a range with start and end indices. |
TokenSlice | ndarray(shape, dtype=float, buffer=None, offset=0, |
|---|
Grammar and structured outputβ
GrammarEnforcementState | Manages grammar enforcement state for constrained decoding. |
|---|---|
GrammarEnforcementSnapshot | Captured grammar-enforcement state for rollback. |
StructuredOutputRegionDelimiters | Token ID sequences that define structured output boundaries. |
Speculative decodingβ
SpecDecodingState | Per-request state for speculative decoding. |
|---|
EOS trackingβ
EOSTracker | Centralized EOS tracking: single-ID, sequence-ID, and stop-sequence checks. |
|---|
Logits processorsβ
LogitsProcessor | alias of Callable[[ProcessorInputs], None] |
|---|---|
BatchLogitsProcessor | alias of Callable[[BatchProcessorInputs], None] |
ProcessorInputs | Inputs passed to a logits processor callback. |
|---|---|
BatchProcessorInputs | Arguments for a batch logits processor. |
Exceptionsβ
InputError | Exception raised for input validation errors that should be shown to users. |
|---|---|
PromptTooLongError | Raised when a prompt exceeds the model's maximum input length. |
Validation functionsβ
validate_aspect_ratio_args | Validates that required aspect ratio arguments are present for vision input. |
|---|---|
validate_flux2_max_pixel_area | Rejects FLUX2 requests whose width * height exceeds the per-arch cap. |
validate_image_grid_thw_args | Validates that image_grid_thw is present when vision encoding is needed. |
validate_image_shape_5d | Validates that images have the expected 5-dimensional shape. |
validate_initial_prompt_has_image | Validates that initial prompts contain an image for vision models. |
validate_only_one_image | Validates that at most one image is provided in the context. |
validate_requires_vision_context | Validates that the context is a TextAndVisionContext. |
validate_vision_position_ids | Validates that vision_position_ids is present when vision encoding is needed. |
validate_wan_max_pixel_area | Rejects WAN requests whose width * height exceeds the per-arch cap. |
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!