Skip to content

Commit b6dbb00

Browse files
youkaichaogarg-amit
authored andcommitted
[torch.compile] add a flag to disable custom op (vllm-project#8488)
Signed-off-by: Amit Garg <[email protected]>
1 parent 5debbf5 commit b6dbb00

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

tests/compile/test_full_graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
@pytest.mark.parametrize("model", ["meta-llama/Meta-Llama-3-8B"])
77
def test_full_graph(model):
88
# make sure these models can be captured in full graph mode
9-
os.environ["VLLM_TEST_DYNAMO_GRAPH_CAPTURE"] = "1"
9+
if "VLLM_TEST_DYNAMO_GRAPH_CAPTURE" not in os.environ:
10+
os.environ["VLLM_TEST_DYNAMO_GRAPH_CAPTURE"] = "1"
1011

1112
from vllm import LLM, SamplingParams
1213
prompts = [

vllm/envs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def get_default_config_root():
202202
(os.environ.get("VLLM_DYNAMO_USE_CUSTOM_DISPATCHER", "True").lower() in
203203
("true", "1")),
204204

205+
# Internal flag to control whether we use custom op,
206+
# or use the native pytorch implementation
207+
"VLLM_TEST_COMPILE_NO_CUSTOM_OPS":
208+
lambda: int(os.environ.get("VLLM_TEST_COMPILE_NO_CUSTOM_OPS", "0")),
209+
205210
# Internal flag to enable Dynamo fullgraph capture
206211
"VLLM_TEST_DYNAMO_FULLGRAPH_CAPTURE":
207212
lambda: bool(

vllm/model_executor/custom_op.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import torch.nn as nn
22

3+
import vllm.envs as envs
34
from vllm.platforms import current_platform
45
from vllm.utils import is_cpu, is_hip, is_xpu
56

@@ -53,6 +54,10 @@ def forward_gaudi(self, *args, **kwargs):
5354
def dispatch_forward(self):
5455
# NOTE(woosuk): Here we assume that vLLM was built for only one
5556
# specific backend. Currently, we do not support dynamic dispatching.
57+
58+
if envs.VLLM_TEST_COMPILE_NO_CUSTOM_OPS:
59+
return self.forward_native
60+
5661
if is_hip():
5762
return self.forward_hip
5863
elif is_cpu():

0 commit comments

Comments
 (0)