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 module

max.pipelines.lib.generate

Fixed-batch generation, the lowest-level entry point to the pipeline API.

This runs a pipeline’s forward passes over a batch you choose, with nothing added on top of the pipeline API. The caller’s list of prompts is the batch: it is never split, re-packed, or chunked, and every GenerateIterator.step() runs exactly one pipeline.execute in the caller’s thread. That also makes it useful for testing, such as reproducing and localizing kernel and model accuracy bugs. Serving features (scheduling and in-flight batching, chunked prefill, prefix caching, LoRA, and structured output) are tested through max serve. Kernels are not batch-invariant, so for bit-exact comparisons between MAX runs, use batch size 1 or ignore_eos=True.

Classes​

BatchPipelineThe pipeline surface GenerateIterator drives.
GenerateIteratorSteps a fixed batch of prompts through a pipeline, one execute at a time.
GenerateResultThe result of generate().

Functions​

generateGenerates tokens for a fixed batch of prompts, run as one batch.