vllm.model_executor.warmup.kernel_warmup
¶
Warmup kernels used during model execution. This is useful specifically for JIT'ed kernels as we don't want JIT'ing to happen during model execution.
Functions:
-
flashinfer_autotune–Autotune FlashInfer operations.
_aiter_gemm_m_buckets(max_m)
¶
One token count per AITER tuned-GEMM bucket up to max_m.
AITER pads M to 1, 2, 4 or 8 below 16, then to multiples of 16 / 32 / 64 / 128 up to 256 / 1024 / 4096 / beyond, and builds each bucket's kernel on first use.
Source code in vllm/model_executor/warmup/kernel_warmup.py
_all_ranks_have_matching_cache(path, group)
¶
True iff every rank in group has its own, mutually consistent file.
Source code in vllm/model_executor/warmup/kernel_warmup.py
_autotune_cache_fingerprint(path)
¶
Identify a saved autotune file by its FlashInfer metadata and size.
Source code in vllm/model_executor/warmup/kernel_warmup.py
_flashinfer_deferred_moe_token_counts(runner)
¶
Return bounded token counts that exercise deferred MoE finalization.
Source code in vllm/model_executor/warmup/kernel_warmup.py
_load_shared_autotune_cache(cache_path, tuner, tune_group)
¶
Load the per-rank autotune cache into the tuner, group-wide.
Returns True only when every rank of the tune group had a matching file and loaded it: the dummy-run sweep contains collectives, so skipping it is safe only if the decision is unanimous.
Source code in vllm/model_executor/warmup/kernel_warmup.py
flashinfer_autotune(runner, *, skip_attn=False)
¶
Autotune FlashInfer operations. FlashInfer have many implementations for the same operation, autotuning runs benchmarks for each implementation and stores the results. The results are cached transparently and future calls to FlashInfer will use the best implementation. Without autotuning, FlashInfer will rely on heuristics, which may be significantly slower.
Parameters:
-
(runner¶GPUModelRunner) –The model runner to tune.
-
(skip_attn¶bool, default:False) –Additionally skip attention in the tuning dummy runs.
With PP > 1, stages run different layers and may profile different ops, so each stage's TP group tunes separately with its own cache file; otherwise the world group tunes together. Per-tactic timings are averaged over the tuning group so all its ranks select the same tactic.
Legacy results are persisted per rank: FlashInfer keys MoE entries by tp/ep rank
(MoERunner.get_cache_key_extras), so one rank's file only hits on that
rank. A rank with a cache hit skips the per-tactic reduce the others block
in, so ranks keep loaded configs only if every rank in the tuning group
has a matching file and successfully loads it.
Source code in vllm/model_executor/warmup/kernel_warmup.py
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 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |