Skip to content

Commit 1bd1545

Browse files
youkaichaomfournioux
authored andcommitted
[torch.compile] fix cpu broken code (vllm-project#9947)
Signed-off-by: youkaichao <youkaichao@gmail.com> Signed-off-by: Maxime Fournioux <55544262+mfournioux@users.noreply.github.com>
1 parent 15f23b0 commit 1bd1545

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

vllm/utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,14 @@ def direct_register_custom_op(
15511551
"""
15521552
if is_in_doc_build():
15531553
return
1554-
schema_str = torch.library.infer_schema(op_func, mutates_args=mutates_args)
1554+
import torch.library
1555+
if hasattr(torch.library, "infer_schema"):
1556+
schema_str = torch.library.infer_schema(op_func,
1557+
mutates_args=mutates_args)
1558+
else:
1559+
# for pytorch 2.4
1560+
import torch._custom_op.impl
1561+
schema_str = torch._custom_op.impl.infer_schema(op_func, mutates_args)
15551562
my_lib = target_lib or vllm_lib
15561563
my_lib.define(op_name + schema_str)
15571564
my_lib.impl(op_name, op_func, "CUDA")

0 commit comments

Comments
 (0)