test_cpu_offload.py 3.21 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
10
11
12
13
14
15


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


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


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


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