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
87805fa1
Unverified
Commit
87805fa1
authored
Apr 20, 2026
by
Frederik Gossen
Committed by
GitHub
Apr 20, 2026
Browse files
[Core] Cache InductorPass.hash_source with functools.cache (#39328)
Signed-off-by:
Frederik Gossen
<
frgossen@meta.com
>
parent
304d5ba1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
vllm/compilation/passes/inductor_pass.py
vllm/compilation/passes/inductor_pass.py
+17
-11
No files found.
vllm/compilation/passes/inductor_pass.py
View file @
87805fa1
...
...
@@ -51,6 +51,15 @@ def pass_context(compile_range: Range) -> Generator[None, None, None]:
_pass_context
=
prev_context
@
functools
.
cache
def
_hash_source_cached
(
*
srcs
:
str
|
type
|
types
.
FunctionType
)
->
str
:
hasher
=
hashlib
.
sha256
()
for
src
in
srcs
:
src_str
=
src
if
isinstance
(
src
,
str
)
else
inspect
.
getsource
(
src
)
hasher
.
update
(
src_str
.
encode
(
"utf-8"
))
return
hasher
.
hexdigest
()
class
InductorPass
(
CustomGraphPass
):
# type: ignore[misc]
"""
A custom graph pass that uses a hash of its source as the UUID.
...
...
@@ -72,19 +81,16 @@ class InductorPass(CustomGraphPass): # type: ignore[misc]
Utility method to hash the sources of functions or objects.
:param srcs: strings or objects to add to the hash.
Objects and functions have their source inspected.
Results are cached by resolved types to avoid repeated
inspect.getsource() calls.
:return:
"""
hasher
=
hashlib
.
sha256
()
for
src
in
srcs
:
if
isinstance
(
src
,
str
):
src_str
=
src
elif
isinstance
(
src
,
(
types
.
FunctionType
,
type
)):
src_str
=
inspect
.
getsource
(
src
)
else
:
# object instance
src_str
=
inspect
.
getsource
(
src
.
__class__
)
hasher
.
update
(
src_str
.
encode
(
"utf-8"
))
return
hasher
.
hexdigest
()
# Resolve instances to their class for a hashable cache key.
cache_key
=
tuple
(
src
if
isinstance
(
src
,
(
str
,
type
,
types
.
FunctionType
))
else
src
.
__class__
for
src
in
srcs
)
return
_hash_source_cached
(
*
cache_key
)
@
staticmethod
def
hash_dict
(
dict_
:
dict
[
Any
,
Any
])
->
str
:
...
...
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