verify-fixes.py
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""验三处修复:eta 跟帧数走、队列满返回 429、派发仍然分散。
跑之前要把调度层的 H3_MAX_QUEUE 调成 1,否则填满默认上限 4 要投 16 条、跑 6 分半。
用 22 帧的短任务,路由和限流逻辑与长任务完全一样。
"""
import json, urllib.request, urllib.error
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
GW = "http://127.0.0.1:8000"
CASES = [
("832x480x124f 4步(基准,实测 767s)", {"width": 832, "height": 480, "frames": 124, "steps": 4}),
("1280x736x56f 4步(实测 736s)", {"width": 1280, "height": 736, "frames": 56, "steps": 4}),
("832x480x22f 4步(实测 96s)", {"width": 832, "height": 480, "frames": 22, "steps": 4}),
]
SPEC = {"prompt": "一只橘猫趴在洒满阳光的窗台上,慢慢眨眼", "turbo": True}
def post(body):
req = urllib.request.Request(GW + "/v1/videos", data=json.dumps(body).encode(),
headers={"Content-Type": "application/json"})
try:
with urllib.request.urlopen(req, timeout=60) as r:
return r.status, json.load(r)
except urllib.error.HTTPError as e:
return e.code, e.read().decode()
print("=== 1. eta 是否跟帧数走(改之前三档全报 691)")
results = [post(dict(SPEC, seed=200 + i, **spec)) for i, (_, spec) in enumerate(CASES)]
for (name, _), (code, body) in zip(CASES, results):
print(f" {name:38} -> eta={body['eta_seconds']}s {body['backend'][-4:]}")
print("\n=== 2. 队列满是否 429(H3_MAX_QUEUE=1,前 3 条已占 3 张卡)")
with ThreadPoolExecutor(max_workers=4) as pool:
burst = list(pool.map(lambda i: post(dict(SPEC, seed=300 + i, frames=22, steps=4)), range(4)))
for i, (code, body) in enumerate(burst):
detail = body if isinstance(body, str) else f"{body['backend'][-4:]} queue_ahead={body['queue_ahead']}"
print(f" #{i} HTTP {code} {detail}")
accepted = [b for c, b in results + burst if c == 202]
print(f"\n=== 3. 派发分布: {dict(Counter(b['backend'][-4:] for b in accepted))}")
print(f"接受 {len(accepted)} 条,拒绝 {len(results) + len(burst) - len(accepted)} 条")