From a231c5ceac87451b6dcf5ccdf0eef7a3634bc5d4 Mon Sep 17 00:00:00 2001 From: music-dino <111048524+music-dino@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:55:50 +0200 Subject: [PATCH] [Bugfix] Skip fetching revision for model when model and weights_model are different (#51260) Signed-off-by: Dino Music Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- tests/test_config.py | 26 ++++++++++++++++++++++---- vllm/config/model.py | 8 +++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index febc9dab28..9b51aab857 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -9,6 +9,7 @@ from unittest.mock import patch import pydantic import pytest +from huggingface_hub import ResolvedRevision from pydantic import ValidationError import vllm.config.vllm as vllm_config_module @@ -29,10 +30,7 @@ from vllm.config.compilation import CompilationMode, CUDAGraphMode from vllm.config.kernel import IrOpPriorityConfig from vllm.config.load import LoadConfig from vllm.config.utils import get_field -from vllm.config.vllm import ( - OPTIMIZATION_LEVEL_TO_CONFIG, - OptimizationLevel, -) +from vllm.config.vllm import OPTIMIZATION_LEVEL_TO_CONFIG, OptimizationLevel from vllm.platforms import current_platform from vllm.v1.attention.backend import AttentionCGSupport @@ -1771,3 +1769,23 @@ def test_load_config_rejects_invalid_safetensors_load_strategy(): def test_load_config_rejects_non_string_load_format(bad_load_format): with pytest.raises(pydantic.ValidationError): LoadConfig(load_format=bad_load_format) + + +# A real Qwen3-0.6B model revision that is used in the tests below. +REVISION = "c1899de289a04d12100db370d81485cdf75e47ca" + + +@patch("vllm.config.model.resolve_revision", return_value=ResolvedRevision(REVISION)) +def test_revision_not_resolved_when_weights_differ_from_model(mock_resolve): + model_weights = "unsloth/Qwen3-0.6B-GGUF:Q8_0" + config = ModelConfig("Qwen/Qwen3-0.6B", model_weights=model_weights) + assert config.revision is None + + +@patch("vllm.config.model.resolve_revision", return_value=ResolvedRevision(REVISION)) +def test_revision_resolved_when_weights_match_model(mock_resolve): + model = "Qwen/Qwen3-0.6B" + config = ModelConfig(model) + assert isinstance(config.revision, ResolvedRevision) + assert config.revision.resolved == REVISION + mock_resolve.assert_any_call(model, None, config.hf_token) diff --git a/vllm/config/model.py b/vllm/config/model.py index 05dbd693c1..b01e6c8c68 100644 --- a/vllm/config/model.py +++ b/vllm/config/model.py @@ -567,9 +567,11 @@ class ModelConfig: # If loading model/tokenizer from HF Hub, resolve the revision once # to prevent resolving it multiple times downstream. - can_resolve_model_revision = ( - self.hf_config_path is None or self.hf_config_path == self.model - ) + # If the weights come from a different repo, we cannot eagerly resolve revision + weights_from_model = not self.model_weights or self.model_weights == self.model + # If the config comes from a different repo, we cannot eagerly resolve revision + config_from_model = not self.hf_config_path or self.hf_config_path == self.model + can_resolve_model_revision = config_from_model and weights_from_model if can_resolve_model_revision: self.revision = resolve_revision( self.model,