main
py 42 lines 1.81 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 # flake8: noqa
4 """Tests Quark mxfp4 models against ground truth generation"""
5
6 import pytest
7
8 from vllm import LLM, SamplingParams
9
10 MODELS = ["amd/Llama-2-7b-chat-hf-wmxfp4-amxfp4-kvfp8-scale-uint8"]
11
12 EXPECTED_STRS_MAP = {
13 "amd/Llama-2-7b-chat-hf-wmxfp4-amxfp4-kvfp8-scale-uint8": [
14 "\n### Key Features\n\n* **High-throughput Inference**: vLL",
15 "\nArtificial intelligence (AI) has evolved significantly since its inception in the 1",
16 "Artificial intelligence (AI) and human intelligence (HI) are two distinct concepts that have been",
17 "A neural network is a machine learning model inspired by the structure of the human brain. It consists of",
18 "\nTitle: The Dreaming Robot\n\nAs the sun set on the bustling metropol",
19 "\nThe COVID-19 pandemic has had a profound impact on global economic structures and business",
20 "The Mona Lisa painting, created by Leonardo da Vinci in the early 16th",
21 " everybody knows this proverbial saying, but did you know that it's not entirely accurate?",
22 ]
23 }
24
25
26 @pytest.mark.skip(reason="Model to be released in the future")
27 @pytest.mark.quant_model
28 @pytest.mark.parametrize("model_name", MODELS)
29 def test_models(example_prompts, model_name) -> None:
30 sampling_params = SamplingParams(max_tokens=20, temperature=0)
31 llm = LLM(
32 model=model_name,
33 kv_cache_dtype="fp8",
34 quantization="quark",
35 )
36 outputs = llm.generate(example_prompts, sampling_params)
37 for i, output in enumerate(outputs):
38 output_str = output.outputs[0].text
39 expected_str = EXPECTED_STRS_MAP[model_name][i]
40 assert expected_str == output_str, (
41 f"Expected: {expected_str!r}\nvLLM: {output_str!r}"
42 )