Unverified Commit d3cc3795 authored by Ziming Huang's avatar Ziming Huang Committed by GitHub
Browse files

[Perf] Fix slow hasattr in CUDAGraphWrapper.__getattr__ (#37425)


Signed-off-by: default avatar智鸣 <hzm414167@alibaba-inc.com>
parent 354cd580
......@@ -189,6 +189,7 @@ class CUDAGraphWrapper:
self.first_run_finished = False
self.is_debugging_mode = envs.VLLM_LOGGING_LEVEL == "DEBUG"
self._runnable_str = str(runnable) if self.is_debugging_mode else None
# assert runtime_mode is not NONE(no cudagraph), otherwise, we don't
# need to initialize a CUDAGraphWrapper.
......@@ -211,10 +212,12 @@ class CUDAGraphWrapper:
# allow accessing the attributes of the runnable.
if hasattr(self.runnable, key):
return getattr(self.runnable, key)
if self.is_debugging_mode:
raise AttributeError(
f"Attribute {key} not exists in the runnable of "
f"cudagraph wrapper: {self.runnable}"
f"cudagraph wrapper: {self._runnable_str}"
)
raise AttributeError
def unwrap(self) -> Callable[..., Any]:
# in case we need to access the original runnable.
......
......@@ -119,6 +119,8 @@ class UBatchWrapper:
self.sm_control = self._create_sm_control_context(vllm_config)
self.device = device
self.is_debugging_mode = envs.VLLM_LOGGING_LEVEL == "DEBUG"
self._runnable_str = str(runnable) if self.is_debugging_mode else None
@property
def graph_pool(self):
......@@ -170,10 +172,12 @@ class UBatchWrapper:
# allow accessing the attributes of the runnable.
if hasattr(self.runnable, key):
return getattr(self.runnable, key)
if self.is_debugging_mode:
raise AttributeError(
f"Attribute {key} not exists in the runnable of "
f"cudagraph wrapper: {self.runnable}"
f"cudagraph wrapper: {self._runnable_str}"
)
raise AttributeError
def unwrap(self) -> Callable:
# in case we need to access the original runnable.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment