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
139508a4
Unverified
Commit
139508a4
authored
Jul 03, 2025
by
rongfu.leng
Committed by
GitHub
Jul 02, 2025
Browse files
[Misc] add handler HF_TOKEN is emptry string (#20369)
Signed-off-by:
rongfu.leng
<
rongfu.leng@daocloud.io
>
parent
d265414d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
vllm/transformers_utils/config.py
vllm/transformers_utils/config.py
+22
-6
No files found.
vllm/transformers_utils/config.py
View file @
139508a4
...
@@ -56,6 +56,22 @@ MISTRAL_CONFIG_NAME = "params.json"
...
@@ -56,6 +56,22 @@ MISTRAL_CONFIG_NAME = "params.json"
logger
=
init_logger
(
__name__
)
logger
=
init_logger
(
__name__
)
def
_get_hf_token
()
->
Optional
[
str
]:
"""
Get the HuggingFace token from environment variable.
Returns None if the token is not set, is an empty string,
or contains only whitespace.
This follows the same pattern as huggingface_hub library which
treats empty string tokens as None to avoid authentication errors.
"""
token
=
os
.
getenv
(
'HF_TOKEN'
)
if
token
and
token
.
strip
():
return
token
return
None
_CONFIG_REGISTRY_OVERRIDE_HF
:
dict
[
str
,
type
[
PretrainedConfig
]]
=
{
_CONFIG_REGISTRY_OVERRIDE_HF
:
dict
[
str
,
type
[
PretrainedConfig
]]
=
{
"mllama"
:
MllamaConfig
"mllama"
:
MllamaConfig
}
}
...
@@ -195,7 +211,7 @@ def file_or_path_exists(model: Union[str, Path], config_name: str,
...
@@ -195,7 +211,7 @@ def file_or_path_exists(model: Union[str, Path], config_name: str,
return
file_exists
(
str
(
model
),
return
file_exists
(
str
(
model
),
config_name
,
config_name
,
revision
=
revision
,
revision
=
revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
))
token
=
_get_hf_token
(
))
def
patch_rope_scaling
(
config
:
PretrainedConfig
)
->
None
:
def
patch_rope_scaling
(
config
:
PretrainedConfig
)
->
None
:
...
@@ -322,7 +338,7 @@ def get_config(
...
@@ -322,7 +338,7 @@ def get_config(
model
,
model
,
revision
=
revision
,
revision
=
revision
,
code_revision
=
code_revision
,
code_revision
=
code_revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
),
token
=
_get_hf_token
(
),
**
kwargs
,
**
kwargs
,
)
)
...
@@ -334,7 +350,7 @@ def get_config(
...
@@ -334,7 +350,7 @@ def get_config(
model
,
model
,
revision
=
revision
,
revision
=
revision
,
code_revision
=
code_revision
,
code_revision
=
code_revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
),
token
=
_get_hf_token
(
),
**
kwargs
,
**
kwargs
,
)
)
else
:
else
:
...
@@ -344,7 +360,7 @@ def get_config(
...
@@ -344,7 +360,7 @@ def get_config(
trust_remote_code
=
trust_remote_code
,
trust_remote_code
=
trust_remote_code
,
revision
=
revision
,
revision
=
revision
,
code_revision
=
code_revision
,
code_revision
=
code_revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
),
token
=
_get_hf_token
(
),
**
kwargs
,
**
kwargs
,
)
)
except
ValueError
as
e
:
except
ValueError
as
e
:
...
@@ -571,7 +587,7 @@ def get_sentence_transformer_tokenizer_config(model: str,
...
@@ -571,7 +587,7 @@ def get_sentence_transformer_tokenizer_config(model: str,
# If model is on HuggingfaceHub, get the repo files
# If model is on HuggingfaceHub, get the repo files
repo_files
=
list_repo_files
(
model
,
repo_files
=
list_repo_files
(
model
,
revision
=
revision
,
revision
=
revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
))
token
=
_get_hf_token
(
))
except
Exception
:
except
Exception
:
repo_files
=
[]
repo_files
=
[]
...
@@ -862,7 +878,7 @@ def try_get_safetensors_metadata(
...
@@ -862,7 +878,7 @@ def try_get_safetensors_metadata(
get_safetensors_metadata
,
get_safetensors_metadata
,
model
,
model
,
revision
=
revision
,
revision
=
revision
,
token
=
os
.
getenv
(
'HF_TOKEN'
,
None
),
token
=
_get_hf_token
(
),
)
)
try
:
try
:
...
...
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