vllm.v1.worker.gpu.spec_decode.adaptive_verification
¶
Adaptive verification for DSpark speculative decoding.
Classes:
-
AdaptiveVerificationManager– -
AdmittedDraftCounts–Per-request admitted draft counts, in flight to the host.
Functions:
-
assign_draft_token_budget–Admit the globally best
draft_budgetdraft slots, in place. -
build_cost_tables_from_curves–Build cost tables: graph-padded below the capture limit, smooth above.
-
resolve_adaptive_cudagraph_mode–Select a separate decode route for variable-length verification.
AdaptiveVerificationManager
¶
Methods:
-
batches_to_profile–Dummy-run kwargs whose step timings seed the cost tables.
-
compact_batch–Compact the CPU batch to the chosen draft budget.
-
get_num_tokens–Token count once the draft budget is trimmed to fit.
-
reallocate_drafts–The admitted draft counts are None unless copy_admitted_drafts_to_host
-
record_confidences–Publish this step's raw confidences for the ranking kernel and start
-
warmup_budget_kernel–JIT the draft-budget kernel so the first binding step doesn't compile.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
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 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | |
batches_to_profile(capture_sizes)
¶
Dummy-run kwargs whose step timings seed the cost tables.
Run these inside StepTimingCollector.collect(), then hand the block's timings to set_initial_cost_curves.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
compact_batch(num_draft_tokens_per_req, num_scheduled_tokens, cu_num_logits_np)
¶
Compact the CPU batch to the chosen draft budget.
Returns the compacted per-request token counts and the CPU cu_num_logits_np. If the draft budget is 0, we can know cu_num_logits_np exactly, otherwise its unchanged/an-upper-bound.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
get_num_tokens(num_tokens_per_req, draft_tokens)
¶
Token count once the draft budget is trimmed to fit.
Stashes the chosen budget in _batch_budget for the compaction and
reallocation that follow in the same step.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
reallocate_drafts(req_ids, idx_mapping)
¶
The admitted draft counts are None unless copy_admitted_drafts_to_host is set and the budget binds; otherwise the host counts are already exact.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
record_confidences(confidence_probs, input_batch)
¶
Publish this step's raw confidences for the ranking kernel and start copying them to the CPU, where a later step's budget reads them.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
warmup_budget_kernel()
¶
JIT the draft-budget kernel so the first binding step doesn't compile.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
AdmittedDraftCounts
¶
Per-request admitted draft counts, in flight to the host.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
assign_draft_token_budget(confidence_probs, idx_mapping, capacities, draft_budget, survival)
¶
Admit the globally best draft_budget draft slots, in place.
Every (request, step) slot is scored by its survival probability, the running product of that request's per-position confidences, and the highest scores win. Survival only decreases along a request, so the winners are always a prefix of each request's steps and only per-request counts are needed.
capacities enters holding each request's scheduled draft count (which bounds its
eligible slots) and leaves holding the admitted count. The caller only calls this
when draft_budget < capacities.sum(), so every winner is a real draft slot.
survival is int32 scratch with room for num_reqs * num_steps slots.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
build_cost_tables_from_curves(draft_curve, verify_curve, max_num_reqs, max_batch_tokens, cudagraph_limit=0)
¶
Build cost tables: graph-padded below the capture limit, smooth above.
Parameters:
-
(draft_curve¶list[tuple[int, float]]) –(size, cost) samples for the draft model.
-
(verify_curve¶list[tuple[int, float]]) –(size, cost) samples for the verify model.
-
(max_num_reqs¶int) –Largest request count to build a table for.
-
(max_batch_tokens¶int) –Largest token count to build a table for.
-
(cudagraph_limit¶int, default:0) –Largest cudagraph-captured size. At or below it, execution pads up to the next captured size, so cost is a step function. Above it there is no padding, so cost is continuous.
Source code in vllm/v1/worker/gpu/spec_decode/adaptive_verification.py
resolve_adaptive_cudagraph_mode(mode, *, piecewise_capture_available)
¶
Select a separate decode route for variable-length verification.