Skip to content

vllm.config.speculative

Classes:

SpeculativeConfig

Configuration for speculative decoding.

Methods:

Attributes:

attention_backend = None class-attribute instance-attribute

Attention backend to use for the draft model. When None, the backend is automatically selected. Useful when the drafter requires a different attention backend (e.g. DFlash needs a backend that supports non-causal attention).

code_revision = None class-attribute instance-attribute

The specific revision to use for the draft model code on Hugging Face Hub. It can be a branch name, a tag name, or a commit id. If unspecified, will use the default version.

custom_method = field(default=None, init=False) class-attribute instance-attribute

The configured custom speculative method, if any (see method).

draft_decode_context_parallel_size = Field(default=None, ge=1) class-attribute instance-attribute

The degree of decode context parallelism for the draft model. Can only be 1 or the same as the target model's decode context parallel size. Defaults to the target's, except for DFlash/DSpark drafts, which default to 1 unless they are full-attention MLA.

draft_enable_eplb = True class-attribute instance-attribute

Whether to enable EPLB for the draft model when it is enabled for the target model.

draft_lm_head_quantization = None class-attribute instance-attribute

Quantize the drafter's copy of a target lm_head it shares (EAGLE, MTP and DeepSeek-V4/V4.1 DSpark), or, with "fp8", the Muse Spark DSpark drafter's own lm_head and Markov head on ROCm. "fp8" uses per-row weight and per-token activation scales on the platform's FP8 linear kernel; "nvfp4" is weight-only on the platform's W4A16 kernel. The target verifies with its own head, so only the acceptance length can change.

draft_load_config = None class-attribute instance-attribute

Load config for the draft model. If not specified, will use the load config from the target model.

draft_model_config = None class-attribute instance-attribute

The configuration of the draft model initialized internal.

draft_parallel_config = None class-attribute instance-attribute

The parallel configuration for the draft model initialized internal.

draft_sample_method = 'greedy' class-attribute instance-attribute

How the draft model samples tokens. 'greedy' always picks the argmax token, and the draft probabilities are treated as one-hot during rejection sampling. 'probabilistic' samples stochastically from the draft distribution and uses the full draft logits for the probability ratio test during rejection sampling. This comes at the cost of additional GPU memory usage.

draft_tensor_parallel_size = Field(default=None, ge=1) class-attribute instance-attribute

The degree of the tensor parallelism for the draft model. Can only be 1 or the same as the target model's tensor parallel size.

dspark_draft_topk = Field(default=None, ge=1) class-attribute instance-attribute

For Qwen3 DSpark drafting, evaluate the Markov projection only for the top-k base-logit candidates. Requires draft tensor parallel size 1.

enable_adaptive_verification = False class-attribute instance-attribute

Whether to adaptively size the draft-verification budget from per-request confidence. Currently only supported for method="dspark".

enforce_eager = None class-attribute instance-attribute

Override the default enforce_eager from model_config

fly_entropy_threshold = Field(default=0.3, ge=0) class-attribute instance-attribute

Target top-k entropy lower bound for FLy loose acceptance.

fly_entropy_top_k = Field(default=3, ge=1) class-attribute instance-attribute

Number of largest target probabilities used by FLy's entropy gate.

fly_window_size = Field(default=None, ge=1) class-attribute instance-attribute

Number of subsequent native acceptance decisions checked by FLy. If unset, defaults to min(6, num_speculative_tokens - 1).

index_share_for_mtp_iteration = None class-attribute instance-attribute

Override whether MTP iterations reuse the first step's sparse indices. If None, use the value from the draft model's Hugging Face config.

kv_cache_dtype = None class-attribute instance-attribute

KV cache dtype for the draft model. When None, the draft inherits the target model's --kv-cache-dtype. Custom dtypes registered by platform backends are accepted.

max_model_len = Field(default=None, ge=1) class-attribute instance-attribute

The maximum model length of the draft model. Used when testing the ability to skip speculation for some sequences.

max_num_new_slots_for_drafting property

Return the maximum additional drafting slots per request.

