Skip to content

Commit 4794402

Browse files
wangxiyuanabmfy
authored andcommitted
[platform] support pytorch custom op pluggable (vllm-project#11328)
Signed-off-by: wangxiyuan <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
1 parent 524640f commit 4794402

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

vllm/model_executor/custom_op.py

+7
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def forward_hpu(self, *args, **kwargs):
5757
# PyTorch-native implementation.
5858
return self.forward_native(*args, **kwargs)
5959

60+
def forward_oot(self, *args, **kwargs):
61+
# By default, we assume that OOT ops are compatible with the
62+
# PyTorch-native implementation.
63+
return self.forward_native(*args, **kwargs)
64+
6065
def dispatch_forward(self):
6166
# NOTE(woosuk): Here we assume that vLLM was built for only one
6267
# specific backend. Currently, we do not support dynamic dispatching.
@@ -81,6 +86,8 @@ def dispatch_forward(self):
8186
return self.forward_tpu
8287
elif current_platform.is_xpu():
8388
return self.forward_xpu
89+
elif current_platform.is_out_of_tree():
90+
return self.forward_oot
8491
else:
8592
return self.forward_cuda
8693

vllm/platforms/interface.py

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class PlatformEnum(enum.Enum):
4545
CPU = enum.auto()
4646
NEURON = enum.auto()
4747
OPENVINO = enum.auto()
48+
OOT = enum.auto()
4849
UNSPECIFIED = enum.auto()
4950

5051

@@ -107,6 +108,9 @@ def is_neuron(self) -> bool:
107108
def is_openvino(self) -> bool:
108109
return self._enum == PlatformEnum.OPENVINO
109110

111+
def is_out_of_tree(self) -> bool:
112+
return self._enum == PlatformEnum.OOT
113+
110114
def is_cuda_alike(self) -> bool:
111115
"""Stateless version of :func:`torch.cuda.is_available`."""
112116
return self._enum in (PlatformEnum.CUDA, PlatformEnum.ROCM)

0 commit comments

Comments
 (0)