[MM] Keep device input normalization fused when encoder compilation is enabled (#59195)
Signed-off-by: Jakub Zakrzewski <jzakrzewski@nvidia.com> Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
co-authored by
Codex
parent
5225f1bacb
commit
5a4351ab09
@@ -6,6 +6,8 @@
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm.config import CompilationConfig, VllmConfig, set_current_vllm_config
|
||||
from vllm.config.compilation import CompilationMode
|
||||
from vllm.model_executor.layers.fusion.mm_input_norm import (
|
||||
FusedMMInputNorm,
|
||||
IdentityInputNorm,
|
||||
@@ -263,6 +265,23 @@ class TestFusedMMInputNormKernel:
|
||||
class TestFusedMMInputNormConstruction:
|
||||
"""Weight/bias buffer semantics at init time."""
|
||||
|
||||
def test_input_norm_is_always_enabled(self):
|
||||
config = VllmConfig(
|
||||
compilation_config=CompilationConfig(
|
||||
mode=CompilationMode.VLLM_COMPILE,
|
||||
compile_mm_encoder=True,
|
||||
custom_ops=["none"],
|
||||
)
|
||||
)
|
||||
with set_current_vllm_config(config):
|
||||
FusedMMInputNorm(_RGB_MEAN, _RGB_STD, _RGB_RESCALE)
|
||||
assert (
|
||||
config.compilation_config.enabled_custom_ops["fused_mm_input_norm"] == 1
|
||||
)
|
||||
assert not config.compilation_config.disabled_custom_ops[
|
||||
"fused_mm_input_norm"
|
||||
]
|
||||
|
||||
def test_identity_config_buffers(self):
|
||||
"""Numerically identity parameters still build plain weight/bias
|
||||
buffers; the identity shortcut lives in ``from_model_config``."""
|
||||
|
||||
@@ -246,6 +246,10 @@ class FusedMMInputNorm(CustomOp):
|
||||
self.register_buffer("weight", (rescale_factor / std).to(device))
|
||||
self.register_buffer("bias", (-mean / std).to(device))
|
||||
|
||||
@classmethod
|
||||
def enabled(cls) -> bool:
|
||||
return True
|
||||
|
||||
@property
|
||||
def input_dtype(self) -> torch.dtype | None:
|
||||
return torch.uint8
|
||||
|
||||
Reference in New Issue
Block a user