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
7f58fb97
Unverified
Commit
7f58fb97
authored
Apr 22, 2025
by
Richard Zou
Committed by
GitHub
Apr 22, 2025
Browse files
Add assertion for no objects while hashing hf_config (#16930)
Signed-off-by:
rzou
<
zou3519@gmail.com
>
parent
30bc3e0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
vllm/config.py
vllm/config.py
+30
-0
No files found.
vllm/config.py
View file @
7f58fb97
...
@@ -6,6 +6,7 @@ import enum
...
@@ -6,6 +6,7 @@ import enum
import
hashlib
import
hashlib
import
inspect
import
inspect
import
json
import
json
import
re
import
sys
import
sys
import
textwrap
import
textwrap
import
warnings
import
warnings
...
@@ -328,6 +329,8 @@ class ModelConfig:
...
@@ -328,6 +329,8 @@ class ModelConfig:
factors
.
append
(
self
.
rope_theta
)
factors
.
append
(
self
.
rope_theta
)
# hf_config can control how the model looks!
# hf_config can control how the model looks!
factors
.
append
(
self
.
hf_config
.
to_json_string
())
factors
.
append
(
self
.
hf_config
.
to_json_string
())
str_factors
=
str
(
factors
)
assert_hashable
(
str_factors
)
return
hashlib
.
sha256
(
str
(
factors
).
encode
()).
hexdigest
()
return
hashlib
.
sha256
(
str
(
factors
).
encode
()).
hexdigest
()
def
__init__
(
def
__init__
(
...
@@ -4031,3 +4034,30 @@ def get_current_vllm_config() -> VllmConfig:
...
@@ -4031,3 +4034,30 @@ def get_current_vllm_config() -> VllmConfig:
from
vllm.config
import
VllmConfig
from
vllm.config
import
VllmConfig
return
VllmConfig
()
return
VllmConfig
()
return
_current_vllm_config
return
_current_vllm_config
def
contains_object_print
(
text
):
"""
Check if the text looks like a printed Python object, e.g.
contains any substring matching the pattern: "at 0xFFFFFFF>"
We match against 0x followed by 2-16 hex chars (there's
a max of 16 on a 64 bit system).
Args:
text (str): The text to check
Returns:
bool: True if a match is found, False otherwise
"""
pattern
=
r
'at 0x[a-fA-F0-9]{2,16}>'
match
=
re
.
search
(
pattern
,
text
)
return
match
is
not
None
def
assert_hashable
(
text
):
if
not
contains_object_print
(
text
):
return
True
raise
AssertionError
(
f
"vLLM tried to hash some configs that may have Python objects ids "
f
"in them. This is a bug, please file an issue. "
f
"Text being hashed:
{
text
}
"
)
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