IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Python function

rejection_sampler

rejection_sampler()โ€‹

max.pipelines.sampling.rejection_sampler(device)

source

Builds a graph that implements speculative decoding rejection sampling.

Accepts or rejects draft tokens using target vs draft probabilities and resamples from the target distribution when rejected.

The sampling RNG seed is bound as a graph input โ€” callers refresh it per execution so RNG varies across calls.

Parameters:

device (DeviceRef) โ€“ Device for the graph.

Returns:

A graph that takes draft tokens, draft logits, target logits, and a per-execute seed and outputs accepted tokens and metadata.

Return type:

Graph