| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | from types import SimpleNamespace |
| 4 | from unittest.mock import Mock |
| 5 | |
| 6 | import pytest |
| 7 | import torch |
| 8 | |
| 9 | from vllm.config.vllm import VllmConfig |
| 10 | |
| 11 | pytestmark = [pytest.mark.cpu_test, pytest.mark.skip_global_cleanup] |
| 12 | |
| 13 | |
| 14 | def test_quantization_config_forwards_model_revision(monkeypatch: pytest.MonkeyPatch): |
| 15 | quant_config = Mock() |
| 16 | quant_config.get_min_capability.return_value = 0 |
| 17 | quant_config.get_supported_act_dtypes.return_value = [torch.float32] |
| 18 | model_config = SimpleNamespace( |
| 19 | quantization="auto_gptq", |
| 20 | model="repo/model", |
| 21 | hf_config=object(), |
| 22 | dtype=torch.float32, |
| 23 | revision="pinned-revision", |
| 24 | ) |
| 25 | |
| 26 | monkeypatch.setattr( |
| 27 | "vllm.model_executor.model_loader.weight_utils.get_quant_config", |
| 28 | lambda model_config, load_config: quant_config, |
| 29 | ) |
| 30 | monkeypatch.setattr( |
| 31 | "vllm.platforms.current_platform.get_device_capability", lambda: None |
| 32 | ) |
| 33 | |
| 34 | VllmConfig._get_quantization_config(model_config, SimpleNamespace()) |
| 35 | |
| 36 | quant_config.maybe_update_config.assert_called_once_with( |
| 37 | "repo/model", |
| 38 | hf_config=model_config.hf_config, |
| 39 | revision="pinned-revision", |
| 40 | ) |