Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
clarify
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
  • Loading branch information
hmellor committed Aug 6, 2026
commit 1c9bb4f35e5b6880b06dddceec5b9d8026a4a61a
25 changes: 8 additions & 17 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,25 +1773,16 @@ def test_load_config_rejects_non_string_load_format(bad_load_format):
LoadConfig(load_format=bad_load_format)


@patch("vllm.config.model.resolve_revision", return_value="main")
@patch("vllm.transformers_utils.repo_utils.resolve_revision", return_value="abc123")
def test_revision_not_resolved_when_weights_differ_from_model(mock_resolve):
"""When model_weights points to a different repo than model (e.g.
GGUF, where model is redirected to the base repo for config), the shared
revision must stay unresolved, or the config repo's commit hash would
leak into the weights download and 404 against the weights repo."""
config = ModelConfig(
"Qwen/Qwen3-0.6B",
model_weights="unsloth/Qwen3-0.6B-GGUF:Q8_0",
)

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="main")
@patch("vllm.transformers_utils.repo_utils.resolve_revision", return_value="abc123")
def test_revision_resolved_when_weights_match_model(mock_resolve):
"""Normal case: weights come from model, so the shared revision is
resolved once against that repo."""
config = ModelConfig("Qwen/Qwen3-0.6B")

assert config.revision == "main"
mock_resolve.assert_any_call("Qwen/Qwen3-0.6B", None, config.hf_token)
model = "Qwen/Qwen3-0.6B"
config = ModelConfig(model)
assert config.revision == "abc123"
mock_resolve.assert_any_call(model, None, config.hf_token)
14 changes: 5 additions & 9 deletions vllm/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,11 @@ def __post_init__(

# If loading model/tokenizer from HF Hub, resolve the revision once
# to prevent resolving it multiple times downstream.
# Only resolve the shared revision against self.model when the
# weights are loaded from that same repo. When model_weights points
# elsewhere (e.g. GGUF, where model is redirected to the base repo
# for config), pinning revision to the config repo's commit hash
# would leak an invalid revision into the weights download.
weights_match_model = not self.model_weights or self.model_weights == self.model
can_resolve_model_revision = (
self.hf_config_path is None or self.hf_config_path == self.model
) and weights_match_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