[vLLM IR] 1/N Implement IR skeleton and rms_norm op (#33825)
Signed-off-by: Luka Govedič <lgovedic@redhat.com> Signed-off-by: Xinyu Chen <xinyu1.chen@intel.com> Signed-off-by: chzhang <chaojun.zhang@intel.com> Signed-off-by: Luka Govedic <luka.govedic@gmail.com> Co-authored-by: Xinyu Chen <xinyu1.chen@intel.com> Co-authored-by: Chaojun Zhang <chaojun.zhang@intel.com> Co-authored-by: Luka Govedič <ProExpertProg@h100-01.nemg-001.lab.rdu2.dc.redhat.com>
This commit is contained in:
co-authored by
Xinyu Chen
Chaojun Zhang
Luka Govedič
parent
0fab52f0aa
commit
40bb175027
@@ -30,6 +30,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum
|
||||
if TYPE_CHECKING:
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.cache import CacheDType
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
from vllm.v1.attention.selector import AttentionSelectorConfig
|
||||
else:
|
||||
VllmConfig = None
|
||||
@@ -550,6 +551,26 @@ class CudaPlatformBase(Platform):
|
||||
def use_custom_op_collectives(cls) -> bool:
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def get_default_ir_op_priority(cls, vllm_config: VllmConfig) -> IrOpPriorityConfig:
|
||||
from vllm.config.compilation import CompilationMode
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
|
||||
# Native used by default when compiling,
|
||||
# use vllm_c kernels where available when no codegen
|
||||
cc = vllm_config.compilation_config
|
||||
using_inductor = cc.backend == "inductor" and cc.mode != CompilationMode.NONE
|
||||
default = ["native"] if using_inductor else ["vllm_c", "native"]
|
||||
|
||||
# Use oink if enabled for rms_norm
|
||||
# TODO(Laurawly/luka): remove this env var,
|
||||
# users can just use IR op priority directly
|
||||
rms_norm = default
|
||||
if envs.VLLM_USE_OINK_OPS:
|
||||
rms_norm = ["oink"] + default
|
||||
|
||||
return IrOpPriorityConfig.with_default(default, rms_norm=rms_norm)
|
||||
|
||||
|
||||
# NVML utils
|
||||
# Note that NVML is not affected by `CUDA_VISIBLE_DEVICES`,
|
||||
|
||||
@@ -17,6 +17,7 @@ if TYPE_CHECKING:
|
||||
from torch.distributed import PrefixStore, ProcessGroup
|
||||
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
from vllm.inputs import EngineInput
|
||||
from vllm.pooling_params import PoolingParams
|
||||
from vllm.sampling_params import SamplingParams
|
||||
@@ -931,6 +932,16 @@ class Platform:
|
||||
"num_compute_units is not implemented for the current platform."
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_default_ir_op_priority(
|
||||
cls, vllm_config: "VllmConfig"
|
||||
) -> "IrOpPriorityConfig":
|
||||
"""Get the default IR op priority for the current platform."""
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
|
||||
# Native always used by default. Platforms can override this behavior.
|
||||
return IrOpPriorityConfig.with_default(["native"])
|
||||
|
||||
|
||||
class UnspecifiedPlatform(Platform):
|
||||
_enum = PlatformEnum.UNSPECIFIED
|
||||
|
||||
@@ -19,6 +19,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
from vllm.v1.attention.selector import AttentionSelectorConfig
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -903,3 +904,32 @@ class RocmPlatform(Platform):
|
||||
@classmethod
|
||||
def use_custom_op_collectives(cls) -> bool:
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def get_default_ir_op_priority(
|
||||
cls, vllm_config: "VllmConfig"
|
||||
) -> "IrOpPriorityConfig":
|
||||
from vllm.config.compilation import CompilationMode
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
|
||||
# Native used by default when compiling,
|
||||
# use vllm_c kernels where available when no codegen
|
||||
# TODO(luka/TJ) use aiter, vllm_c, native by default on ROCm
|
||||
cc = vllm_config.compilation_config
|
||||
using_inductor = cc.backend == "inductor" and cc.mode != CompilationMode.NONE
|
||||
default = ["native"] if using_inductor else ["vllm_c", "native"]
|
||||
|
||||
# This (mostly) preserves previous CustomOp behavior
|
||||
# Necessary on ROCm because it's common that users
|
||||
# enable rms_norm to use the aiter kernel.
|
||||
# TODO(luka/TJ) remove env vars completely
|
||||
if (
|
||||
cc.is_custom_op_enabled("rms_norm")
|
||||
and envs.VLLM_ROCM_USE_AITER
|
||||
and envs.VLLM_ROCM_USE_AITER_RMSNORM
|
||||
):
|
||||
rms_norm = ["aiter"] + default
|
||||
else:
|
||||
rms_norm = default
|
||||
|
||||
return IrOpPriorityConfig.with_default(default, rms_norm=rms_norm)
|
||||
|
||||
@@ -21,6 +21,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
from vllm.v1.attention.selector import AttentionSelectorConfig
|
||||
else:
|
||||
VllmConfig = None
|
||||
@@ -257,6 +258,21 @@ class XPUPlatform(Platform):
|
||||
)
|
||||
return "vllm.distributed.device_communicators.xpu_communicator.XpuCommunicator" # noqa
|
||||
|
||||
@classmethod
|
||||
def get_default_ir_op_priority(
|
||||
cls, vllm_config: "VllmConfig"
|
||||
) -> "IrOpPriorityConfig":
|
||||
from vllm.config.compilation import CompilationMode
|
||||
from vllm.config.kernel import IrOpPriorityConfig
|
||||
|
||||
# Native used by default when compiling,
|
||||
# use fused kernels where available when no codegen
|
||||
cc = vllm_config.compilation_config
|
||||
using_inductor = cc.backend == "inductor" and cc.mode != CompilationMode.NONE
|
||||
default = ["native"] if using_inductor else ["xpu_kernels", "native"]
|
||||
|
||||
return IrOpPriorityConfig.with_default(default)
|
||||
|
||||
@classmethod
|
||||
def device_count(cls) -> int:
|
||||
return torch.xpu.device_count()
|
||||
|
||||
Reference in New Issue
Block a user