Update sc1/score_clawbenchpro.sh
Browse files- sc1/score_clawbenchpro.sh +108 -2
sc1/score_clawbenchpro.sh
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
# ClawBenchPro base100/hard100 后处理评分。
|
| 3 |
# 可选在本机启动 OpenAI-compatible vLLM Judge,然后调用每题自带 verifier。
|
| 4 |
|
|
|
|
| 5 |
set -x
|
| 6 |
|
| 7 |
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
@@ -62,6 +63,106 @@ fi
|
|
| 62 |
|
| 63 |
mkdir -p "${SCORE_OUTPUT_ROOT}" "$(dirname "${JUDGE_LOG}")"
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Triton/vLLM 在 Judge 初始化 KV cache 前会通过 tempfile 创建 hivmc
|
| 66 |
# 探测文件。训练环境安装脚本历史上默认使用 /cache/ray_tmp,但该目录在
|
| 67 |
# 某些独立评分节点上不存在、不可写或已耗尽配额。评分任务使用独立临时
|
|
@@ -122,7 +223,7 @@ trap cleanup EXIT INT TERM
|
|
| 122 |
|
| 123 |
check_judge() {
|
| 124 |
python3 -c 'import json,sys,urllib.request; req=urllib.request.Request(sys.argv[1].rstrip("/")+"/models",headers={"Authorization":"Bearer "+sys.argv[2]}); data=json.load(urllib.request.urlopen(req,timeout=10)); ids={str(x.get("id")) for x in data.get("data",[])}; raise SystemExit(0 if sys.argv[3] in ids else 1)' \
|
| 125 |
-
"${JUDGE_BASE_URL}" "${JUDGE_API_KEY}" "${JUDGE_SERVED_MODEL_NAME}"
|
| 126 |
}
|
| 127 |
|
| 128 |
if [ "${JUDGE_ENABLED}" = "1" ]; then
|
|
@@ -195,7 +296,12 @@ score_args=(
|
|
| 195 |
if [ "${FAIL_ON_ERROR}" = "1" ]; then
|
| 196 |
score_args+=(--fail-on-error)
|
| 197 |
fi
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
echo "Scoring completed:"
|
| 201 |
echo " ${SCORE_OUTPUT_ROOT}/summary.json"
|
|
|
|
| 2 |
# ClawBenchPro base100/hard100 后处理评分。
|
| 3 |
# 可选在本机启动 OpenAI-compatible vLLM Judge,然后调用每题自带 verifier。
|
| 4 |
|
| 5 |
+
set -Eeo pipefail
|
| 6 |
set -x
|
| 7 |
|
| 8 |
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
| 63 |
|
| 64 |
mkdir -p "${SCORE_OUTPUT_ROOT}" "$(dirname "${JUDGE_LOG}")"
|
| 65 |
|
| 66 |
+
# 只把完整通过磁盘审计的 checkpoint 交给评分器。残缺模型不能用部分题目
|
| 67 |
+
# 计算均分;它们由推理续跑脚本补齐后,再次运行本脚本即可自动纳入评分。
|
| 68 |
+
MODELS=$(python3 - "${INFERENCE_ROOT}" "${BASE_TASKS}/benchmark_manifest.json" "${MODELS}" <<'PY'
|
| 69 |
+
import json
|
| 70 |
+
import sys
|
| 71 |
+
from pathlib import Path
|
| 72 |
+
|
| 73 |
+
inference_root = Path(sys.argv[1])
|
| 74 |
+
manifest_path = Path(sys.argv[2])
|
| 75 |
+
requested_raw = sys.argv[3]
|
| 76 |
+
requested = {item.strip() for item in requested_raw.split(",") if item.strip()} or None
|
| 77 |
+
|
| 78 |
+
try:
|
| 79 |
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 80 |
+
task_ids = {str(item["task_id"]) for item in manifest["tasks"]}
|
| 81 |
+
except Exception as exc:
|
| 82 |
+
print(
|
| 83 |
+
f"ERROR: failed to load benchmark manifest {manifest_path}: {type(exc).__name__}: {exc}",
|
| 84 |
+
file=sys.stderr,
|
| 85 |
+
)
|
| 86 |
+
raise SystemExit(2)
|
| 87 |
+
|
| 88 |
+
def load_json(path: Path):
|
| 89 |
+
try:
|
| 90 |
+
value = json.loads(path.read_text(encoding="utf-8"))
|
| 91 |
+
except Exception:
|
| 92 |
+
return None
|
| 93 |
+
return value if isinstance(value, dict) else None
|
| 94 |
+
|
| 95 |
+
complete = []
|
| 96 |
+
discovered_names = set()
|
| 97 |
+
for model_dir in sorted(path for path in inference_root.iterdir() if path.is_dir()):
|
| 98 |
+
if not (model_dir / "step_1").is_dir():
|
| 99 |
+
continue
|
| 100 |
+
model_name = model_dir.name
|
| 101 |
+
discovered_names.add(model_name)
|
| 102 |
+
if requested is not None and model_name not in requested:
|
| 103 |
+
continue
|
| 104 |
+
|
| 105 |
+
result_dirs = sorted(
|
| 106 |
+
path for path in (model_dir / "step_1").glob("data_*_sample_*") if path.is_dir()
|
| 107 |
+
)
|
| 108 |
+
discovered_task_ids = {
|
| 109 |
+
path.name.rsplit("_sample_", 1)[0]
|
| 110 |
+
for path in result_dirs
|
| 111 |
+
if "_sample_" in path.name
|
| 112 |
+
}
|
| 113 |
+
missing = sorted(task_ids - discovered_task_ids)
|
| 114 |
+
extra = sorted(discovered_task_ids - task_ids)
|
| 115 |
+
issues = []
|
| 116 |
+
if missing:
|
| 117 |
+
issues.append(f"missing_tasks={len(missing)} first={missing[:5]}")
|
| 118 |
+
if extra:
|
| 119 |
+
issues.append(f"extra_tasks={len(extra)} first={extra[:5]}")
|
| 120 |
+
|
| 121 |
+
for result_dir in result_dirs:
|
| 122 |
+
if not (result_dir / "workspace_after").is_dir():
|
| 123 |
+
issues.append(f"missing_workspace={result_dir.name}")
|
| 124 |
+
metadata = load_json(result_dir / "nanoclaw_metadata.json")
|
| 125 |
+
if metadata is None:
|
| 126 |
+
issues.append(f"invalid_metadata={result_dir.name}")
|
| 127 |
+
elif metadata.get("status") != "ready":
|
| 128 |
+
issues.append(f"metadata_status={metadata.get('status')}:{result_dir.name}")
|
| 129 |
+
if load_json(result_dir / "conversation_history.json") is None:
|
| 130 |
+
issues.append(f"invalid_conversation={result_dir.name}")
|
| 131 |
+
if load_json(result_dir / "trajectory.json") is None:
|
| 132 |
+
issues.append(f"invalid_trajectory={result_dir.name}")
|
| 133 |
+
if len(issues) >= 20:
|
| 134 |
+
break
|
| 135 |
+
|
| 136 |
+
if issues:
|
| 137 |
+
print(
|
| 138 |
+
f"[score_skip_incomplete] model={model_name} issues={len(issues)} "
|
| 139 |
+
f"preview={' | '.join(issues[:8])}",
|
| 140 |
+
file=sys.stderr,
|
| 141 |
+
)
|
| 142 |
+
continue
|
| 143 |
+
|
| 144 |
+
complete.append(model_name)
|
| 145 |
+
print(
|
| 146 |
+
f"[score_include_complete] model={model_name} tasks={len(task_ids)} samples={len(result_dirs)}",
|
| 147 |
+
file=sys.stderr,
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
if requested is not None:
|
| 151 |
+
unknown = sorted(requested - discovered_names)
|
| 152 |
+
if unknown:
|
| 153 |
+
print(f"ERROR: requested model directories not found: {unknown}", file=sys.stderr)
|
| 154 |
+
raise SystemExit(2)
|
| 155 |
+
|
| 156 |
+
print(",".join(complete))
|
| 157 |
+
PY
|
| 158 |
+
)
|
| 159 |
+
export MODELS
|
| 160 |
+
if [ -z "${MODELS}" ]; then
|
| 161 |
+
echo "NO_COMPLETE_MODELS_TO_SCORE: incomplete checkpoints must finish inference before scoring."
|
| 162 |
+
exit 0
|
| 163 |
+
fi
|
| 164 |
+
echo "COMPLETE_MODELS_TO_SCORE=${MODELS}"
|
| 165 |
+
|
| 166 |
# Triton/vLLM 在 Judge 初始化 KV cache 前会通过 tempfile 创建 hivmc
|
| 167 |
# 探测文件。训练环境安装脚本历史上默认使用 /cache/ray_tmp,但该目录在
|
| 168 |
# 某些独立评分节点上不存在、不可写或已耗尽配额。评分任务使用独立临时
|
|
|
|
| 223 |
|
| 224 |
check_judge() {
|
| 225 |
python3 -c 'import json,sys,urllib.request; req=urllib.request.Request(sys.argv[1].rstrip("/")+"/models",headers={"Authorization":"Bearer "+sys.argv[2]}); data=json.load(urllib.request.urlopen(req,timeout=10)); ids={str(x.get("id")) for x in data.get("data",[])}; raise SystemExit(0 if sys.argv[3] in ids else 1)' \
|
| 226 |
+
"${JUDGE_BASE_URL}" "${JUDGE_API_KEY}" "${JUDGE_SERVED_MODEL_NAME}" 2>/dev/null
|
| 227 |
}
|
| 228 |
|
| 229 |
if [ "${JUDGE_ENABLED}" = "1" ]; then
|
|
|
|
| 296 |
if [ "${FAIL_ON_ERROR}" = "1" ]; then
|
| 297 |
score_args+=(--fail-on-error)
|
| 298 |
fi
|
| 299 |
+
score_rc=0
|
| 300 |
+
"${score_args[@]}" || score_rc=$?
|
| 301 |
+
if [ "${score_rc}" -ne 0 ]; then
|
| 302 |
+
echo "ERROR: ClawBenchPro scoring failed with exit code ${score_rc}." >&2
|
| 303 |
+
exit "${score_rc}"
|
| 304 |
+
fi
|
| 305 |
|
| 306 |
echo "Scoring completed:"
|
| 307 |
echo " ${SCORE_OUTPUT_ROOT}/summary.json"
|