补充D3基准参数并记录MD002的ROCm升级速度对比

This commit is contained in:
tfarcraw 2026-11-20 16:15:35 +08:00
parent 7d117a1e25
commit 01d7c85f3f
2 changed files with 49 additions and 5 deletions

View File

@ -3,6 +3,37 @@
当前入口是统一的 **Avalonia 跨平台版**,详见 [AVALONIA.md](AVALONIA.md)。
Windows 和 Linux 都编译 `src/SopHelper.Avalonia`;旧 Linux 简化验证版已删除。
## MD002 ROCm 升级速度对比(2026-11-20)
对同一固定版本 d3-nano,对比完整运行环境:旧环境为 PyTorch `2.11.0+rocm7.14.1`,
新环境为 `2.12.0+rocm10.1.0`,不能把差异单独归因于 ROCm。
在 780M 上用同一服务脚本、同一模型、相同 JPEG 字节、相同英文问题及参数,
按旧→新→新→旧顺序串行测试;每阶段每例预热 3 次并排除,计时 10 次。
每环境合计 80 次计时请求,每例 20 次。图片大小和 SHA-256、问题与输出保存在原始报告。
服务端平均耗时(包含图片解码、预处理、模型推理和后处理,不含 HTTP、SSH、模型加载):
| 样例 | ROCm 7.14.1 | ROCm 10.1.0 | 延迟降低 |
| --- | ---: | ---: | ---: |
| 非空盒 | 688.16ms | 533.91ms | 22.41% |
| 空盒 | 646.46ms | 524.98ms | 18.79% |
| 手持物体 | 764.12ms | 642.94ms | 15.86% |
| 物体颜色 | 734.07ms | 609.17ms | 17.01% |
| 等权整体 | 708.21ms | 577.75ms | 18.42% |
整体服务端 P95 为 766.14→646.90ms;本机 HTTP 平均为 709.14→578.71ms。
160 次计时请求的样例判定均符合预期,但这是四张固定样例的重复测试,不代表现场准确率。
旧环境两阶段均值为 720.48、695.94ms,新环境为 581.34、574.16ms,存在运行波动。
候选服务依次使用 8767 端口;正式 8766 服务始终驻留,测试期间未收到其他图片推理请求。
测试后 8767 已关闭,正式服务仍为 ROCm 10.1.0 / d3-nano / ready,运行配置已恢复。
本次结果反映预热后的单请求延迟,未测试并发吞吐、冷启动、现场相机和完整 SOP。
原始报告在 `/home/wl/sophelper/diagnostics/djev-benchmark/results.json`,
本地副本为工作区 `scratch/test-results/md002-rocm-benchmark.json`。
`tools/benchmark_d3_lite.py` 已支持指定图片目录、筛选样例、配置预热次数,并输出
服务端与 HTTP 的均值、中位数和 P95;本次实机测试覆盖这些选项。
## MD002 djev 升级 ROCm 10.1(2026-11-20)
正式端口 `127.0.0.1:8766` 的 d3-nano 已切换到 ROCm `10.1.0`,

View File

@ -35,7 +35,8 @@ def post(endpoint, image, question, choices=None, state=""):
def stats(runs):
values = sorted(row["http_ms"] for row in runs)
return {"count": len(runs), "mean_ms": round(statistics.mean(values), 2), "p95_ms": values[math.ceil(.95 * len(values)) - 1], "max_ms": max(values), "under_200ms": sum(value < 200 for value in values), "under_500ms": sum(value < 500 for value in values)}
server = sorted(row["response"]["usage"]["server_ms"] for row in runs)
return {"count": len(runs), "mean_ms": round(statistics.mean(values), 2), "median_ms": round(statistics.median(values), 2), "p95_ms": values[math.ceil(.95 * len(values)) - 1], "max_ms": max(values), "server_mean_ms": round(statistics.mean(server), 2), "server_median_ms": round(statistics.median(server), 2), "server_p95_ms": server[math.ceil(.95 * len(server)) - 1], "under_200ms": sum(value < 200 for value in values), "under_500ms": sum(value < 500 for value in values)}
def main():
@ -43,10 +44,15 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--endpoint", default="http://127.0.0.1:8766/v1/systemone")
parser.add_argument("--count", type=int, default=5)
parser.add_argument("--warmup-count", type=int, default=1)
parser.add_argument("--image-root", type=Path)
parser.add_argument("--case", action="append", dest="selected_cases", help="Run only this case; repeat to select multiple cases")
parser.add_argument("--output", type=Path, required=True)
args = parser.parse_args()
if args.count < 1 or args.warmup_count < 1:
parser.error("--count and --warmup-count must be positive")
repo = Path(__file__).resolve().parents[1]
images = repo / "artifacts/imajev-benchmark"
images = args.image_root or repo / "artifacts/imajev-benchmark"
colors = {"黄": "黄色", "绿": "绿色", "有红有蓝": "红色和蓝色都有"}
english_colors = {"yellow": "yellow", "green": "green", "red_and_blue": "both red and blue"}
cases = [
@ -61,10 +67,15 @@ def main():
("颜色_中文", "hikvision-imajev-color-20261112-195330-hand-crop-input.jpg", "手里这东西是黄的、绿的,还是红蓝都有?", colors, "有红有蓝"),
("颜色_英文", "hikvision-imajev-color-20261112-195330-hand-crop-input.jpg", "What color is the object held in the hand?", english_colors, "red_and_blue"),
]
if args.selected_cases:
unknown = set(args.selected_cases) - {case[0] for case in cases}
if unknown:
parser.error(f"Unknown cases: {sorted(unknown)}")
cases = [case for case in cases if case[0] in args.selected_cases]
health_url = args.endpoint.rsplit("/v1/systemone", 1)[0] + "/health"
with urllib.request.urlopen(health_url, timeout=10) as response:
health = json.load(response)
report = {"model": health["model"], "endpoint": args.endpoint, "health": health, "scope": "Same real camera images as Imajev, maximum edge 512; one question per request; first call per case recorded separately as warmup", "note": "The upstream D3 response has no automatic abstention/unknown field; confidence is not a correctness guarantee", "cases": []}
report = {"model": health["model"], "endpoint": args.endpoint, "health": health, "warmup_count": args.warmup_count, "scope": "Prepared JPEG bytes without recompression; one question per request; per-case warmups excluded from statistics; HTTP timing excludes image preparation and server_ms comes from the service", "note": "The upstream D3 response has no automatic abstention/unknown field; confidence is not a correctness guarantee", "cases": []}
args.output.parent.mkdir(parents=True, exist_ok=True)
for name, filename, question, choices, expected in cases:
source = images / filename
@ -74,12 +85,14 @@ def main():
size = image.size
row = {"case": name, "input": str(source), "image_size": size, "image_sha256": hashlib.sha256(data).hexdigest(),
"question": question, "choices": choices, "expected": expected, "runs": []}
row["warmup"] = post(args.endpoint, data, question, choices)
assert row["warmup"]["response"]["model"] == report["model"], "Served model changed during benchmark"
row["warmups"] = [post(args.endpoint, data, question, choices) for _ in range(args.warmup_count)]
row["warmup"] = row["warmups"][0]
assert all(run["response"]["model"] == report["model"] for run in row["warmups"]), "Served model changed during benchmark"
report["cases"].append(row)
for _ in range(args.count):
run = post(args.endpoint, data, question, choices)
assert run["response"]["model"] == report["model"], "Served model changed during benchmark"
assert run["response"]["model"] == report["model"], "Served model changed during benchmark"
run["correct"] = run["actual"] == expected
row["runs"].append(run)
args.output.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")