vllm.config.speculative ¶
MTP_MODEL_TYPES module-attribute
¶
MTP_MODEL_TYPES = (
"deepseek_mtp",
"mimo_mtp",
"glm4_moe_mtp",
"ernie_mtp",
"qwen3_next_mtp",
"longcat_flash_mtp",
)
SpeculativeMethod module-attribute
¶
SpeculativeMethod = Literal[
"ngram",
"eagle",
"eagle3",
"medusa",
"mlp_speculator",
"draft_model",
"deepseek_mtp",
"ernie_mtp",
"qwen3_next_mtp",
"mimo_mtp",
"longcat_flash_mtp",
"mtp",
]
SpeculativeConfig ¶
Configuration for speculative decoding.
Source code in vllm/config/speculative.py
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 151 152 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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
|
code_revision 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.
disable_by_batch_size class-attribute
instance-attribute
¶
Disable speculative decoding for new incoming requests when the number of enqueued requests is larger than this value, if provided.
disable_log_stats class-attribute
instance-attribute
¶
disable_log_stats: SkipValidation[bool] = None
Whether to disable the periodic printing of stage times in speculative decoding.
disable_logprobs class-attribute
instance-attribute
¶
disable_logprobs: bool = True
If set to True, token log probabilities are not returned during speculative decoding. If set to False, token log probabilities are returned according to the log probability settings in SamplingParams.
disable_padded_drafter_batch class-attribute
instance-attribute
¶
disable_padded_drafter_batch: bool = False
Disable input padding for speculative decoding. If set to True, speculative input batches can contain sequences of different lengths, which may only be supported by certain attention backends. This currently only affects the EAGLE method of speculation.
draft_model_config class-attribute
instance-attribute
¶
draft_model_config: SkipValidation[ModelConfig] = None
The configuration of the draft model initialized internal.
draft_parallel_config class-attribute
instance-attribute
¶
draft_parallel_config: SkipValidation[ParallelConfig] = None
The parallel configuration for the draft model initialized internal.
draft_tensor_parallel_size 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.
enable_chunked_prefill class-attribute
instance-attribute
¶
enable_chunked_prefill: SkipValidation[bool] = None
Whether vLLM is configured to use chunked prefill or not. Used for raising an error since it's not yet compatible with speculative decode.
max_model_len class-attribute
instance-attribute
¶
The maximum model length of the draft model. Used when testing the ability to skip speculation for some sequences.
method class-attribute
instance-attribute
¶
method: Optional[SpeculativeMethod] = None
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.
model class-attribute
instance-attribute
¶
The name of the draft model, eagle head, or additional weights, if provided.
num_lookahead_slots property
¶
num_lookahead_slots: int
The number of additional slots the scheduler should allocate per step, in addition to the slots allocated for each known token.
This is equal to the number of speculative tokens, as each speculative token must be scored.
num_speculative_tokens class-attribute
instance-attribute
¶
num_speculative_tokens: SkipValidation[int] = None
The number of speculative tokens, if provided. It will default to the number in the draft model config if present, otherwise, it is required.
prompt_lookup_max class-attribute
instance-attribute
¶
Maximum size of ngram token window when using Ngram proposer, required when method is set to ngram.
prompt_lookup_min class-attribute
instance-attribute
¶
Minimum size of ngram token window when using Ngram proposer, if provided. Defaults to 1.
quantization class-attribute
instance-attribute
¶
quantization: Optional[QuantizationMethods] = None
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.
revision 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.
speculative_token_tree class-attribute
instance-attribute
¶
Specifies the tree structure for speculative token generation.
target_model_config class-attribute
instance-attribute
¶
target_model_config: SkipValidation[ModelConfig] = None
The configuration of the target model.
target_parallel_config class-attribute
instance-attribute
¶
target_parallel_config: SkipValidation[ParallelConfig] = (
None
)
The parallel configuration for the target model.
__post_init__ ¶
Source code in vllm/config/speculative.py
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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
_maybe_override_draft_max_model_len staticmethod
¶
_maybe_override_draft_max_model_len(
speculative_max_model_len: Optional[int],
draft_max_model_len: int,
target_max_model_len: int,
) -> int
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.
Source code in vllm/config/speculative.py
_verify_and_get_draft_tp staticmethod
¶
_verify_and_get_draft_tp(
target_parallel_config: ParallelConfig,
speculative_draft_tensor_parallel_size: Optional[int],
draft_hf_config: PretrainedConfig,
) -> int
Verifies and adjusts the tensor parallel size for a draft model specified using speculative_draft_tensor_parallel_size.
Source code in vllm/config/speculative.py
_verify_args ¶
_verify_args() -> Self
Source code in vllm/config/speculative.py
compute_hash ¶
compute_hash() -> str
WARNING: Whenever a new field is added to this config, ensure that it is included in the factors list if it affects the computation graph.
Provide a hash that uniquely identifies all the configs that affect the structure of the computation graph from input ids/embeddings to the final hidden states, excluding anything before input ids/embeddings and after the final hidden states.
Source code in vllm/config/speculative.py
create_draft_parallel_config staticmethod
¶
create_draft_parallel_config(
target_parallel_config: ParallelConfig,
speculative_draft_tensor_parallel_size: int,
) -> ParallelConfig
Create a parallel config for use by the draft worker.
This is mostly a copy of the target parallel config, except the tp_size.