Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import pydantic
import pytest
from huggingface_hub import ResolvedRevision
from pydantic import ValidationError

import vllm.config.vllm as vllm_config_module
Expand All @@ -29,10 +30,7 @@
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

Expand Down Expand Up @@ -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)
8 changes: 5 additions & 3 deletions vllm/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,11 @@ def __post_init__(

# 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,
Expand Down
Loading