6c95a641e9
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com> Signed-off-by: Roberto L. Castro <38211239+LopezCastroRoberto@users.noreply.github.com> Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
"""Warm up FA4 CuTeDSL kernels."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from vllm.v1.attention.backends.mla.prefill import get_mla_prefill_backend
|
|
|
|
if TYPE_CHECKING:
|
|
from vllm.v1.worker.gpu_worker import Worker
|
|
|
|
|
|
def _warm_fa4_mla_prefill(worker: Worker) -> None:
|
|
runner = worker.model_runner
|
|
if runner.is_pooling_model:
|
|
return
|
|
|
|
vllm_config = runner.vllm_config
|
|
if not vllm_config.model_config.use_mla:
|
|
return
|
|
|
|
try:
|
|
backend_cls = get_mla_prefill_backend(vllm_config)
|
|
except ValueError:
|
|
# fall back to top-k MQA prefill path.
|
|
return
|
|
if backend_cls.get_name() != "FLASH_ATTN":
|
|
return
|
|
|
|
from vllm.v1.attention.backends.mla.prefill import flash_attn
|
|
|
|
flash_attn.FA4_MLA_PREFILL_KERNEL.warmup(vllm_config)
|
|
|
|
|
|
def _warm_inkling_fa4_rel_attention(worker: Worker) -> None:
|
|
from vllm.models.inkling.configs import InklingMMConfig, InklingModelConfig
|
|
from vllm.models.inkling.nvidia.ops.fa4_rel_attention import (
|
|
INKLING_FA4_REL_ATTENTION_KERNEL,
|
|
)
|
|
|
|
vllm_config = worker.vllm_config
|
|
hf_config = vllm_config.model_config.hf_config
|
|
if not isinstance(hf_config, (InklingMMConfig, InklingModelConfig)):
|
|
return
|
|
|
|
INKLING_FA4_REL_ATTENTION_KERNEL.warmup(vllm_config)
|
|
|
|
|
|
def fa4_cutedsl_warmup(worker: Worker) -> None:
|
|
_warm_fa4_mla_prefill(worker)
|
|
_warm_inkling_fa4_rel_attention(worker)
|