zefancainlp's picture
download
raw
3.12 kB
# 中文源码导读(2026-09-15)|阅读顺序 079|本地工程
# 来源:官方同路径无此文件。
# 作用:读取运行配置、进程和验证记录,展示进度。
# 对照基准:test-time-training/discover@6c40e82;完整路线见 docs/CODE_READING_ORDER_ZH.md。
"""Read progress without touching the experiment."""
import argparse
from collections import Counter
import json
import math
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument("run_dir", type=Path)
parser.add_argument("--full-metrics", action="store_true", help="Include generated code and all per-batch metrics")
args = parser.parse_args()
root = args.run_dir.resolve()
c = json.loads((root / "resolved_config.json").read_text())
log = root / "tinker_log" / c["experiment_name"]
result = {"task": c["task"], "run_dir": str(root), "smoke": c["smoke"],
"target_updates": c["updates"], "rollouts_per_batch": c["group_size"] * c["groups_per_batch"]}
result["logical_rollouts"] = {}
result["candidate_summary"] = {}
for path in sorted((log / "function_analysis").glob("step_*.jsonl")):
with path.open() as handle:
rows = [json.loads(line) for line in handle if line.strip() and line.endswith("\n")]
result["logical_rollouts"][path.stem] = len(rows)
candidates = [row.get("candidate", {}) for row in rows]
scores = [float(row["raw_score"]) for row in candidates if row.get("raw_score") is not None and math.isfinite(float(row["raw_score"])) and float(row.get("correctness") or 0) > 0]
failures = Counter(str(row.get("msg") or "No diagnostic message") for row in candidates
if float(row.get("correctness") or 0) <= 0)
result["candidate_summary"][path.stem] = dict(valid=len(scores), best_raw_score=min(scores) if scores else None,
failures=dict(failures))
result["complete_checkpoints"] = [p.parent.name for p in sorted((root / "checkpoints").glob("*/checkpoint_complete"))]
for name in ("status.json", "processes.json", "verification.json"):
if (root / name).is_file():
result[name] = json.loads((root / name).read_text())
recent_log = root / "launcher.log"
if recent_log.is_file():
result["recent_training_log"] = recent_log.read_text(errors="replace").splitlines()[-12:]
if (log / "metrics.jsonl").is_file():
# A writer may still be appending the last JSON line during a status read.
with (log / "metrics.jsonl").open() as handle:
rows = [line for line in handle if line.strip() and line.endswith("\n")]
if rows:
metrics = json.loads(rows[-1])
if not args.full_metrics:
prefixes = ("time/", "optim/", "progress/", "kl/", "bootstrap/")
names = {"step", "kl_policy_base", "env/all/total_episodes", "env/all/correctness",
"env/all/raw_score/min", "env/all/raw_score/max", "env/all/reward/mean"}
metrics = {k: v for k, v in metrics.items() if k in names or k.startswith(prefixes)}
result["latest_metrics"] = metrics
print(json.dumps(result, indent=2))

Xet Storage Details

Size:
3.12 kB
·
Xet hash:
44cbae2aa33d36afde64bfe6b2a92a8bd0b9655376d6787b02ceafd16be118d0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.