The scheduler budget already includes one query slot per decoding request. Only the autoregressive draft-model input needs one more: it retains one unsliced token. DFlash and DSpark draft in a separate query pass rather than adding rows to the target batch.

method = None class-attribute instance-attribute

The name of the speculative method to use. If users provide and set the model param, the speculative method type will be detected automatically if possible, if model param is not provided, the method name must be provided.

If using ngram method, the related configuration prompt_lookup_max and prompt_lookup_min should be considered.

A configured method is never changed based on the draft checkpoint, but it is checked against it where the checkpoint can be recognized (e.g. mtp requires an MTP draft, and draft_model rejects one).

Besides the built-in methods, this can be a custom method registered with vllm.v1.worker.gpu.spec_decode.speculator_config.register_speculative_method (e.g. by a vLLM plugin). It is then moved to custom_method, and this is set to the built-in method that its config is based on (None if it isn't based on one).

model = None class-attribute instance-attribute

The name of the draft model, eagle head, or additional weights, if provided.

moe_backend = None class-attribute instance-attribute

MoE backend to use for the draft model. When None, the draft model inherits the target model's --moe-backend setting. Useful when the drafter and generator require different MoE kernels (e.g. quantized generator with unquantized drafter).

num_speculative_tokens = Field(default=None, gt=0) class-attribute instance-attribute

The number of speculative tokens, if provided. It will default to the number in the draft model config if present, otherwise, it is required.

num_speculative_tokens_per_batch_size = None class-attribute instance-attribute

Batch-size schedule used to dynamically choose speculative-token count.

Each entry is (range_start, range_end, num_speculative_tokens) with an inclusive batch-size range.

parallel_drafting = None class-attribute instance-attribute

Deprecated and has no effect. DFlash and DSpark always draft in parallel, and no other method supports it.

prefill_context_kv_only = False class-attribute instance-attribute

Set on a P/D prefill instance (Model Runner V2, DFlash-based speculators) to only store the drafter's context K/V, which the decode instance reads: no drafts, no lookahead KV slots, and, for draft models that support it, the draft weights only drafting reads are freed. Requests that decode there run without speculation. Keep the rest of the speculative config as on the decode instance; adaptive verification and dynamic speculative decoding are turned off.

prompt_lookup_max = Field(default=None, ge=1) class-attribute instance-attribute

Maximum size of ngram token window when using Ngram proposer. Defaults to prompt_lookup_min if set, otherwise 5.

prompt_lookup_min = Field(default=None, ge=1) class-attribute instance-attribute

Minimum size of ngram token window when using Ngram proposer. Defaults to prompt_lookup_max if set, otherwise 5.

quantization = None class-attribute instance-attribute

Quantization method that was used to quantize the draft model weights. If None, we assume the model weights are not quantized. Note that it only takes effect when using the draft model-based speculative method.

rejection_sample_method = 'standard' class-attribute instance-attribute

The rejection sampling method to use. 'standard' uses probabilistic rejection sampling (with or without cached draft logits, controlled by draft_sample_method). 'synthetic' accepts draft tokens with a decaying probability calibrated to synthetic_acceptance_rate. 'block' uses block verification (Sun et al.), which jointly verifies the draft tokens as a block instead of one at a time. 'fly' applies FLy's lossy, entropy-gated deferred window to the native per-token acceptance decisions.

resolved_draft_num_redundant_experts = field(default=None, init=False, repr=False) class-attribute instance-attribute

Resolved redundant expert count used for the draft's EPLB config.

revision = None class-attribute instance-attribute

The specific model version to use for the draft model. It can be a branch name, a tag name, or a commit id. If unspecified, will use the default version.

speculator_config property

The configured speculator's config. Derived on each access so that it follows changes to the fields it depends.

speculator_options = None class-attribute instance-attribute

Options for a custom speculator, interpreted by its SpeculatorConfig, which must list "speculator_options" in its supported_options.

subfolder = None class-attribute instance-attribute

The subfolder of the target model that holds the draft checkpoint, e.g. "eagle3" for a target that ships its EAGLE-3 draft in eagle3/. Only this subfolder is downloaded from the Hugging Face Hub. Cannot be combined with model. If neither is given, a draft method that needs a checkpoint looks for one in the target's subfolder named after the method.

suffix_decoding_corpus_tokens = 1 << 20 class-attribute instance-attribute

Token capacity of the GPU corpus of finished responses used for cross-request matching. Oldest responses are overwritten first. Set 0 (or suffix_decoding_max_cached_requests to 0) to match only within each request's own prompt and output.

suffix_decoding_max_cached_requests = 10000 class-attribute instance-attribute

Set to 0 to disable the cross-request corpus of finished responses (equivalent to suffix_decoding_corpus_tokens=0), so that each request matches only within its own prompt and output.

suffix_decoding_max_spec_factor = 1.0 class-attribute instance-attribute

Deprecated and has no effect: the GPU suffix speculator always drafts num_speculative_tokens tokens.

suffix_decoding_max_tree_depth = 24 class-attribute instance-attribute

The maximum suffix match length for suffix decoding.

suffix_decoding_min_token_prob = 0.1 class-attribute instance-attribute

Deprecated and has no effect: the GPU suffix speculator always drafts num_speculative_tokens tokens.

synthetic_acceptance_length = None class-attribute instance-attribute

Target mean acceptance length for synthetic rejection sampling, in [1, num_speculative_tokens + 1]. Resolved internally to synthetic_acceptance_rates. Only valid when rejection_sample_method is 'synthetic'. Mutually exclusive with synthetic_acceptance_rates.

synthetic_acceptance_rates = None class-attribute instance-attribute

Per-position unconditional acceptance rates for synthetic rejection sampling. Position i's entry is the marginal probability that the first i+1 draft tokens are all accepted; the list must have length num_speculative_tokens, each entry in [0, 1], and be monotonically non-increasing. Only valid when rejection_sample_method is 'synthetic'. Mutually exclusive with synthetic_acceptance_length.

target_model_config = None class-attribute instance-attribute

The configuration of the target model.

target_parallel_config = None class-attribute instance-attribute

The parallel configuration for the target model.

tensor_parallel_size = None class-attribute instance-attribute

Users should pass "draft_tensor_parallel_size". This parameter's purpose is to warn users when they mistakenly provide the wrong argument.

use_local_argmax_reduction = False class-attribute instance-attribute

Use vocab-parallel local argmax instead of all-gathering full logits for draft token generation. Reduces communication from O(vocab_size) to O(2 * tp_size) per token. Only applies to greedy draft selection in non-tree speculation.

uses_aux_hidden_states property

See SpeculatorConfig.uses_aux_hidden_states.

uses_separate_workspace_lane property

See SpeculatorConfig.uses_separate_workspace_lane.

uses_target_hidden_states property

See SpeculatorConfig.uses_target_hidden_states.

xpress_topc = Field(default=None, ge=0) class-attribute instance-attribute

For XPress drafting, score each Jacobi pass only on the drafter's top-C base-logit candidates. 0 disables the narrowing and scores the full vocabulary. Takes precedence over xpress_topc in the draft checkpoint's config, which is used when this is unset.

_acceptance_length_to_rates(length, n) staticmethod

Mean acceptance length to unconditional per-position rates, using the minimum-variance schedule.

_apply_dict_then_arch_override(target_hf_overrides, hf_config, transformers_mtp_overrides=None) staticmethod

Apply dict rope overrides, then the draft arch rewrite.

Dict patches run first so nested keys (text_config.rope_parameters) apply before arch mapping may promote text_config. Nested wrappers are skipped on flat draft configs, where setting them would create a bare text_config dict that get_text_config() picks up instead.

_apply_draft_eplb_override(parallel_config)

Return the parallel config with the draft EPLB settings applied.

_maybe_override_draft_max_model_len(speculative_max_model_len, draft_max_model_len, target_max_model_len) staticmethod

Determine the max sequence len for the draft model. This is usually the draft_max_model_len, but may be the target_max_model_len if it is less than the draft_max_model_len, or may be speculative_max_model_len if it is specified.

This is necessary so that sequences do not exceed the capacity of the draft model or the target model.

speculative_max_model_len is mainly used for testing that sequences can skip speculation.

_maybe_override_draft_max_position_embeddings(draft_hf_config, target_max_model_len) staticmethod

Raise the max_position_embeddings of a draft that shares the target's positional space (see DraftModelSpeculatorConfig's shares_target_positions) up to the target's.

