test_full_graph.py 1.23 KB
Newer Older
1
2
3
4
import os

import pytest

5
6
7
8
from vllm.utils import cuda_device_count_stateless

from ..utils import fork_new_process_for_each_test

9
10

@pytest.mark.parametrize("model", ["meta-llama/Meta-Llama-3-8B"])
11
12
13
14
15
16
17
18
@pytest.mark.parametrize("tp_size", [1, 2])
@fork_new_process_for_each_test
def test_full_graph(model, tp_size):

    # Skip the test if there are not enough CUDA devices.
    if cuda_device_count_stateless() < tp_size:
        pytest.skip("Not enough CUDA devices for the test.")

19
    # make sure these models can be captured in full graph mode
20
21
    if "VLLM_TEST_DYNAMO_GRAPH_CAPTURE" not in os.environ:
        os.environ["VLLM_TEST_DYNAMO_GRAPH_CAPTURE"] = "1"
22
23
24
25
26
27
28
29
30

    from vllm import LLM, SamplingParams
    prompts = [
        "Hello, my name is",
        "The president of the United States is",
        "The capital of France is",
        "The future of AI is",
    ]
    sampling_params = SamplingParams(temperature=0)
31
    llm = LLM(model=model, enforce_eager=True, tensor_parallel_size=tp_size)
32
33
34
35
36
37
38
39

    outputs = llm.generate(prompts, sampling_params)

    # Print the outputs.
    for output in outputs:
        prompt = output.prompt
        generated_text = output.outputs[0].text
        print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")