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

Pipeline

Pipeline

class max.pipelines.modeling.types.Pipeline

source

Bases: Generic[PipelineInputsType, PipelineOutputType], ABC

Defines the interface for pipeline operations.

This generic abstract class defines the interface for pipeline operations that transform inputs of type PipelineInputsType into outputs of type PipelineOutputsDict[PipelineOutputType]. All concrete pipeline implementations must inherit from this class and implement the execute() method.

from max.pipelines.modeling.types.pipeline import (
    Pipeline,
    PipelineInputs,
    PipelineOutput,
)
from max.pipelines.request import RequestID

class MyInputs(PipelineInputs):
    pass

class MyOutput(PipelineOutput):
    @property
    def is_done(self) -> bool:
        return True

class MyPipeline(Pipeline[MyInputs, MyOutput]):
    @property
    def max_batch_size(self) -> int:
        return 1

    def execute(self, inputs: MyInputs) -> dict[RequestID, MyOutput]:
        # Implementation here
        return {}

    def release(self, request_id: RequestID) -> None:
        pass

execute()

abstract execute(inputs)

source

Executes the pipeline operation with the given inputs.

This method must be implemented by all concrete pipeline classes. It takes inputs of the specified type and returns outputs according to the pipeline’s processing logic.

Parameters:

inputs (PipelineInputsType) – The input data for the pipeline operation.

Returns:

A dictionary mapping RequestID to pipeline output objects.

Raises:

NotImplementedError – If not implemented by a concrete subclass.

Return type:

dict[RequestID, PipelineOutputType]

max_batch_size

abstract property max_batch_size: int

source

Returns the maximum number of requests processed in a single batch.

release()

abstract release(request_id)

source

Releases any resources or state associated with a specific request.

This method should be implemented by concrete pipeline classes to perform cleanup or resource deallocation for the given request ID. It is typically called when a request has completed processing and its associated resources (such as memory, cache, or temporary files) are no longer needed.

Parameters:

request_id (RequestID) – The unique identifier of the request to release resources for.

Raises:

NotImplementedError – If not implemented by a concrete subclass.

Return type:

None