test_cpu_offload.py 3.29 KB
Newer Older
1
2
3
4
# Expanded quantized model tests for CPU offloading
# Base tests: tests/basic_correctness/test_cpu_offload.py

import pytest
5
import os
6
7
8

from tests.quantization.utils import is_quant_method_supported

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


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


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


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


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