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
AcceptanceSampler
AcceptanceSampler
class max.nn.sampling.AcceptanceSampler(synthetic_acceptance_rate=None, num_draft_steps=1, use_stochastic=False, draft_proposal='argmax', vocab_size=None, relaxed_topk=None, relaxed_delta=None)
Bases: object
Dispatches between greedy, synthetic, and stochastic acceptance.
synthetic_acceptance_rateset → synthetic (benchmarking) mode. The per-position acceptance probability is calibrated so that the mean joint acceptance acrossnum_draft_stepsmatches the configured rate, viacompute_synthetic_acceptance_base_rate().use_stochastic=True→ stochastic rejection sampling. The caller must then pass per-row sampling params (temperature,top_k,max_k,top_p,min_top_p) at call time.- Otherwise → greedy (accept iff draft token == target argmax).
Synthetic mode takes priority over stochastic when both are configured, but still samples with the stochastic params.
relaxed_topk / relaxed_delta require draft_proposal="argmax";
the relaxed rule assumes the drafted token is the draft’s own argmax, so
it does not carry over to a sampled proposal.
-
Parameters:
acceptance_rule
property acceptance_rule: Literal['synthetic', 'stochastic', 'greedy']
The rule __call__() dispatches to, in its precedence order.
This is the only place the acceptance rule in effect is decided:
SpeculativeConfig.rejection_sampling_strategy is read by nothing.