| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | # Expanded quantized model tests for CPU offloading |
| 5 | # Base tests: tests/basic_correctness/cpu_offload/test_cpu_offload.py |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from tests.quantization.utils import is_quant_method_supported |
| 10 | |
| 11 | from ..utils import compare_two_settings |
| 12 | |
| 13 | |
| 14 | @pytest.mark.skipif( |
| 15 | not is_quant_method_supported("fp8"), |
| 16 | reason="fp8 is not supported on this GPU type.", |
| 17 | ) |
| 18 | def test_cpu_offload_fp8(): |
| 19 | # Test loading a quantized checkpoint |
| 20 | compare_two_settings( |
| 21 | "neuralmagic/Qwen2-1.5B-Instruct-FP8", |
| 22 | ["--enforce_eager"], |
| 23 | ["--enforce_eager", "--cpu-offload-gb", "1"], |
| 24 | max_wait_seconds=480, |
| 25 | ) |
| 26 | |
| 27 | |
| 28 | @pytest.mark.skipif( |
| 29 | not is_quant_method_supported("gptq_marlin"), |
| 30 | reason="gptq_marlin is not supported on this GPU type.", |
| 31 | ) |
| 32 | def test_cpu_offload_gptq(monkeypatch): |
| 33 | # This quant method is sensitive to dummy weights, so we force real weights |
| 34 | monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto") |
| 35 | # Test GPTQ Marlin |
| 36 | compare_two_settings( |
| 37 | "Qwen/Qwen2-1.5B-Instruct-GPTQ-Int4", |
| 38 | ["--enforce_eager"], |
| 39 | ["--enforce_eager", "--cpu-offload-gb", "1"], |
| 40 | max_wait_seconds=480, |
| 41 | ) |
| 42 | |
| 43 | |
| 44 | @pytest.mark.skipif( |
| 45 | not is_quant_method_supported("awq_marlin"), |
| 46 | reason="awq_marlin is not supported on this GPU type.", |
| 47 | ) |
| 48 | def test_cpu_offload_awq(monkeypatch): |
| 49 | # This quant method is sensitive to dummy weights, so we force real weights |
| 50 | monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto") |
| 51 | # Test AWQ Marlin |
| 52 | compare_two_settings( |
| 53 | "Qwen/Qwen2-1.5B-Instruct-AWQ", |
| 54 | ["--enforce_eager"], |
| 55 | ["--enforce_eager", "--cpu-offload-gb", "1"], |
| 56 | max_wait_seconds=480, |
| 57 | ) |
| 58 | |
| 59 | |
| 60 | @pytest.mark.skipif( |
| 61 | not is_quant_method_supported("gptq_marlin"), |
| 62 | reason="gptq_marlin is not supported on this GPU type.", |
| 63 | ) |
| 64 | def test_cpu_offload_compressed_tensors(monkeypatch): |
| 65 | # This quant method is sensitive to dummy weights, so we force real weights |
| 66 | monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto") |
| 67 | # Test wNa16 |
| 68 | compare_two_settings( |
| 69 | "nm-testing/Qwen1.5-MoE-A2.7B-Chat-quantized.w4a16", |
| 70 | ["--enforce_eager"], |
| 71 | ["--enforce_eager", "--cpu-offload-gb", "1"], |
| 72 | max_wait_seconds=480, |
| 73 | include_seeded_sampling=False, |
| 74 | ) |