File size: 7,804 Bytes
c793be8 | 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | from __future__ import annotations
import ast
import json
from collections import Counter
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DATA = ROOT / "data" / "ClawBenchPro_base100_hard100_quality"
VERL = ROOT / "verl"
def require_file(path: Path) -> None:
if not path.is_file():
raise FileNotFoundError(path)
def main() -> None:
required_bundle_files = [
ROOT / "v14" / "0708_new" / "inference_clawbenchpro.sh",
ROOT / "v14" / "0708_new" / "score_clawbenchpro.sh",
ROOT / "v14" / "0710" / "inference.sh",
ROOT / "scripts" / "setup_full_npu_environment.sh",
VERL / "recipe" / "nanoclaw" / "inference.py",
VERL / "recipe" / "nanoclaw" / "nanoclaw.py",
VERL / "recipe" / "nanoclaw" / "nanoclaw_tool_config.yaml",
VERL / "recipe" / "nanoclaw" / "score_clawbenchpro.py",
VERL / "verl" / "experimental" / "agent_loop" / "agent_loop.py",
VERL / "verl" / "experimental" / "agent_loop" / "tool_agent_loop.py",
DATA / "benchmark_manifest.json",
DATA / "quality_selection_report.json",
DATA / "quality_selection_manifest.jsonl",
DATA / "_SUCCESS",
ROOT / "BUNDLE_VALIDATION.json",
]
for path in required_bundle_files:
require_file(path)
inference_shell = (ROOT / "v14" / "0708_new" / "inference_clawbenchpro.sh").read_text(encoding="utf-8")
inference_core_shell = (ROOT / "v14" / "0710" / "inference.sh").read_text(encoding="utf-8")
scoring_shell = (ROOT / "v14" / "0708_new" / "score_clawbenchpro.sh").read_text(encoding="utf-8")
scoring_python = (VERL / "recipe" / "nanoclaw" / "score_clawbenchpro.py").read_text(encoding="utf-8")
setup_shell = (ROOT / "scripts" / "setup_full_npu_environment.sh").read_text(encoding="utf-8")
if "SETUP_ENVIRONMENT=${SETUP_ENVIRONMENT:-1}" not in inference_shell:
raise ValueError("inference entrypoint must default to full environment installation")
required_multi_model_markers = (
"MODEL_CHECKPOINTS",
"MODEL_PATH_LIST",
"MODEL_NAME_LIST",
"MODEL_INPUT_VALIDATE_ONLY",
"INPUT_MODEL_PATHS",
"CONTINUE_ON_MODEL_ERROR",
"MODEL_SWITCH_COOLDOWN",
"MODEL_RESOURCE_RELEASE_TIMEOUT",
"model checkpoint path must be absolute",
)
missing_multi_model_markers = [marker for marker in required_multi_model_markers if marker not in inference_shell]
if missing_multi_model_markers:
raise ValueError(f"multi-checkpoint inference entrypoint is incomplete: {missing_multi_model_markers}")
required_core_multi_model_markers = (
'for model_index in "${!MODEL_PATHS[@]}"',
'model_output_root=${OUTPUT_ROOT}/${model_name}',
"wait_for_ray_available_npu_resources",
"MODEL_RESOLVED_NAMES",
"duplicate model output name",
)
missing_core_markers = [marker for marker in required_core_multi_model_markers if marker not in inference_core_shell]
if missing_core_markers:
raise ValueError(f"core multi-checkpoint loop is incomplete: {missing_core_markers}")
required_scoring_multi_model_markers = (
"discover_models",
"for model_dir in models",
'output_root / model_dir.name',
'output_root / "leaderboard.csv"',
)
missing_scoring_markers = [marker for marker in required_scoring_multi_model_markers if marker not in scoring_python]
if missing_scoring_markers:
raise ValueError(f"multi-model scoring is incomplete: {missing_scoring_markers}")
if "SETUP_ENVIRONMENT=${SETUP_ENVIRONMENT:-1}" not in scoring_shell:
raise ValueError("scoring entrypoint must default to full environment installation")
if 'source "${BUNDLE_ROOT}/scripts/setup_full_npu_environment.sh"' not in scoring_shell:
raise ValueError("scoring entrypoint does not source the full NPU environment installer")
required_install_markers = (
"torch==2.9.0",
"torch-npu==2.9.0",
"VLLM_TARGET_DEVICE=empty pip install .",
"triton==3.5.0",
"pip install -r requirements-npu.txt",
"transformers==5.3.0",
"openai httpx",
)
missing_install_markers = [marker for marker in required_install_markers if marker not in setup_shell]
if missing_install_markers:
raise ValueError(f"full NPU environment installer is incomplete: {missing_install_markers}")
manifest = json.loads((DATA / "benchmark_manifest.json").read_text(encoding="utf-8"))
tasks = manifest.get("tasks")
if not isinstance(tasks, list) or manifest.get("task_count") != 200 or len(tasks) != 200:
raise ValueError("benchmark_manifest.json must declare exactly 200 tasks")
categories = Counter(str(item.get("quality_category")) for item in tasks)
if categories != {"base": 100, "hard": 100}:
raise ValueError(f"unexpected category counts: {dict(categories)}")
task_dirs = sorted(path for path in DATA.glob("data_*") if path.is_dir())
if len(task_dirs) != 200:
raise ValueError(f"expected 200 task directories, found {len(task_dirs)}")
if {path.name for path in task_dirs} != {str(item.get("task_id")) for item in tasks}:
raise ValueError("task directories do not match benchmark manifest")
llm_judge = 0
required_task_keys = ("env_builder", "prompt", "verifier", "yaml")
for task_dir in task_dirs:
task_manifest = json.loads((task_dir / "manifest.json").read_text(encoding="utf-8"))
files = task_manifest.get("files")
if not isinstance(files, dict):
raise ValueError(f"invalid task manifest: {task_dir}")
for key in required_task_keys:
require_file(task_dir / str(files.get(key) or "<missing>"))
require_file(task_dir / "_env_builder_impl.py")
verifier = task_dir / str(files["verifier"])
verifier_text = verifier.read_text(encoding="utf-8", errors="replace")
if any(marker in verifier_text for marker in ("OpenAI(", "client.chat.completions", "httpx.Client")):
llm_judge += 1
for python_file in (task_dir / str(files["env_builder"]), task_dir / "_env_builder_impl.py", verifier):
ast.parse(python_file.read_text(encoding="utf-8"), filename=str(python_file))
if llm_judge != 134:
raise ValueError(f"expected 134 LLM Judge verifiers, found {llm_judge}")
symlinks = [path for path in ROOT.rglob("*") if path.is_symlink()]
if symlinks:
raise ValueError(f"bundle contains symlinks and is not self-contained: {symlinks[:10]}")
for python_file in (
VERL / "recipe" / "nanoclaw" / "inference.py",
VERL / "recipe" / "nanoclaw" / "score_clawbenchpro.py",
):
ast.parse(python_file.read_text(encoding="utf-8"), filename=str(python_file))
print(
json.dumps(
{
"bundle_root": str(ROOT),
"tasks": 200,
"categories": dict(categories),
"deterministic_verifiers": 66,
"llm_judge_verifiers": llm_judge,
"inference_full_environment_install_default": True,
"inference_multi_checkpoint_input": True,
"script_top_model_array_smoke_count": 3,
"absolute_checkpoint_paths_required": True,
"script_top_model_strings": True,
"tabular_model_config_removed": True,
"per_model_output_directories": True,
"scoring_full_environment_install_default": True,
"scoring_multi_model_discovery": True,
"symlinks": 0,
"status": "ok",
},
ensure_ascii=False,
indent=2,
)
)
if __name__ == "__main__":
main()
|