Don't compile vision encoder for Transformers backend (#30518)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -205,6 +205,8 @@ def support_torch_compile(
|
||||
if v.annotation in [
|
||||
torch.Tensor,
|
||||
torch.Tensor | None,
|
||||
torch.FloatTensor,
|
||||
torch.FloatTensor | None,
|
||||
IntermediateTensors,
|
||||
IntermediateTensors | None,
|
||||
]:
|
||||
@@ -346,7 +348,7 @@ def _support_torch_compile(
|
||||
|
||||
def __init__(
|
||||
self: _T,
|
||||
*,
|
||||
*args,
|
||||
vllm_config: VllmConfig | None = None,
|
||||
prefix: str = "",
|
||||
**kwargs: Any,
|
||||
@@ -357,11 +359,24 @@ def _support_torch_compile(
|
||||
# NOTE: to support multimodal models (such as encoder),
|
||||
# we may not have vllm_config so we may need to patch it
|
||||
sig = inspect.signature(old_init)
|
||||
# Check that any positional arguments match the old_init method signature
|
||||
annotations = [p.annotation for p in sig.parameters.values()]
|
||||
for arg, annotation in zip(args, annotations):
|
||||
if annotation is inspect._empty:
|
||||
continue
|
||||
if not isinstance(arg, annotation):
|
||||
init = f"'{type(self).__name__}.__init__'"
|
||||
arg_type = f"'{type(arg).__name__}'"
|
||||
raise TypeError(
|
||||
f"{init} received a positional argument of type {arg_type}, "
|
||||
"but no parameter of that type was found in the method signature. "
|
||||
f"Please either annotate {init} or pass it as a keyword argument."
|
||||
)
|
||||
if "vllm_config" in sig.parameters:
|
||||
kwargs["vllm_config"] = vllm_config
|
||||
if "prefix" in sig.parameters:
|
||||
kwargs["prefix"] = prefix
|
||||
old_init(self, **kwargs)
|
||||
old_init(self, *args, **kwargs)
|
||||
|
||||
self.vllm_config = vllm_config
|
||||
self.compilation_config = self.vllm_config.compilation_config
|
||||
|
||||
Reference in New Issue
Block a user