From fc3bf2602a4fbf99ee15a2e96c84a69840e73665 Mon Sep 17 00:00:00 2001 From: Haoran Geng <71596067+geng-haoran@users.noreply.github.com> Date: Sun, 29 Nov 2026 22:03:40 +0000 Subject: [PATCH] feat(bench): a result records initial states outside the joint limits; the gate refuses them `validate_instances` ran only in `bench health`, so `bench suite run` scored the shipped lift_peg_upright demos (fingers at 1.0 in a 0 to 0.04 joint) without a word and the rows passed the submission gate. `evaluate` now judges the pool before the first episode, warns, and records the offenders in `notes.instance_problems`; `submission_problems` refuses such a result. The corrected peg demo file (fingers 0.04) gates clean at replay 1.0 and is the file to publish on the Hub before the first reproducible rows. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01WT1rr3wpGmrFtSiGj4k5yG --- packages/metasim/CHANGELOG.md | 1 + packages/metasim/metasim/bench/evaluator.py | 17 ++++++++++++++++- packages/metasim/metasim/bench/suite.py | 6 ++++++ .../metasim/metasim/test/test_bench_general.py | 12 ++++++++++++ .../metasim/test/test_bench_suites_general.py | 7 +++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/metasim/CHANGELOG.md b/packages/metasim/CHANGELOG.md index 3d843819e..5425c73f1 100644 --- a/packages/metasim/CHANGELOG.md +++ b/packages/metasim/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- `evaluate` validates the instance pool's initial states against the robot's joint limits and records the offenders in `notes.instance_problems` (a warning at run time); `submission_problems` refuses such a result, so a suite run on a demo file with an unphysical start (the shipped `lift_peg_upright` demos) is scored but cannot enter the leaderboard. Before, only `bench health` judged this. - `bench run|suite run|serve --checkpoint-url URL`: where the hashed checkpoint can be fetched, recorded as `policy.checkpoint_url` next to `checkpoint_sha256` (a leaderboard row of a learned policy requires both; nothing wrote the URL before). `bench submit` keeps two output directories that share file names (two seeds of one policy) under `__`, decides every destination before copying, and never replaces a file with other contents (`--force` adds to a submission). - `bench summarize --json` and `bench matrix [--suite NAME] --json` write the pooled rows and the methods x tiers cells as data instead of Markdown (`metasim.bench.summarize_rows`, `metasim.bench.matrix_cells`; the Markdown tables are rendered from them). `bench matrix --suite` judges the macros against the suite's full task list. - Assets can be pinned. `metasim.utils.hf_util.set_hub_revision` / `ROBOVERSE_HUB_REVISION` make every Hub download (files, folders, companions) come from one revision, and every result records it (`provenance.hub`). `BenchmarkSuite.manifest` carries a suite's frozen asset manifest (every file its tasks load with sha256 and size, plus the Hub revision); `bench suite run` pins downloads to it and exits 1 when the loaded assets or the demo file differ (`--allow-unpinned-assets` for a local experiment; the result then carries `notes.asset_check`), and `metasim.bench.manifest_problems` / `submission_problems` refuse such a result for the leaderboard. Results record the demo file the instances came from (`notes.demo_file`: path, sha256, size). diff --git a/packages/metasim/metasim/bench/evaluator.py b/packages/metasim/metasim/bench/evaluator.py index cc0fea076..84ccb0509 100644 --- a/packages/metasim/metasim/bench/evaluator.py +++ b/packages/metasim/metasim/bench/evaluator.py @@ -25,7 +25,15 @@ from metasim.utils.log import warn_once from .access import AccessProfile, restrict_observation, usage_report -from .instances import TaskInstance, demo_budget, expects_instances, instance_pool, plan_instances, pool_fingerprint +from .instances import ( + TaskInstance, + demo_budget, + expects_instances, + instance_pool, + plan_instances, + pool_fingerprint, + validate_instances, +) from .policy import Policy, PolicyContext, PolicyError from .prompts import DRAW_REVISION, task_prompt_bank from .protocol import EvalProtocol @@ -349,6 +357,12 @@ def evaluate( "resets would not be comparable with runs on the recorded instances. Download the demos, pass --demos, or " "record them with `bench record` (which evaluates from the task's own initial states on purpose)" ) + instance_problems = validate_instances(env, pool) + if instance_problems: + log.warning( + f"bench: {len(instance_problems)} instance(s) of {name} start outside the robot's joint limits; the result " + f"records them (notes.instance_problems) and cannot enter the leaderboard. First: {instance_problems[0]}" + ) bank = task_prompt_bank(env) plan = plan_instances(pool, protocol, prompts=bank, task=name) task_cap = int(getattr(env, "max_episode_steps", 0) or 0) @@ -571,6 +585,7 @@ def observed(obs, slots: list[int] | None = None) -> None: notes={ "instance_pool": len(pool), "instance_pool_hash": pool_fingerprint(pool), + **({"instance_problems": instance_problems} if instance_problems else {}), **({"demo_file": demo_file} if (demo_file := _demo_file(env)) else {}), "instruction": ctx.instruction or (bank.canonical if bank else None), "task_class": type(env).__qualname__, diff --git a/packages/metasim/metasim/bench/suite.py b/packages/metasim/metasim/bench/suite.py index 761eb62e5..8133243c4 100644 --- a/packages/metasim/metasim/bench/suite.py +++ b/packages/metasim/metasim/bench/suite.py @@ -291,6 +291,12 @@ def submission_problems(result: BenchmarkResult, suite: BenchmarkSuite) -> list[ problems.append("the command that produced it was not recorded (notes.command)") if not notes.get("instance_pool_hash"): problems.append("the instance pool was not fingerprinted (notes.instance_pool_hash)") + if notes.get("instance_problems"): + problems.append( + f"{len(notes['instance_problems'])} instance(s) start outside the robot's joint limits " + "(notes.instance_problems); an unphysical start is resolved differently by every engine, so the number " + "is not reproducible: fix the demo file before scoring on it" + ) demos = notes.get("demos") if demos is not None and not (isinstance(demos, dict) and demos.get("sha256")): problems.append("notes.demos names a demo file without its sha256; a local demo file is not reproducible") diff --git a/packages/metasim/metasim/test/test_bench_general.py b/packages/metasim/metasim/test/test_bench_general.py index 1efab0ac4..e15c5184b 100644 --- a/packages/metasim/metasim/test/test_bench_general.py +++ b/packages/metasim/metasim/test/test_bench_general.py @@ -1479,3 +1479,15 @@ def test_demo_file_is_resolved_by_the_loaders_rule(tmp_path, monkeypatch): env.scenario = SimpleNamespace(robots=[SimpleNamespace(name="bot")]) note = _demo_file(env) assert note["path"] == "roboverse_data/trajs/t/v2/bot_v2.pkl" and note["bytes"] == 4 and len(note["sha256"]) == 64 + + +def test_evaluate_records_out_of_limit_initial_states_in_the_result(): + """A pool whose states put a joint outside its limits is scored, but the result says so and cannot be submitted.""" + good = {**_state(0), "robots": {"bot": {"dof_pos": {"j0": 0.5, "j1": 0.0}}}} + bad = {**_state(1), "robots": {"bot": {"dof_pos": {"j0": 1.5, "j1": 0.0}}}} + env = _limited_env([good, bad]) + result = evaluate(env, HoldPolicy(), EvalProtocol(episodes=2)) + assert result.notes["instance_problems"] == ["instance 1: bot.j0=1.500 outside [0.000, 1.000]"] + validate_result(result.to_dict()) + env = _limited_env([good, good]) + assert "instance_problems" not in evaluate(env, HoldPolicy(), EvalProtocol(episodes=2)).notes diff --git a/packages/metasim/metasim/test/test_bench_suites_general.py b/packages/metasim/metasim/test/test_bench_suites_general.py index 735d145bb..3d82ff03a 100644 --- a/packages/metasim/metasim/test/test_bench_suites_general.py +++ b/packages/metasim/metasim/test/test_bench_suites_general.py @@ -414,6 +414,13 @@ def test_manifest_problems_hold_a_result_to_the_suites_frozen_bytes(): } result.notes["demo_file"] = {"path": "roboverse_data/trajs/t/v2/bot_v2.pkl.gz", "sha256": "b" * 64, "bytes": 20} assert manifest_problems(result, suite) == [] + # an unphysical start recorded by the evaluator is refused by the submission gate, whatever else is right + from metasim.bench import submission_problems + + result.notes["instance_problems"] = ["instance 0: bot.j0=1.500 outside [0.000, 1.000]"] + assert any("1 instance(s) start outside the robot's joint limits" in p for p in submission_problems(result, suite)) + result.notes.pop("instance_problems") + assert not any("joint limits" in p for p in submission_problems(result, suite)) result.notes["demo_file"]["sha256"] = "c" * 64 assert manifest_problems(result, suite) == [ "roboverse_data/trajs/t/v2/bot_v2.pkl.gz: sha256 cccccccccccc differs from the manifest's bbbbbbbbbbbb"