[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>
This commit is contained in:
co-authored by
Harry Mellor
parent
d5aae2b464
commit
a231c5ceac
+22
-4
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user