test_weight_loading.py 1.4 KB
Newer Older
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3

4
5
import os

6
import pytest
7
8
import torch

9
10
from vllm.platforms import current_platform

11
12
13
14
15
MAX_MODEL_LEN = 1024
MODEL_NAME = os.environ.get("MODEL_NAME",
                            "robertgshaw2/zephyr-7b-beta-channelwise-gptq")
REVISION = os.environ.get("REVISION", "main")
QUANTIZATION = os.environ.get("QUANTIZATION", "gptq_marlin")
16
MIN_CAPABILITY = os.environ.get("MIN_CAPABILITY", "80")
17
18


19
20
21
@pytest.mark.skipif(
    MODEL_NAME == "casperhansen/deepseek-coder-v2-instruct-awq",
    reason="OOM in the CI")
22
23
24
@pytest.mark.skipif(
    not current_platform.has_device_capability(int(MIN_CAPABILITY)),
    reason="Current system does not have minimum capability.")
25
def test_weight_loading(vllm_runner):
26
27
28
    """
    Test parameter weight loading with tp>1.
    """
29
30
31
32

    # MoE models need fp16.
    NEEDS_FP16 = (QUANTIZATION == "gptq" or MODEL_NAME
                  == "nm-testing/test-w4a16-mixtral-actorder-group")
33
34
35
    with vllm_runner(
            model_name=MODEL_NAME,
            revision=REVISION,
36
            dtype=torch.half if NEEDS_FP16 else "auto",
37
38
39
            quantization=None if QUANTIZATION == "None" else QUANTIZATION,
            max_model_len=MAX_MODEL_LEN,
            tensor_parallel_size=2) as model:
40
41
42
43

        output = model.generate_greedy("Hello world!", max_tokens=20)
        print(output)
        assert output