The proposer feeds the draft positions up to the target's max_model_len, while max_position_embeddings sizes the draft's rotary cos_sin_cache. A smaller checkpoint value (e.g. 2048 for yuhuili/EAGLE3-LLaMA3.1-Instruct-8B, or a DFlash or DSpark draft published against a shorter context than the target is served with) makes that cache gather go out of bounds.

Only drafts whose RoPE types are all in _CACHE_ONLY_ROPE_TYPES are resized.

Parameters:

  • draft_hf_config

    (PreTrainedConfig) –

    The draft model's HF config, mutated in place.

  • target_max_model_len

    (int) –

    The target model's max_model_len.

_resolve_synthetic_acceptance_rates(n, rates, length) staticmethod

Return per-position unconditional acceptance rates from exactly one of rates or length (validates range, length, and monotonicity).

_select_draft_hf_overrides(overrides) staticmethod

Keep rope-relevant keys, including those nested under VL wrappers.

_verify_and_get_draft_dcp(target_parallel_config, draft_dcp) staticmethod

Default the draft's DCP to the target's; an explicit value must be 1 or the target's.

_verify_and_get_draft_tp(target_parallel_config, speculative_draft_tensor_parallel_size) staticmethod

Verifies and adjusts the tensor parallel size for a draft model specified using speculative_draft_tensor_parallel_size.

