A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 10, 19:00 UTC
[CI/Build] Revive skipped reward models e2e test (#31665)
Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
Isotr0py committed
Jan 5, 2026 at 10:33 UTC
367856de1402dd61f7e9a29e4165b9ba6eb9dd58
2 files changed
+64
-4
tests/models/fixtures/qwen2_5_math_prm_reward_step.json
new
+1
@@ -0,0 +1 @@
1
+[[[0.0006361007690429688, 0.99951171875], [0.81884765625, 0.1812744140625], [0.025543212890625, 0.974609375], [0.0004382133483886719, 0.99951171875]]]
\ No newline at end of file
tests/models/language/pooling/test_reward.py
+63
-4
@@ -1,5 +1,7 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+import json
4
+from typing import TYPE_CHECKING
5
6
import pytest
7
import torch
@@ -9,7 +11,18 @@ from transformers import AutoModel
11
from vllm.platforms import current_platform
12
13
from ....conftest import HfRunner
12
-from ...utils import check_transformers_version
14
+from ....utils import VLLM_PATH
15
+from ...registry import HF_EXAMPLE_MODELS
16
+
17
+if TYPE_CHECKING:
18
+ from _typeshed import StrPath
19
+
20
+
21
+FIXTURES_PATH = VLLM_PATH / "tests/models/fixtures"
22
+assert FIXTURES_PATH.exists()
23
+FIXTURE_REWARD_RESULT = {
24
+ "Qwen/Qwen2.5-Math-PRM-7B": FIXTURES_PATH / "qwen2_5_math_prm_reward_step.json",
25
+}
26
27
28
@pytest.fixture
@@ -60,6 +73,16 @@ def step_reward_patch_hf_model(hf_model: HfRunner):
73
return hf_model
74
75
76
+def dump_reward_outputs(outputs: list[list[float]], filename: "StrPath"):
77
+ with open(filename, "w", encoding="utf-8") as f:
78
+ json.dump(outputs, f)
79
+
80
+
81
+def load_reward_outputs(filename: "StrPath") -> list[list[float]]:
82
+ with open(filename, encoding="utf-8") as f:
83
+ return json.load(f)
84
+
85
+
86
@pytest.mark.parametrize(
87
"model",
88
[
@@ -77,9 +100,8 @@ def test_prm_models(
100
model: str,
101
dtype: str,
102
) -> None:
80
- check_transformers_version(
81
- "Qwen/Qwen2.5-Math-PRM-7B", max_transformers_version="4.53.2"
82
- )
103
+ model_info = HF_EXAMPLE_MODELS.find_hf_info(model)
104
+ model_info.check_transformers_version(on_fail="skip")
105
106
if current_platform.is_cpu():
107
pytest.skip("CPU only supports V1")
@@ -91,9 +113,46 @@ def test_prm_models(
113
hf_model = step_reward_patch_hf_model(hf_model)
114
hf_outputs = hf_model.reward(math_step_prompts)
115
116
+ dump_reward_outputs(
117
+ hf_outputs,
118
+ FIXTURE_REWARD_RESULT[model],
119
+ )
120
+
121
# check logits difference
122
for hf_output, vllm_output in zip(hf_outputs, vllm_outputs):
123
hf_output = torch.tensor(hf_output).float()
124
vllm_output = torch.tensor(vllm_output).float()
125
126
assert torch.allclose(hf_output, vllm_output, 1.5e-2)
127
+
128
+
129
+@pytest.mark.parametrize(
130
+ "model",
131
+ [
132
+ pytest.param(
133
+ "Qwen/Qwen2.5-Math-PRM-7B",
134
+ marks=[pytest.mark.core_model, pytest.mark.cpu_model],
135
+ ),
136
+ ],
137
+)
138
+@pytest.mark.parametrize("dtype", ["half"])
139
+def test_prm_models_with_golden_outputs(
140
+ vllm_runner,
141
+ math_step_prompts,
142
+ model: str,
143
+ dtype: str,
144
+) -> None:
145
+ if not FIXTURE_REWARD_RESULT.get(model):
146
+ pytest.skip(f"No available golden outputs for {model}.")
147
+
148
+ with vllm_runner(model, max_model_len=1024, dtype=dtype) as vllm_model:
149
+ vllm_outputs = vllm_model.reward(math_step_prompts)
150
+
151
+ golden_outputs = load_reward_outputs(FIXTURE_REWARD_RESULT[model])
152
+
153
+ # check logits difference
154
+ for golden_output, vllm_output in zip(golden_outputs, vllm_outputs):
155
+ golden_output = torch.tensor(golden_output).float()
156
+ vllm_output = torch.tensor(vllm_output).float()
157
+
158
+ assert torch.allclose(golden_output, vllm_output, 1.5e-2)