Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/metasim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<directory>__<file>`, 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).
Expand Down
17 changes: 16 additions & 1 deletion packages/metasim/metasim/bench/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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__,
Expand Down
6 changes: 6 additions & 0 deletions packages/metasim/metasim/bench/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions packages/metasim/metasim/test/test_bench_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions packages/metasim/metasim/test/test_bench_suites_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading