From 54b0578adacd0413b18c0f59948dabc7533a6524 Mon Sep 17 00:00:00 2001 From: Javier De Jesus Date: Tue, 24 Mar 2026 20:22:05 +0100 Subject: [PATCH] [Bugfix] Pass hf_token through config loading paths for gated model support (#37920) Signed-off-by: javierdejesusda --- vllm/config/model.py | 3 +++ vllm/engine/arg_utils.py | 1 + vllm/transformers_utils/config.py | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/vllm/config/model.py b/vllm/config/model.py index b539420785..032f29c180 100644 --- a/vllm/config/model.py +++ b/vllm/config/model.py @@ -488,6 +488,7 @@ class ModelConfig: # type: ignore[misc] self.config_format, hf_overrides_kw=hf_overrides_kw, hf_overrides_fn=hf_overrides_fn, + token=self.hf_token, ) hf_config = maybe_patch_hf_config_from_gguf( self.model, @@ -1341,12 +1342,14 @@ class ModelConfig: # type: ignore[misc] trust_remote_code=self.trust_remote_code, revision=self.revision, config_format=self.config_format, + hf_token=self.hf_token, ) else: config = try_get_generation_config( self.generation_config, trust_remote_code=self.trust_remote_code, config_format=self.config_format, + hf_token=self.hf_token, ) if config is None: diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index 41eadb1e65..6ae0b1daef 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -1530,6 +1530,7 @@ class EngineArgs: revision=self.revision, trust_remote_code=self.trust_remote_code, vllm_speculative_config=self.speculative_config, + hf_token=self.hf_token, ) ) diff --git a/vllm/transformers_utils/config.py b/vllm/transformers_utils/config.py index 6313d34a6b..9894a6a88e 100644 --- a/vllm/transformers_utils/config.py +++ b/vllm/transformers_utils/config.py @@ -542,6 +542,7 @@ def maybe_override_with_speculators( trust_remote_code: bool, revision: str | None = None, vllm_speculative_config: dict[str, Any] | None = None, + hf_token: bool | str | None = None, **kwargs, ) -> tuple[str, str | None, dict[str, Any] | None]: """ @@ -556,6 +557,7 @@ def maybe_override_with_speculators( trust_remote_code: Whether to trust remote code revision: Model revision vllm_speculative_config: Existing vLLM speculative config + hf_token: HuggingFace token for authenticated model access Returns: Tuple of (resolved_model, resolved_tokenizer, speculative_config) @@ -572,6 +574,7 @@ def maybe_override_with_speculators( config_dict, _ = PretrainedConfig.get_config_dict( model if gguf_model_repo is None else gguf_model_repo, revision=revision, + token=hf_token, **without_trust_remote_code(kwargs), ) speculators_config = config_dict.get("speculators_config") @@ -1054,6 +1057,7 @@ def try_get_generation_config( trust_remote_code: bool, revision: str | None = None, config_format: str | ConfigFormat = "auto", + hf_token: bool | str | None = None, ) -> GenerationConfig | None: # GGUF files don't have generation_config.json - their config is embedded # in the file header. Skip all filesystem lookups to avoid re-reading the @@ -1066,6 +1070,7 @@ def try_get_generation_config( return GenerationConfig.from_pretrained( model, revision=revision, + token=hf_token, ) except OSError: # Not found try: @@ -1074,6 +1079,7 @@ def try_get_generation_config( trust_remote_code=trust_remote_code, revision=revision, config_format=config_format, + token=hf_token, ) return GenerationConfig.from_model_config(config) except OSError: # Not found