[Bugfix][Model] Pass revision by name in Run:ai and bitsandbytes index downloads (#45308)
Signed-off-by: Ting Sun <suntcrick@gmail.com>
This commit is contained in:
+25
@@ -1,11 +1,15 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import types
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm import SamplingParams
|
||||
from vllm.config.load import LoadConfig
|
||||
from vllm.model_executor.model_loader import get_model_loader
|
||||
from vllm.model_executor.model_loader import runai_streamer_loader as rsl
|
||||
|
||||
load_format = "runai_streamer"
|
||||
test_model = "openai-community/gpt2"
|
||||
@@ -53,3 +57,24 @@ def test_runai_model_loader_download_files_gcs(
|
||||
with vllm_runner(test_gcs_model, load_format=load_format) as llm:
|
||||
deserialized_outputs = llm.generate(prompts, sampling_params)
|
||||
assert deserialized_outputs
|
||||
|
||||
|
||||
def test_runai_passes_revision_by_name():
|
||||
# revision must reach download_safetensors_index_file_from_hf as the
|
||||
# ``revision`` keyword, not the positional ``subfolder`` slot.
|
||||
fake_self = types.SimpleNamespace(
|
||||
load_config=types.SimpleNamespace(download_dir="/cache", ignore_patterns=[])
|
||||
)
|
||||
with (
|
||||
patch.object(rsl, "is_runai_obj_uri", return_value=False),
|
||||
patch.object(rsl, "download_weights_from_hf", return_value="/folder"),
|
||||
patch.object(
|
||||
rsl, "list_safetensors", return_value=["/folder/model.safetensors"]
|
||||
),
|
||||
patch.object(rsl, "download_safetensors_index_file_from_hf") as mock_idx,
|
||||
):
|
||||
rsl.RunaiModelStreamerLoader._prepare_weights(fake_self, "org/model", "myrev")
|
||||
|
||||
mock_idx.assert_called_once()
|
||||
assert mock_idx.call_args.kwargs.get("revision") == "myrev"
|
||||
assert "myrev" not in mock_idx.call_args.args
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
Run `pytest tests/quantization/test_bitsandbytes.py`.
|
||||
"""
|
||||
|
||||
import types
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from packaging.version import Version
|
||||
from transformers import BitsAndBytesConfig
|
||||
from transformers import __version__ as TRANSFORMERS_VERSION
|
||||
|
||||
from tests.quantization.utils import is_quant_method_supported
|
||||
from vllm.model_executor.model_loader import bitsandbytes_loader as bnb
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
from ...utils import compare_two_settings, multi_gpu_test
|
||||
@@ -300,3 +304,27 @@ def validate_generated_texts(
|
||||
f"HF Output: '{hf_str}'\n"
|
||||
f"vLLM Output: '{vllm_str}'"
|
||||
)
|
||||
|
||||
|
||||
def test_bitsandbytes_passes_revision_by_name():
|
||||
# revision must reach download_safetensors_index_file_from_hf as the
|
||||
# ``revision`` keyword, not a positional slot.
|
||||
fake_self = types.SimpleNamespace(
|
||||
load_config=types.SimpleNamespace(download_dir="/cache"),
|
||||
_get_weight_files=MagicMock(
|
||||
return_value=("/folder", ["/folder/model.safetensors"], "*.safetensors")
|
||||
),
|
||||
)
|
||||
with (
|
||||
patch.object(bnb, "download_safetensors_index_file_from_hf") as mock_idx,
|
||||
patch.object(
|
||||
bnb,
|
||||
"filter_duplicate_safetensors_files",
|
||||
return_value=["/folder/model.safetensors"],
|
||||
),
|
||||
):
|
||||
bnb.BitsAndBytesModelLoader._prepare_weights(fake_self, "org/model", "myrev")
|
||||
|
||||
mock_idx.assert_called_once()
|
||||
assert mock_idx.call_args.kwargs.get("revision") == "myrev"
|
||||
assert "myrev" not in mock_idx.call_args.args
|
||||
|
||||
@@ -140,8 +140,8 @@ class BitsAndBytesModelLoader(BaseModelLoader):
|
||||
download_safetensors_index_file_from_hf(
|
||||
model_name_or_path,
|
||||
index_file,
|
||||
self.load_config.download_dir,
|
||||
revision,
|
||||
cache_dir=self.load_config.download_dir,
|
||||
revision=revision,
|
||||
)
|
||||
hf_weights_files = filter_duplicate_safetensors_files(
|
||||
hf_weights_files, hf_folder, index_file
|
||||
|
||||
@@ -70,7 +70,10 @@ class RunaiModelStreamerLoader(BaseModelLoader):
|
||||
|
||||
if not is_local and not is_object_storage_path:
|
||||
download_safetensors_index_file_from_hf(
|
||||
model_name_or_path, index_file, self.load_config.download_dir, revision
|
||||
model_name_or_path,
|
||||
index_file,
|
||||
cache_dir=self.load_config.download_dir,
|
||||
revision=revision,
|
||||
)
|
||||
|
||||
if not hf_weights_files:
|
||||
|
||||
Reference in New Issue
Block a user