_verify_draft_eplb_config()

Validate EPLB against draft experts and the topology they use.

apply_draft_eplb_overrides(vllm_config)

Apply draft-only EPLB settings without changing the target config.

apply_draft_overrides(vllm_config)

Overlay this config's draft overrides onto a target VllmConfig.

Only non-None model overrides are applied. Draft EPLB settings are applied separately, including the draft-specific redundant-expert count from eplb_config.

compile_factors()

WARNING: Whenever a new field is added to this config, add it to ignored_factors if it does not affect the computation graph.

compose_draft_hf_overrides(target_hf_overrides, transformers_mtp_overrides=None) staticmethod

Build the hf_overrides for the draft ModelConfig.

Callable overrides on the target are config-to-config transforms (e.g. test harnesses shrinking num_hidden_layers) and must also reach the draft config — otherwise a draft belonging to a large target is instantiated at full size even when the target is shrunk.

Dict overrides are mostly target-specific key patches, but rope-relevant keys (rope_parameters / rope_theta, including nested text_config) must reach the draft or a YaRN-style target override leaves the draft on native rope (#58080). max_position_embeddings stays target-only so the draft max-model-len clamp keeps holding (#63909).

The composed override must stay picklable: the draft ModelConfig is sent to spawned engine-core processes, so a local closure would fail with Can't get local object during pickling. Bind the target via functools.partial over a module-referenceable static method instead.

create_draft_parallel_config(target_parallel_config, speculative_draft_tensor_parallel_size, draft_model_config=None) staticmethod

Create a parallel config for use by the draft worker.

Use the draft TP size and disable inherited EP for known dense drafts. Without a draft model config, preserve the previous EP inheritance.

get_subfolder_checkpoint(subfolder, required=True)

The local path of the draft checkpoint in subfolder of the target model. If there is none, raises if required, else returns None.

num_mtp_modules()

Number of MTP modules the drafter selects among by draft step.

update_arch_()

EagleConfig and ExtractHiddenStatesConfig update architectures, so update all architectures-related fields in self.draft_model_config

_validate_qwen3_omni_dspark(target_model_config, draft_model_config, num_speculative_tokens)

Validate the standalone Qwen3-Omni DSpark checkpoint contract.