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.
Parts only needed by the V1 model runner are marked "V1 model runner only", and will be removed with it.
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–The config class for
spec_config.method, regardless of 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:
-
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
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
resolve_num_speculative_tokens(spec)
classmethod
¶
Default or validate num_speculative_tokens from the checkpoint.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
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.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
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.compute_hash. -
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.
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_lookahead_tokens(int) –See
VllmConfig.num_lookahead_tokens. -
num_prefill_lookahead_tokens(int) –See
VllmConfig.num_prefill_lookahead_tokens. -
uses_aux_hidden_states(bool) –Whether the target must also output intermediate hidden states.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
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_lookahead_tokens
property
¶
See VllmConfig.num_lookahead_tokens.
num_prefill_lookahead_tokens
property
¶
See VllmConfig.num_prefill_lookahead_tokens.
uses_aux_hidden_states
property
¶
Whether the target must also output intermediate hidden states.
apply_options(spec)
classmethod
¶
configure(spec)
classmethod
¶
Set up the draft model config (and related options).
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
default_model(spec)
classmethod
¶
hash_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).
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
pcp_unsupported_reason(parallel_config)
¶
Why prefill context parallelism can't be used, or None.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
specialize(spec)
classmethod
¶
This config, or a more specific subclass for the settings.
_get_draft_declared_config_class(spec_config)
¶
The config declared by the draft model (see SpeculativeDraftModel).
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
_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).
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
get_custom_speculator_config_class(method)
¶
The config of a registered custom speculative method, or None.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
get_method_config_class(spec_config)
¶
The config class for spec_config.method, regardless of the draft
checkpoint (for setting up spec_config).
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
get_speculator_config_class(spec_config)
¶
The config class for a set-up spec config.
Source code in vllm/v1/worker/gpu/spec_decode/speculator_config.py
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. Custom methods require the V2 model runner.
This is an experimental interface that may change between releases.