Skip to content

Commit 5511130

Browse files
authored
update (#3165)
1 parent 1ea7dcb commit 5511130

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

framework/ServeTest/test_ci.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def test_picture_diff():
175175
result = "".join([x['choices'][0]['delta']['content'] for x in chunks])
176176
except Exception as e:
177177
print(f"解析失败: {e}")
178+
print("chunks:", chunks)
178179
# 打印log/worklog.0
179180
if os.path.exists('log/workerlog.0'):
180181
with open('log/workerlog.0', 'r') as file:

framework/ServeTest/test_ci_t2i.py

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,42 @@ def send_request(url, payload, timeout=600):
3939
return None
4040

4141

42+
def recursive_diff(a, b, path=""):
43+
"""
44+
递归比较两个不规则嵌套数组(list)
45+
- a, b: 任意层嵌套的列表
46+
- path: 当前路径标识
47+
返回: 差异信息列表
48+
"""
49+
diffs = []
50+
51+
# 两者都为 list,继续深入比较
52+
if isinstance(a, list) and isinstance(b, list):
53+
if len(a) != len(b):
54+
diffs.append({
55+
"path": path,
56+
"msg": f"长度不同: {len(a)} vs {len(b)}",
57+
"a": a,
58+
"b": b
59+
})
60+
# 继续对比重叠部分
61+
for i in range(min(len(a), len(b))):
62+
diffs += recursive_diff(a[i], b[i], f"{path}[{i}]")
63+
else:
64+
for i in range(len(a)):
65+
diffs += recursive_diff(a[i], b[i], f"{path}[{i}]")
66+
67+
else:
68+
# 不是列表,直接比较值
69+
if a != b:
70+
diffs.append({
71+
"path": path,
72+
"msg": f"值不同: {a} vs {b}"
73+
})
74+
75+
return diffs
76+
77+
4278
def test_text_to_image_diff():
4379
payload = {
4480
"model": "null",
@@ -52,7 +88,7 @@ def test_text_to_image_diff():
5288
"stream_options": {"include_usage": True, "continuous_usage_stats": True},
5389
"temperature": 0.7,
5490
"seed": 22,
55-
"top_p": 1.0,
91+
"top_p": 0,
5692
"stop": ["停止生成"],
5793
"disable_chat_template": False,
5894
"return_token_ids": True,
@@ -88,7 +124,7 @@ def test_text_to_image_diff():
88124
res = multimodal_content[0].get("text", None)
89125
# print(res, end="", flush=True)
90126
result += res
91-
# print("#####completion_token_ids:\n", completion_token_ids)
127+
print("#####completion_token_ids:\n", completion_token_ids)
92128
print("#####url:\n", url)
93129
print("#####result:\n", result)
94130

@@ -101,12 +137,30 @@ def test_text_to_image_diff():
101137
print("################# workerlog.0 ##################", log_contents)
102138
pytest.fail(f"解析失败: {e}")
103139

104-
# with open("./baseline_t2i.txt", "w", encoding="utf-8") as f:
105-
# f.writelines(result)
140+
# with open("./baseline_t2i_tokens.txt", "w", encoding="utf-8") as f:
141+
# json.dump(completion_token_ids, f)
106142

107143
with open("./baseline_t2i.txt", "r", encoding="utf-8") as f:
108144
baseline = f.read()
109145

146+
with open("/cot/baseline_t2i_tokens.txt", "r", encoding="utf-8") as f:
147+
baseline_tokens = json.load(f)
148+
149+
diffs = recursive_diff(baseline_tokens, completion_token_ids)
150+
151+
if not diffs:
152+
print("✅ completion_token_ids 完全一致")
153+
return
154+
155+
print(f"❌ 共发现 {len(diffs)} 处差异:")
156+
for i, d in enumerate(diffs[:10]):
157+
print(f"\n[{i + 1}] 路径: {d['path']}")
158+
print(f"👉 {d['msg']}")
159+
if "a" in d and isinstance(d["a"], list):
160+
print(f"baseline 子数组: {d['a']}")
161+
if "b" in d and isinstance(d["b"], list):
162+
print(f"current 子数组: {d['b']}")
163+
110164
assert result == baseline, f"与baseline存在diff,result: {result}\n baseline: {baseline}"
111165

112166

0 commit comments

Comments
 (0)