Skip to content

Commit b2c6c41

Browse files
authored
[CI] Relocate server test cases from ci_use directory to e2e (#4608)
1 parent 31180a6 commit b2c6c41

5 files changed

Lines changed: 99 additions & 0 deletions

File tree

File renamed without changes.

tests/ci_use/ERNIE_0dot3B/test_ernie_03b_pd.py renamed to tests/e2e/test_ernie_03b_pd.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import json
1616
import os
17+
import shutil
1718
import signal
1819
import socket
1920
import subprocess
@@ -95,6 +96,10 @@ def setup_and_run_server():
9596
print("Pre-test port cleanup...")
9697
clean_ports()
9798

99+
print("log dir clean ")
100+
if os.path.exists("log") and os.path.isdir("log"):
101+
shutil.rmtree("log")
102+
98103
base_path = os.getenv("MODEL_PATH")
99104
if base_path:
100105
model_path = os.path.join(base_path, "ERNIE-4.5-0.3B-Paddle")

tests/ci_use/EB_Lite/test_ernie_21b_mtp.py renamed to tests/e2e/test_ernie_21b_mtp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ def setup_and_run_server():
9292
print("Pre-test port cleanup...")
9393
clean_ports()
9494

95+
print("log dir clean ")
96+
if os.path.exists("log") and os.path.isdir("log"):
97+
shutil.rmtree("log")
98+
9599
base_path = os.getenv("MODEL_PATH")
96100
if base_path:
97101
model_path = os.path.join(base_path, "ernie-4_5-21b-a3b-bf16-paddle")

tests/e2e/utils/rollout_model.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import argparse
16+
17+
from paddleformers.trl.llm_utils import init_dist_env
18+
19+
from fastdeploy.rl.rollout_config import RolloutModelConfig
20+
from fastdeploy.rl.rollout_model import RolloutModel
21+
22+
_, ranks = init_dist_env()
23+
24+
parser = argparse.ArgumentParser()
25+
parser.add_argument("--model_path", type=str, required=True, help="Path to the model directory")
26+
parser.add_argument("--baseline_path", type=str, required=True, help="Path to the baseline path")
27+
parser.add_argument("--quantization", type=str, default=None, help="Quantization")
28+
parser.add_argument("--enable_mm", action="store_true", required=False, help="Flags to enable multi-modal model")
29+
args = parser.parse_args()
30+
31+
# base result
32+
model_path = args.model_path
33+
34+
# Usage example:
35+
init_kwargs = {
36+
"model_name_or_path": model_path,
37+
"max_model_len": 32768,
38+
"tensor_parallel_size": ranks,
39+
"dynamic_load_weight": True,
40+
"load_strategy": "ipc_snapshot",
41+
"quantization": args.quantization,
42+
}
43+
if args.enable_mm:
44+
init_kwargs["enable_mm"] = True
45+
46+
47+
rollout_config = RolloutModelConfig(**init_kwargs)
48+
actor_eval_model = RolloutModel(rollout_config)
49+
50+
content = "".join(
51+
sorted(
52+
[f"{k}\n" for k, v in actor_eval_model.state_dict().items()]
53+
+ [f"{k}:{v}\n" for k, v in actor_eval_model.get_name_mappings_to_training().items()]
54+
)
55+
)
56+
57+
58+
def compare_strings_line_by_line(a: str, b: str) -> bool:
59+
"""
60+
Compare two multiline strings line by line.
61+
62+
Returns:
63+
True if all lines match exactly in order and content.
64+
False if any line differs or the number of lines is not equal.
65+
"""
66+
a_lines = a.splitlines()
67+
b_lines = b.splitlines()
68+
69+
if len(a_lines) != len(b_lines):
70+
print(f"❌ Mismatch in number of lines: expected {len(a_lines)}, but got {len(b_lines)}.")
71+
return False
72+
73+
for i, (line_a, line_b) in enumerate(zip(a_lines, b_lines)):
74+
if line_a != line_b:
75+
print(f"❌ Difference found on line {i + 1}:")
76+
print(f" Expected: {repr(line_a)}")
77+
print(f" Actual : {repr(line_b)}")
78+
return False
79+
80+
print("✅ All lines match exactly.")
81+
return True
82+
83+
84+
with open(args.baseline_path, "r", encoding="utf-8") as f:
85+
baseline = f.read()
86+
assert compare_strings_line_by_line(baseline, content), (
87+
"In the unittest of RL scenario, your modification "
88+
"caused inconsistency in the content before and after. Please fix it. "
89+
"Can request assistance from yuanlehome or gzy19990617 (github id)."
90+
)

0 commit comments

Comments
 (0)