Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
d3cc3795
Unverified
Commit
d3cc3795
authored
Mar 19, 2026
by
Ziming Huang
Committed by
GitHub
Mar 19, 2026
Browse files
[Perf] Fix slow hasattr in CUDAGraphWrapper.__getattr__ (#37425)
Signed-off-by:
智鸣
<
hzm414167@alibaba-inc.com
>
parent
354cd580
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
vllm/compilation/cuda_graph.py
vllm/compilation/cuda_graph.py
+7
-4
vllm/v1/worker/gpu_ubatch_wrapper.py
vllm/v1/worker/gpu_ubatch_wrapper.py
+8
-4
No files found.
vllm/compilation/cuda_graph.py
View file @
d3cc3795
...
...
@@ -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.
...
...
vllm/v1/worker/gpu_ubatch_wrapper.py
View file @
d3cc3795
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment