### What this PR does / why we need it?
| File Path |
| :--- |
| `tests/e2e/singlecard/compile/backend.py` |
| `tests/e2e/singlecard/compile/test_graphex_norm_quant_fusion.py` |
| `tests/e2e/singlecard/compile/test_graphex_qknorm_rope_fusion.py` |
| `tests/e2e/singlecard/compile/test_norm_quant_fusion.py` |
| `tests/e2e/singlecard/model_runner_v2/test_basic.py` |
| `tests/e2e/singlecard/test_aclgraph_accuracy.py` |
| `tests/e2e/singlecard/test_aclgraph_batch_invariant.py` |
| `tests/e2e/singlecard/test_aclgraph_mem.py` |
| `tests/e2e/singlecard/test_async_scheduling.py` |
| `tests/e2e/singlecard/test_auto_fit_max_mode_len.py` |
| `tests/e2e/singlecard/test_batch_invariant.py` |
| `tests/e2e/singlecard/test_camem.py` |
| `tests/e2e/singlecard/test_completion_with_prompt_embeds.py` |
| `tests/e2e/singlecard/test_cpu_offloading.py` |
| `tests/e2e/singlecard/test_guided_decoding.py` |
| `tests/e2e/singlecard/test_ilama_lora.py` |
| `tests/e2e/singlecard/test_llama32_lora.py` |
| `tests/e2e/singlecard/test_models.py` |
| `tests/e2e/singlecard/test_multistream_overlap_shared_expert.py` |
| `tests/e2e/singlecard/test_quantization.py` |
| `tests/e2e/singlecard/test_qwen3_multi_loras.py` |
| `tests/e2e/singlecard/test_sampler.py` |
| `tests/e2e/singlecard/test_vlm.py` |
| `tests/e2e/singlecard/test_xlite.py` |
| `tests/e2e/singlecard/utils.py` |
### Does this PR introduce _any_ user-facing change?
### How was this patch tested?
- vLLM version: v0.15.0
- vLLM main:
9562912cea
---------
Signed-off-by: MrZ20 <2609716663@qq.com>
82 lines
3.2 KiB
Python
82 lines
3.2 KiB
Python
from dataclasses import dataclass, field
|
|
|
|
from vllm import SamplingParams
|
|
|
|
from tests.e2e.conftest import VllmRunner
|
|
from tests.e2e.model_utils import check_outputs_equal
|
|
|
|
PROMPTS_SHORT = [
|
|
"Hello, my name is",
|
|
"The president of the United States is",
|
|
"The capital of France is",
|
|
"The future of AI is",
|
|
]
|
|
|
|
# NOTE: Randomly fill the prompt with the requested amount for
|
|
# the specified capture shape to prevent accuracy issues caused by padding
|
|
PROMPTS_LONG = [
|
|
(
|
|
"Solve the following math problem step by step."
|
|
"The last line of your response should be of the form Answer: "
|
|
"$Answer (without quotes) where $Answer is the answer to the problem.\n\n"
|
|
"In triangle $ABC$, $\\sin \\angle A = \\frac{4}{5}$ and $\\angle A < 90^\\circ$. Let $D$"
|
|
"be a point outside triangle $ABC$ such that $\\angle BAD = \\angle DAC$,"
|
|
"$\\angle BDC = 90^\\circ$. Suppose $AD = 1$ and $\\frac{BD}{CD} = \\frac{3}{2}$."
|
|
"If $AB + AC$ can be expressed in the form $\\frac{a\\sqrt{b}}{c}$,"
|
|
"where $a, b, c$ are pairwise relatively prime integers, find $a + b + c$."
|
|
),
|
|
(
|
|
"Solve the following math problem step by step."
|
|
"The last line of your response should be of the form Answer: "
|
|
"$Answer (without quotes) where $Answer is the answer to the problem.\n\n"
|
|
"Let $ABCD$ be a unit square in the plane. Points $X$ and $Y$ are chosen"
|
|
"independently and uniformly at random on the perimeter of $ABCD$."
|
|
"If the expected value of the area of triangle $\\triangle AXY$"
|
|
"can be expressed as $\\frac{m}{n}$, for relatively prime positive"
|
|
"integers $m$ and $n$, compute $m+n$."
|
|
),
|
|
(
|
|
"Solve the following math problem step by step."
|
|
"The last line of your response should be of the form Answer: "
|
|
"$Answer (without quotes) where $Answer is the answer to the problem.\n\n"
|
|
"Let $a, b, c$ be distinct numbers such that the equations $x^2 + ax + 1 = 0$"
|
|
"and $x^2 + bx + c = 0$ have a common real root, and the equations $x^2 + x + a = 0$"
|
|
"and $x^2 + cx + b = 0$ also have a common real root."
|
|
"Compute the sum $a + b + c$."
|
|
),
|
|
]
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class LLMTestCase:
|
|
model: str
|
|
prompts: list[str]
|
|
golden_answers: list[str]
|
|
quantization: str | None = None
|
|
sampling_params: SamplingParams = field(
|
|
default_factory=lambda: SamplingParams(
|
|
max_tokens=32,
|
|
temperature=0.0,
|
|
top_p=1.0,
|
|
top_k=0,
|
|
n=1,
|
|
)
|
|
)
|
|
|
|
|
|
def gen_and_valid(runner_kwargs: dict, prompts: list[str], sampling_params: SamplingParams, golden_answers: list[str]):
|
|
with VllmRunner(**runner_kwargs) as runner:
|
|
vllm_aclgraph_outputs = runner.model.generate(prompts=prompts, sampling_params=sampling_params)
|
|
outputs_gen = []
|
|
for output in vllm_aclgraph_outputs:
|
|
outputs_gen.append(([output.outputs[0].index], output.outputs[0].text))
|
|
|
|
output_origin = [([0], answer) for answer in golden_answers]
|
|
|
|
check_outputs_equal(
|
|
outputs_0_lst=output_origin,
|
|
outputs_1_lst=outputs_gen,
|
|
name_0="output_origin",
|
|
name_1="outputs_gen",
|
|
)
|