test_cpu_offload.py 3.33 KB
Newer Older
1
2
# SPDX-License-Identifier: Apache-2.0

3
4
5
6
# Expanded quantized model tests for CPU offloading
# Base tests: tests/basic_correctness/test_cpu_offload.py

import pytest
7
import os
8
9
10

from tests.quantization.utils import is_quant_method_supported

11
from ..utils import compare_two_settings, models_path_prefix
zhuwenwen's avatar
zhuwenwen committed
12
from vllm.utils import is_hip
13
14


zhuwenwen's avatar
zhuwenwen committed
15
@pytest.mark.skipif(not is_quant_method_supported("fp8") or is_hip(),
16
17
18
                    reason="fp8 is not supported on this GPU type.")
def test_cpu_offload_fp8():
    # Test quantization of an unquantized checkpoint
zhuwenwen's avatar
zhuwenwen committed
19
    compare_two_settings(os.path.join(models_path_prefix, "meta-llama/Llama-3.2-1B-Instruct"),
20
                         ["--quantization", "fp8"],
21
                         ["--quantization", "fp8", "--cpu-offload-gb", "1"],
22
                         max_wait_seconds=480)
23
    # Test loading a quantized checkpoint
zhuwenwen's avatar
zhuwenwen committed
24
25
26
    # compare_two_settings(os.path.join(models_path_prefix, "neuralmagic/Qwen2-1.5B-Instruct-FP8"), [],
    #                      ["--cpu-offload-gb", "1"],
    #                      max_wait_seconds=480)
27
28


zhuwenwen's avatar
zhuwenwen committed
29
@pytest.mark.skipif(not is_quant_method_supported("gptq_marlin") or is_hip(),
30
31
32
                    reason="gptq_marlin is not supported on this GPU type.")
def test_cpu_offload_gptq():
    # Test GPTQ Marlin
33
    compare_two_settings(os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-GPTQ-Int4"), [],
34
35
                         ["--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
36
    # Test GPTQ
37
    compare_two_settings(os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-GPTQ-Int4"),
38
                         ["--quantization", "gptq"],
39
40
                         ["--quantization", "gptq", "--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
41
42


zhuwenwen's avatar
zhuwenwen committed
43
@pytest.mark.skipif(not is_quant_method_supported("awq_marlin") or is_hip(),
44
45
46
                    reason="awq_marlin is not supported on this GPU type.")
def test_cpu_offload_awq():
    # Test AWQ Marlin
47
    compare_two_settings(os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-AWQ"), [],
48
49
                         ["--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
50
    # Test AWQ
51
    compare_two_settings(os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-AWQ"),
52
                         ["--quantization", "awq"],
53
54
                         ["--quantization", "awq", "--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
55
56


zhuwenwen's avatar
zhuwenwen committed
57
@pytest.mark.skipif(not is_quant_method_supported("gptq_marlin") or is_hip(),
58
59
60
                    reason="gptq_marlin is not supported on this GPU type.")
def test_cpu_offload_compressed_tensors():
    # Test wNa16
61
    compare_two_settings(os.path.join(models_path_prefix, "nm-testing/tinyllama-oneshot-w4a16-channel-v2"), [],
62
63
                         ["--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
64
    # Test w4a16_marlin24
65
    compare_two_settings(os.path.join(models_path_prefix, "nm-testing/llama7b-one-shot-2_4-w4a16-marlin24-t"),
66
67
                         [], ["--cpu-offload-gb", "1"],
                         max_wait_seconds=480)
68
69
    # Test w8a8
    compare_two_settings(
70
        os.path.join(models_path_prefix, "nm-testing/tinyllama-oneshot-w8w8-test-static-shape-change"), [],
71
72
        ["--cpu-offload-gb", "1"],
        max_wait_seconds=480)