vllm.v1.worker.gpu.spec_decode.speculator_config
¶
Per-speculator configuration.
Each speculator has a SpeculatorConfig subclass, in a config.py next to its
V2 model runner implementation, which sets up SpeculativeConfig for it,
describes its behavior to code outside the speculator (queried through
SpeculativeConfig.speculator_config rather than by method name), and names
its implementation class. Config modules must not import the speculators, as
they're used in every process. Custom speculators are registered with
register_speculative_method.
Classes:
-
DraftModelSpeculatorConfig–A speculator whose draft model is loaded from the
modelcheckpoint. -
SpeculatorConfig–Configuration of a kind of speculator.
Functions:
-
get_custom_speculator_config_class–The config of a registered custom speculative method, or None.
-
get_method_config_class–Select method and target-family configuration before loading the draft.
-
get_speculator_config_class–The config class for a set-up spec config.
-
register_speculative_method–Register a custom speculative method, used with
method=name. -
registered_speculative_methods–The names of the registered custom speculative methods.
DraftModelSpeculatorConfig
¶
Bases: SpeculatorConfig
A speculator whose draft model is loaded from the model checkpoint.
Methods:
-
default_draft_decode_context_parallel_size–The draft's DCP when
draft_decode_context_parallel_sizeis unset. -
default_model–Overridden by drafts whose checkpoint the target implies (e.g.
-
draft_hf_overrides–Build the picklable transform applied before draft architecture parsing.
-
resolve_num_speculative_tokens–Default or validate
num_speculative_tokensfrom the checkpoint. -
transformers_backend_hf_overrides–HF config updates for a draft built by the Transformers modeling
default_draft_decode_context_parallel_size(spec)
classmethod
¶
The draft's DCP when draft_decode_context_parallel_size is unset.
default_model(spec)
classmethod
¶
Overridden by drafts whose checkpoint the target implies (e.g.
MTP), which may then also give num_speculative_tokens.
draft_hf_overrides(spec)
classmethod
¶
Build the picklable transform applied before draft architecture parsing.
resolve_num_speculative_tokens(spec)
classmethod
¶
Default or validate num_speculative_tokens from the checkpoint.
transformers_backend_hf_overrides(spec)
classmethod
¶
HF config updates for a draft built by the Transformers modeling backend, which replace the usual draft config rewrites, or None.
SpeculatorConfig
¶
Configuration of a kind of speculator.
The defaults describe a speculator without a draft checkpoint or special
requirements. A custom speculator can subclass this, or the config of the
built-in speculator it behaves like (overriding speculator_class), whose
setup and behavior it then inherits.
Methods:
-
apply_options–Apply method-specific options to the draft model config.
-
configure–Set up the draft model config (and related options).
-
default_model–The
modelto use when it isn't given. -
hash_factors–Extra factors of
SpeculativeConfig.compile_factors. -
matches–Whether the draft checkpoint is for this speculator, other than by
-
max_num_draft_seqs–The most requests the draft forward pass fits in
-
pcp_unsupported_reason–Why prefill context parallelism can't be used, or None.
-
specialize–This config, or a more specific subclass for the settings.
-
supports_draft_eplb–Whether the draft model's experts can be balanced by EPLB.
-
verify_draft_eplb–Validate draft EPLB with the target's, for a draft that supports it.
Attributes:
-
max_model_len(int | None) –The longest sequence the speculator can draft for, or None if
-
max_num_new_slots_for_drafting(int) –See
SpeculativeConfig.max_num_new_slots_for_drafting. -
num_hash_lookahead_tokens(int) –Next tokens the drafter's own KV at a position depends on, which
-
num_lookahead_tokens(int) –See
VllmConfig.num_lookahead_tokens. -
num_prefill_lookahead_tokens(int) –See
VllmConfig.num_prefill_lookahead_tokens. -
num_scheduled_spec_tokens(int) –Spec tokens scheduled per step:
num_speculative_tokens, or 0 with -
uses_aux_hidden_states(bool) –Whether the target must also output intermediate hidden states.
max_model_len
property
¶
The longest sequence the speculator can draft for, or None if unlimited. A smaller limit lowers overall max_model_len.
max_num_new_slots_for_drafting
property
¶
See SpeculativeConfig.max_num_new_slots_for_drafting.
num_hash_lookahead_tokens
property
¶
Next tokens the drafter's own KV at a position depends on, which prefix-cache block hashes must cover.
num_lookahead_tokens
property
¶
See VllmConfig.num_lookahead_tokens.
num_prefill_lookahead_tokens
property
¶
See VllmConfig.num_prefill_lookahead_tokens.
num_scheduled_spec_tokens
property
¶
Spec tokens scheduled per step: num_speculative_tokens, or 0 with
prefill_context_kv_only.
uses_aux_hidden_states
property
¶
Whether the target must also output intermediate hidden states.
apply_options(spec)
classmethod
¶
Apply method-specific options to the draft model config.
configure(spec)
classmethod
¶
Set up the draft model config (and related options).
default_model(spec)
classmethod
¶
The model to use when it isn't given.
hash_factors()
¶
Extra factors of SpeculativeConfig.compile_factors.
matches(spec)
classmethod
¶
Whether the draft checkpoint is for this speculator, other than by its model's declaration (e.g. by name). Used to detect the method.
max_num_draft_seqs(max_num_batched_tokens)
¶
The most requests the draft forward pass fits in max_num_batched_tokens, which limits max_num_active_seqs, or None if unlimited (e.g. when it's sized by the target's scheduled tokens).
pcp_unsupported_reason(parallel_config)
¶
Why prefill context parallelism can't be used, or None.
specialize(spec)
classmethod
¶
This config, or a more specific subclass for the settings.
supports_draft_eplb(draft_model_config)
classmethod
¶
Whether the draft model's experts can be balanced by EPLB.
verify_draft_eplb(spec)
classmethod
¶
Validate draft EPLB with the target's, for a draft that supports it. Returns the draft's routed expert count if its model config's isn't.
_get_draft_declared_config_class(spec_config)
¶
The config declared by the draft model (see SpeculativeDraftModel).
_resolve_checkpoint_config_class(spec_config, configured_cls)
¶
The built-in config for the draft checkpoint: detected if no method is configured, else the configured one, checked against the speculator the draft model declares (if any).
get_custom_speculator_config_class(method)
¶
The config of a registered custom speculative method, or None.
get_method_config_class(spec_config)
¶
Select method and target-family configuration before loading the draft.
get_speculator_config_class(spec_config)
¶
The config class for a set-up spec config.
register_speculative_method(name, config_cls)
¶
Register a custom speculative method, used with method=name.
config_cls is its SpeculatorConfig subclass, or its qualified name to
import it lazily. Register it from a vLLM general plugin, so that it's
registered in every process. This is an experimental interface that may
change between releases.
registered_speculative_methods()
¶
The names of the registered custom speculative methods.