[Bugfix] Skip fetching revision for model when model and weights_model are different (#51260)

Signed-off-by: Dino Music <Dino.Music@amd.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

music-dino committed Aug 7, 2026 at 14:55 UTC a231c5ceac87451b6dcf5ccdf0eef7a3634bc5d4
2 files changed +27 -7
tests/test_config.py
+22 -4
@@ -9,6 +9,7 @@ from unittest.mock import patch
9
10 import pydantic
11 import pytest
12 +from huggingface_hub import ResolvedRevision
13 from pydantic import ValidationError
14
15 import vllm.config.vllm as vllm_config_module
@@ -29,10 +30,7 @@ from vllm.config.compilation import CompilationMode, CUDAGraphMode
30 from vllm.config.kernel import IrOpPriorityConfig
31 from vllm.config.load import LoadConfig
32 from vllm.config.utils import get_field
32 -from vllm.config.vllm import (
33 - OPTIMIZATION_LEVEL_TO_CONFIG,
34 - OptimizationLevel,
35 -)
33 +from vllm.config.vllm import OPTIMIZATION_LEVEL_TO_CONFIG, OptimizationLevel
34 from vllm.platforms import current_platform
35 from vllm.v1.attention.backend import AttentionCGSupport
36
@@ -1771,3 +1769,23 @@ def test_load_config_rejects_invalid_safetensors_load_strategy():
1769 def test_load_config_rejects_non_string_load_format(bad_load_format):
1770 with pytest.raises(pydantic.ValidationError):
1771 LoadConfig(load_format=bad_load_format)
1772 +
1773 +
1774 +# A real Qwen3-0.6B model revision that is used in the tests below.
1775 +REVISION = "c1899de289a04d12100db370d81485cdf75e47ca"
1776 +
1777 +
1778 +@patch("vllm.config.model.resolve_revision", return_value=ResolvedRevision(REVISION))
1779 +def test_revision_not_resolved_when_weights_differ_from_model(mock_resolve):
1780 + model_weights = "unsloth/Qwen3-0.6B-GGUF:Q8_0"
1781 + config = ModelConfig("Qwen/Qwen3-0.6B", model_weights=model_weights)
1782 + assert config.revision is None
1783 +
1784 +
1785 +@patch("vllm.config.model.resolve_revision", return_value=ResolvedRevision(REVISION))
1786 +def test_revision_resolved_when_weights_match_model(mock_resolve):
1787 + model = "Qwen/Qwen3-0.6B"
1788 + config = ModelConfig(model)
1789 + assert isinstance(config.revision, ResolvedRevision)
1790 + assert config.revision.resolved == REVISION
1791 + mock_resolve.assert_any_call(model, None, config.hf_token)
vllm/config/model.py
+5 -3
@@ -567,9 +567,11 @@ class ModelConfig:
567
568 # If loading model/tokenizer from HF Hub, resolve the revision once
569 # to prevent resolving it multiple times downstream.
570 - can_resolve_model_revision = (
571 - self.hf_config_path is None or self.hf_config_path == self.model
572 - )
570 + # If the weights come from a different repo, we cannot eagerly resolve revision
571 + weights_from_model = not self.model_weights or self.model_weights == self.model
572 + # If the config comes from a different repo, we cannot eagerly resolve revision
573 + config_from_model = not self.hf_config_path or self.hf_config_path == self.model
574 + can_resolve_model_revision = config_from_model and weights_from_model
575 if can_resolve_model_revision:
576 self.revision = resolve_revision(
577 self.model,