test_cpu_offload.py 2.44 KB
Newer Older
1
# SPDX-License-Identifier: Apache-2.0
zhuwenwen's avatar
zhuwenwen committed
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
zhuwenwen's avatar
zhuwenwen committed
3
4
5
6
7

# Expanded quantized model tests for CPU offloading
# Base tests: tests/basic_correctness/test_cpu_offload.py

import os
zhuwenwen's avatar
zhuwenwen committed
8
import pytest
zhuwenwen's avatar
zhuwenwen committed
9
10
11

from tests.quantization.utils import is_quant_method_supported

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


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


29
30
31
32
@pytest.mark.skipif(
    not is_quant_method_supported("gptq_marlin"),
    reason="gptq_marlin is not supported on this GPU type.",
)
zhuwenwen's avatar
zhuwenwen committed
33
34
def test_cpu_offload_gptq(monkeypatch):
    # This quant method is sensitive to dummy weights, so we force real weights
35
    monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto")
zhuwenwen's avatar
zhuwenwen committed
36
    # Test GPTQ Marlin
37
    compare_two_settings(
38
        os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-GPTQ-Int4"),
39
40
        ["--enforce_eager"],
        ["--enforce_eager", "--cpu-offload-gb", "1"],
41
42
        max_wait_seconds=480,
    )
zhuwenwen's avatar
zhuwenwen committed
43
44


45
46
47
48
@pytest.mark.skipif(
    not is_quant_method_supported("awq_marlin"),
    reason="awq_marlin is not supported on this GPU type.",
)
zhuwenwen's avatar
zhuwenwen committed
49
50
def test_cpu_offload_awq(monkeypatch):
    # This quant method is sensitive to dummy weights, so we force real weights
51
    monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto")
zhuwenwen's avatar
zhuwenwen committed
52
    # Test AWQ Marlin
53
    compare_two_settings(
54
        os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct-AWQ"),
55
56
        ["--enforce_eager"],
        ["--enforce_eager", "--cpu-offload-gb", "1"],
57
58
        max_wait_seconds=480,
    )
zhuwenwen's avatar
zhuwenwen committed
59
60


61
62
63
64
@pytest.mark.skipif(
    not is_quant_method_supported("gptq_marlin"),
    reason="gptq_marlin is not supported on this GPU type.",
)
zhuwenwen's avatar
zhuwenwen committed
65
66
def test_cpu_offload_compressed_tensors(monkeypatch):
    # This quant method is sensitive to dummy weights, so we force real weights
67
    monkeypatch.setenv("VLLM_TEST_FORCE_LOAD_FORMAT", "auto")
zhuwenwen's avatar
zhuwenwen committed
68
69
    # Test wNa16
    compare_two_settings(
70
        os.path.join(models_path_prefix, "nm-testing/Qwen1.5-MoE-A2.7B-Chat-quantized.w4a16"),
71
72
        ["--enforce_eager"],
        ["--enforce_eager", "--cpu-offload-gb", "1"],
73
74
        max_wait_seconds=480,
    )