"""按序跑完全部评测模型(云端优先,本地模型等下载完成后再跑)。 每个模型一条命令,串行执行(不并发,符合本次评测目标);stdout/耗时写入 各 tag 目录下的 run.log。中断后重跑会跳过已有 summary.json 的 tag。 """ from __future__ import annotations import json import subprocess import sys import time from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parent.parent OUT_ROOT = PROJECT_ROOT / "data/experiments/translate_models" CLOUD_BASE = "https://api.siliconflow.cn/v1/chat/completions" LOCAL_BASE = "http://localhost:11434/v1/chat/completions" # (tag, model, 额外参数)。基线 Qwen3.6-35B-A3B 单列,不重跑(已有 run_d386 产物)。 TASKS: list[tuple[str, str, list[str]]] = [ ("cloud-qwen3.5-35b-a3b", "Qwen/Qwen3.5-35B-A3B", []), ("cloud-qwen3-vl-30b-a3b", "Qwen/Qwen3-VL-30B-A3B-Instruct", ["--strip-thinking"]), ("cloud-qwen3-14b", "Qwen/Qwen3-14B", []), ("cloud-qwen3-8b", "Qwen/Qwen3-8B", []), ("cloud-qwen3.5-9b", "Qwen/Qwen3.5-9B", []), ("local-qwen3-14b", "qwen3:14b", ["--api-base", LOCAL_BASE, "--api-key", "", "--timeout", "900", "--warmup"]), ("local-qwen3-30b-a3b", "qwen3:30b-a3b", ["--api-base", LOCAL_BASE, "--api-key", "", "--timeout", "900", "--warmup"]), ] def main() -> None: only = sys.argv[1:] or None for tag, model, extra in TASKS: if only and tag not in only: continue out_dir = OUT_ROOT / tag if (out_dir / "summary.json").is_file(): print(f"[skip] {tag} 已有 summary.json", flush=True) continue out_dir.mkdir(parents=True, exist_ok=True) cmd = [ sys.executable, str(PROJECT_ROOT / "scripts/bench_translate_models.py"), "run", "--model", model, "--tag", tag, *extra, ] print(f"[start] {tag} :: {' '.join(cmd[2:])}", flush=True) started = time.monotonic() with (out_dir / "run.log").open("w", encoding="utf-8") as log: proc = subprocess.run(cmd, cwd=PROJECT_ROOT, stdout=log, stderr=subprocess.STDOUT) elapsed = time.monotonic() - started print(f"[done] {tag} rc={proc.returncode} {elapsed/60:.1f}min", flush=True) summary = out_dir / "summary.json" if summary.is_file(): data = json.loads(summary.read_text(encoding="utf-8")) print(" ", {k: data.get(k) for k in ("status", "cues_out", "wall_s", "per_cue_s", "failed_calls", "error")}, flush=True) if __name__ == "__main__": main()