Fix weight tying (#51665)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-08-20 10:31:55 +00:00
committed by GitHub
parent 6e85feb1b7
commit f0c14b4f77
70 changed files with 526 additions and 238 deletions
+24 -2
View File
@@ -8,14 +8,17 @@ only get the `eos_token_id` from the tokenizer as defined by
from types import SimpleNamespace
from typing import cast
from unittest.mock import patch
from unittest.mock import MagicMock, patch
from transformers import PretrainedConfig
from vllm.config.model import ModelConfig
from vllm.tokenizers import get_tokenizer
from vllm.transformers_utils import config as config_module
from vllm.transformers_utils.config import try_get_generation_config
from vllm.transformers_utils.config import (
get_safetensors_params_metadata,
try_get_generation_config,
)
def test_get_llama3_eos_token():
@@ -77,3 +80,22 @@ def test_model_config_generation_fallback_forwards_code_revision():
config_format="auto",
token=None,
)
def test_safetensors_metadata_of_repo_without_safetensors():
"""A repo storing its weights in another format is an answer, not a failure,
so it must not be retried."""
from huggingface_hub.errors import LocalEntryNotFoundError, NotASafetensorsRepoError
get_safetensors_metadata = MagicMock(
side_effect=NotASafetensorsRepoError("not a safetensors repo")
)
api = SimpleNamespace(
get_safetensors_metadata=get_safetensors_metadata,
snapshot_download=MagicMock(side_effect=LocalEntryNotFoundError("no cache")),
)
with patch.object(config_module, "hf_api", lambda: api):
assert get_safetensors_params_metadata("some/pytorch-only-model") == {}
get_safetensors_metadata.assert_called_once()
@@ -14,6 +14,7 @@ from vllm.transformers_utils.repo_utils import (
get_hf_file_to_dict,
is_mistral_model_repo,
list_filtered_repo_files,
with_retry,
)
@@ -185,3 +186,13 @@ def test_is_mistral_model_repo(files: list[str], expected_bool: bool):
repo_type="model",
token="token",
)
def test_with_retry_does_not_retry_fatal_errors():
"""A definitive answer must not be retried, which costs a delay per attempt."""
func = MagicMock(side_effect=FileNotFoundError("no such file"))
with pytest.raises(FileNotFoundError):
with_retry(func, "Error", fatal_errors=(FileNotFoundError,))
func.assert_called_once()