Skip to content

Commit 51d370a

Browse files
youkaichaorickyyx
authored andcommitted
[3/N][torch.compile] consolidate custom op logging (vllm-project#10399)
Signed-off-by: youkaichao <youkaichao@gmail.com> Signed-off-by: rickyx <rickyx@anyscale.com>
1 parent d3c9fa3 commit 51d370a

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

vllm/config.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import warnings
55
from dataclasses import dataclass, field, replace
66
from pathlib import Path
7-
from typing import (TYPE_CHECKING, Any, Callable, ClassVar, Dict, Final, List,
8-
Literal, Mapping, Optional, Set, Tuple, Type, Union)
7+
from typing import (TYPE_CHECKING, Any, Callable, ClassVar, Counter, Dict,
8+
Final, List, Literal, Mapping, Optional, Set, Tuple, Type,
9+
Union)
910

1011
import torch
1112
from pydantic import BaseModel, Field, PrivateAttr
@@ -2169,6 +2170,10 @@ class CompilationConfig(BaseModel):
21692170
compile_sizes: List[int] = PrivateAttr
21702171
capture_sizes: List[int] = PrivateAttr
21712172

2173+
# keep track of enabled and disabled custom ops
2174+
enabled_custom_ops: Counter[str] = PrivateAttr
2175+
disabled_custom_ops: Counter[str] = PrivateAttr
2176+
21722177
def model_post_init(self, __context: Any) -> None:
21732178
self.level = envs.VLLM_TORCH_COMPILE_LEVEL
21742179

@@ -2190,6 +2195,9 @@ def model_post_init(self, __context: Any) -> None:
21902195
func = __import__(module).__dict__[func_name]
21912196
self.inductor_compile_config[k] = func
21922197

2198+
self.enabled_custom_ops = Counter()
2199+
self.disabled_custom_ops = Counter()
2200+
21932201
def init_backend(self) -> Union[str, Callable]:
21942202
if self.level == CompilationLevel.NO_COMPILATION:
21952203
raise ValueError("No compilation level is set.")

vllm/model_executor/custom_op.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ def forward_hpu(self, *args, **kwargs):
6161
def dispatch_forward(self):
6262
# NOTE(woosuk): Here we assume that vLLM was built for only one
6363
# specific backend. Currently, we do not support dynamic dispatching.
64-
64+
compilation_config = get_current_vllm_config().compilation_config
6565
enabled = self.enabled()
66-
logger.debug("custom op %s %s", self.__class__.name,
67-
"enabled" if enabled else "disabled")
66+
if enabled:
67+
compilation_config.enabled_custom_ops.update([self.__class__.name])
68+
else:
69+
compilation_config.disabled_custom_ops.update(
70+
[self.__class__.name])
6871

6972
if not enabled:
7073
return self.forward_native

vllm/plugins/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def set_current_vllm_config(vllm_config: VllmConfig):
8080
_current_vllm_config = vllm_config
8181
yield
8282
finally:
83+
logger.debug("enabled custom ops: %s",
84+
vllm_config.compilation_config.enabled_custom_ops)
85+
logger.debug("disabled custom ops: %s",
86+
vllm_config.compilation_config.disabled_custom_ops)
8387
_current_vllm_config = old_vllm_config
8488

8589

0 commit comments

Comments
 (0)