Python module
sampling
rejection_sampler()
max.pipelines.lib.sampling.sampling.rejection_sampler(device, *, seed=0)
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.
rejection_sampler_with_residuals()
max.pipelines.lib.sampling.sampling.rejection_sampler_with_residuals(device, *, seed=0, debug=False)
Builds a rejection sampler with residual sampling for speculative decoding.
Computes acceptance ratios for draft tokens, finds first rejection, samples from residual distribution (target - draft), and generates bonus tokens.
token_sampler()
max.pipelines.lib.sampling.sampling.token_sampler(sampling_config, device, return_logits=False)
Builds a sampling graph that samples tokens from logits.
-
Parameters:
-
Returns:
-
A graph that takes logits (and optional penalty inputs) and outputs tokens.
-
Return type:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!