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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,6 @@ gate_out/
coverage.xml
scratch*/
wt/

# benchmark instance sets ship with the repository (gzip JSON, ~250-650 KB each; the *.gz rule above would hide them)
!roboverse_pack/suites/instances/**/*.json.gz
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
exclude: '(^third_party|.*\.md|.*\.rst)'
- id: check-added-large-files
exclude: '^(docs/source/_static/|packages/metasim/metasim/data/)' # tutorial videos / MetaSim example assets (tracked debt: move to a CDN)
args: ['--maxkb=800'] # a suite instance set (50 demos as gzip JSON) is up to ~650 KB
- id: debug-statements # check for debugger imports or `breakpoint()`
exclude: '^roboverse_learn/'
- id: check-yaml
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ release.

## [Unreleased]

### Added
- The tabletop-mujoco suite scores each task on a frozen instance set shipped with the repository (`roboverse_pack/suites/instances/tabletop-mujoco/<task>/franka_v2.json.gz`, 50 instances, one per protocol episode): the first published instances whose initial state is inside the joint limits and whose reference demo replays on MuJoCo, written by `tools/bench/freeze_instances.py` with a sidecar that names the source file and every skipped instance. This replaces the Hub demo files as the scoring set (the shipped lift_peg_upright start was unphysical; pick_cube's demos replayed at 0.8) and is hashed in the suite manifest.

## [1.0.0] - 2026-11-30

### Added
Expand Down
120 changes: 60 additions & 60 deletions docs/source/dataset_benchmark/benchmark/leaderboard.md

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions docs/source/dataset_benchmark/benchmark/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ This page says what is scored and what a number means; [usage](usage.md) lists e

## What is scored

An **episode** starts from a fixed **instance** (an initial state from the task's recorded demos, with a
content-addressed id) and runs the policy until the task reports success, the task's own time-out, or the
protocol's episode cap. The task's per-step success predicate becomes one verdict per episode through the
An **episode** starts from a fixed **instance** (an initial state with a content-addressed id and a reference
demo) and runs the policy until the task reports success, the task's own time-out, or the protocol's episode
cap. A suite scores each task on an **instance set that ships with the repository**
(`roboverse_pack/suites/instances/<suite>/<task>/<robot>_v2.json.gz`, gzip JSON, one instance per protocol
episode), frozen by `tools/bench/freeze_instances.py` from the task's published demos: the first instances in
file order whose initial state is inside the robot's joint limits and whose reference demo replays on the
suite's engine, with a sidecar naming the source file, the kept indices and every skipped one with its reason.
The replay baseline of a set is therefore 1.0 by construction, and a number does not depend on what a path on
the Hub holds today. The task's per-step success predicate becomes one verdict per episode through the
protocol's **success rule** (`first`: held at any step; `final`: at the last step; `held`: for *n*
consecutive steps). A run's **success rate** is the fraction of solved episodes, always reported with a
95% Wilson interval; a suite's number is the **task-macro** mean over its tasks and is `INCOMPLETE` until
Expand Down Expand Up @@ -62,7 +68,9 @@ Assets live on the Hugging Face Hub, where a path can change under a name. A sui
`tools/assets/freeze_suite_manifest.py`): every file its tasks load with its sha256, and the Hub revision.
`bench suite run` pins downloads to that revision and exits 1 when the loaded bytes differ from the manifest
(`--allow-unpinned-assets` for a local experiment, which the result then says); the leaderboard refuses such a
row. Re-publishing an asset or a demo set means re-freezing the manifest in the same pull request.
row, and a row scored on anything but the suite's instance set. Re-publishing an asset, or re-freezing an
instance set, means re-freezing the manifest in the same pull request; a new instance set is a new instance
pool, so earlier rows stop being comparable with new ones.

Two results are **comparable** (`metasim.bench.result_key`) when task, robots, simulator, `num_envs`,
instance pool and protocol agree; `bench summarize` pools exactly those, and names a policy with its
Expand Down
15 changes: 12 additions & 3 deletions docs/source/dataset_benchmark/benchmark/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,18 @@ The replay ceiling of every suite task on its backend is a row of the [leaderboa
the committed result files; this page keeps no copy of it.

Only tasks whose demos replay on the suite's backend belong in a suite. `bench health` is the gate. A suite
also freezes the bytes it is scored on: `roboverse_pack/suites/manifests/<suite>.json` lists every asset and
demo file with its sha256 and the Hub revision (`tools/assets/freeze_suite_manifest.py --suite <name>`);
`bench suite run` pins downloads to it and refuses a run on other bytes unless `--allow-unpinned-assets`.
scores each task on its own **instance set**, shipped with the repository as gzip JSON
(`roboverse_pack/suites/instances/<suite>/<task>/<robot>_v2.json.gz`, one instance per protocol episode) and
frozen by `tools/bench/freeze_instances.py --suite <name>` from the task's published demos: the first instances in
file order whose initial state is inside the robot's joint limits and whose reference demo replays on the backend;
the sidecar `.json` next to each set names the source file and every skipped instance with its reason, and
`--source TASK=PATH --note TASK=WHY` records a re-recorded source when the published demos cannot be used.
`bench suite run` evaluates on the set (`notes.demos`), and a result scored on anything else is refused by
`bench validate --suite` and the leaderboard. A suite also freezes the bytes it is scored on:
`roboverse_pack/suites/manifests/<suite>.json` lists every asset and instance set with its sha256 and the Hub
revision (`tools/assets/freeze_suite_manifest.py --suite <name>`); `bench suite run` pins downloads to it and
refuses a run on other bytes unless `--allow-unpinned-assets`. Re-freezing an instance set changes the
instance-pool hash, so earlier rows stop being comparable with new ones.
In `tabletop-mujoco` the demo budget tightens push_cube (216 steps), pull_cube (237) and
lift_peg_upright (534). pick_cube and stack_cube keep their 250-step time-out, because their recorded
demos run that long even when the task is solved by about step 120. Every task in the suite has a
Expand Down
3 changes: 3 additions & 0 deletions packages/metasim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- `SuiteTask.demos`: the instance set a suite scores a task on, a repository-relative demo file that `bench suite run` applies in both execution modes and records as `notes.demos`; `submission_problems` refuses a result scored on anything else (or on a `--demos` override the suite does not define). `metasim.utils.demo_util` reads and writes `.json.gz` trajectory files (gzip JSON: readable, no pickle), the format the repository's instance sets use.

## [1.0.0] - 2026-11-30

### Added
Expand Down
5 changes: 5 additions & 0 deletions packages/metasim/metasim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ def _suite_task_isolated(entry, protocol, args: argparse.Namespace, sim: str, ou
cmd += ["--access", access_path]
for robot in entry.robots:
cmd += ["--robot", robot]
if entry.demos: # the suite's instance set; `bench run` records it under notes.demos
cmd += ["--demos", entry.demos]
for cam in getattr(args, "camera", None) or ():
cmd += ["--camera", cam]
if getattr(args, "video", None):
Expand Down Expand Up @@ -715,6 +717,7 @@ def _bench_suite_run(args: argparse.Namespace) -> int:
device=args.device,
cameras=cameras,
)
_apply_demos_override(env, entry.demos) # the suite's instance set, when it ships one
try:
robots = "+".join(r.name for r in (getattr(env.scenario, "robots", None) or [])) or "norobot"
recorder = None
Expand All @@ -739,6 +742,8 @@ def on_episode(ep, recorder=recorder) -> None:
)
result.notes["suite"] = {"name": suite.name, "split": split}
result.notes["command"] = _command_line()
if entry.demos:
result.notes["demos"] = _demos_note(entry.demos)
if cameras:
result.notes["cameras"] = list(cameras)
if recorder is not None:
Expand Down
18 changes: 18 additions & 0 deletions packages/metasim/metasim/bench/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ class SuiteTask:
protocol: Field overrides on the suite protocol for this task (``{"episodes": 50}``).
dimensions: Capability tags the task tests (``"precision"``, ``"long_horizon"``, ``"articulation"``, …);
the report aggregates task-macro success per tag so a policy's profile is visible, not one number.
demos: The instance set the suite scores this task on, as a path relative to the repository root
(``roboverse_pack/suites/instances/<suite>/<task>/<robot>_v2.json.gz``), instead of the task's own demo
file. A benchmark's instances are part of the benchmark: shipping them with the code, hashed in the
suite manifest, makes a number independent of what a path on the Hub holds today. ``None`` = the task's
own demos.
"""

task: str
robots: tuple[str, ...] = ()
protocol: Mapping[str, Any] = field(default_factory=dict)
dimensions: tuple[str, ...] = ()
demos: str | None = None

def __post_init__(self) -> None:
object.__setattr__(self, "robots", tuple(self.robots))
Expand Down Expand Up @@ -291,6 +297,18 @@ 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)")
entry = next(
(e for _, e in suite.entries() if e.task == result.task and (not e.robots or tuple(e.robots) == tuple(robots))),
None,
)
scored_on = notes.get("demos", {}).get("path") if isinstance(notes.get("demos"), dict) else None
own = "the task's own demos"
if entry is not None and entry.demos and scored_on != entry.demos:
problems.append(
f"scored on {scored_on or own}; the suite scores {result.task!r} on its instance set {entry.demos}"
)
elif entry is not None and not entry.demos and scored_on:
problems.append(f"scored on a --demos override ({scored_on}) the suite does not define for {result.task!r}")
if notes.get("instance_problems"):
problems.append(
f"{len(notes['instance_problems'])} instance(s) start outside the robot's joint limits "
Expand Down
3 changes: 2 additions & 1 deletion packages/metasim/metasim/test/test_bench_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,12 @@ def fake_run(cmd, check, stdout, stderr):
instances=(1, 4),
access=AccessProfile(name="visual", observation="rgb"),
)
entry = SuiteTask(task="t", robots=("franka",))
entry = SuiteTask(task="t", robots=("franka",), demos="roboverse_pack/suites/instances/s/t/franka_v2.json.gz")
result = cli._suite_task_isolated(entry, protocol, args, "isaacsim", str(tmp_path / "r.json"))
cmd = calls[-1]
assert cmd[1:6] == ["-m", "metasim", "bench", "run", "--task"] and "isaacsim" in cmd
for flag, value in (
("--demos", "roboverse_pack/suites/instances/s/t/franka_v2.json.gz"),
("--episodes", "2"),
("--seed", "3"),
("--demo-budget", "2.0"),
Expand Down
44 changes: 44 additions & 0 deletions packages/metasim/metasim/test/test_bench_suites_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,3 +1068,47 @@ def fake_record(env_, policy, protocol, *, out, success_only, task_name, on_epis
== 0
)
assert calls["success_only"] is False


def test_submission_gate_holds_a_result_to_the_suites_instance_set():
from metasim.bench import SuiteTask, submission_problems

pinned = BenchmarkSuite(
name="pinned",
splits={"core": (SuiteTask("t", demos="roboverse_pack/suites/instances/pinned/t/bot_v2.json.gz"), "u")},
simulator="fake",
)
result = _result("t", 1, 1)
result.notes["demos"] = {"path": "roboverse_pack/suites/instances/pinned/t/bot_v2.json.gz", "sha256": "a" * 64}
assert not any("instance set" in p or "--demos override" in p for p in submission_problems(result, pinned))
result.notes["demos"]["path"] = "scratch/my_demos/bot_v2.pkl.gz"
assert any("the suite scores 't' on its instance set" in p for p in submission_problems(result, pinned))
result.notes.pop("demos")
assert any("scored on the task's own demos; the suite scores 't'" in p for p in submission_problems(result, pinned))
other = _result("u", 1, 1)
other.notes["demos"] = {"path": "scratch/x/bot_v2.pkl.gz", "sha256": "a" * 64}
assert any("--demos override" in p for p in submission_problems(other, pinned))


def test_gzip_json_is_a_trajectory_format(tmp_path):
"""The repository's instance sets are gzip JSON: readable, pickle-free, and resolved like any other demo file."""
from metasim.utils.demo_util import load_traj_file, save_traj_file
from metasim.utils.demo_util.demo_util import _resolve_traj_file
from metasim.utils.demo_util.loader import TRAJ_SUFFIXES

assert ".json.gz" in TRAJ_SUFFIXES
data = {
"bot": [
{
"init_state": {"bot": {"pos": [0.0, 0.0, 0.0], "rot": [1.0, 0.0, 0.0, 0.0], "dof_pos": {"j0": 0.5}}},
"actions": [{"bot": {"dof_pos_target": {"j0": 0.6}}}],
"states": None,
}
]
}
folder = tmp_path / "v2"
folder.mkdir()
save_traj_file(data, str(folder / "bot_v2.json.gz"))
assert load_traj_file(str(folder / "bot_v2.json.gz")) == data
assert _resolve_traj_file(str(folder), "bot") == str(folder / "bot_v2.json.gz")
assert (folder / "bot_v2.json.gz").read_bytes()[:2] == b"\x1f\x8b", "gzip, not a pickle"
32 changes: 31 additions & 1 deletion packages/metasim/metasim/test/test_cli_entry_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ def suite(monkeypatch):

s = BenchmarkSuite(
name="cli-test",
splits={"core": (SuiteTask("t_a", dimensions=("precision",)), "t_b")},
splits={
"core": (
SuiteTask(
"t_a",
dimensions=("precision",),
demos="roboverse_pack/suites/instances/cli-test/t_a/bot_v2.json.gz",
),
"t_b",
)
},
protocol=EvalProtocol(episodes=2),
simulator="mujoco",
description="two fake tasks",
Expand Down Expand Up @@ -124,6 +133,16 @@ def result(task, ok=True, *, tagged=True, dirty=False):
"command": "python -m metasim bench suite run --suite cli-test",
"instance_pool_hash": "ab" * 32,
**({"suite": {"name": "cli-test", "split": "core"}} if tagged else {}),
**(
{
"demos": {
"path": "roboverse_pack/suites/instances/cli-test/t_a/bot_v2.json.gz",
"sha256": "0" * 64,
}
}
if task == "t_a"
else {}
), # t_a is scored on the suite's instance set
},
)

Expand Down Expand Up @@ -326,13 +345,24 @@ def test_suite_run_in_process_writes_tagged_results_and_the_report(suite, monkey
monkeypatch.setattr(bench, "evaluate", _fake_evaluate({"t_a": (True, False), "t_b": (True, True)}))
monkeypatch.setattr(cli, "_make_env", lambda *a, **k: _Env())
monkeypatch.setattr(cli, "_make_policy", lambda args: (HoldPolicy(), {}))
overrides = []
monkeypatch.setattr(cli, "_apply_demos_override", lambda env, demos: overrides.append(demos))
monkeypatch.setattr(cli, "_demos_note", lambda demos: {"path": demos, "sha256": "0" * 64, "bytes": 1, "files": 1})
out_dir = tmp_path / "suite"
argv = ["bench", "suite", "run", "--suite", "cli-test", "--policy", "hold", "--isolate", "never", "--device", "cpu"]
assert cli.main([*argv, "--out-dir", str(out_dir)]) == 0
files = sorted(p.name for p in out_dir.iterdir())
assert files == ["core__t_a__bot__hold.json", "core__t_b__bot__hold.json", "suite.json", "suite.md"]
a = json.loads((out_dir / "core__t_a__bot__hold.json").read_text())
assert a["notes"]["suite"] == {"name": "cli-test", "split": "core"}
assert a["notes"]["demos"]["path"] == "roboverse_pack/suites/instances/cli-test/t_a/bot_v2.json.gz", (
"the suite's instance set is recorded as what the task was scored on"
)
assert overrides == ["roboverse_pack/suites/instances/cli-test/t_a/bot_v2.json.gz", None], (
"the env of t_a was pointed at the instance set; t_b has none"
)
b = json.loads((out_dir / "core__t_b__bot__hold.json").read_text())
assert "demos" not in b["notes"]
assert a["notes"]["command"].startswith("python -m metasim bench suite run --suite cli-test"), (
"a result records the command that produced it"
)
Expand Down
10 changes: 9 additions & 1 deletion packages/metasim/metasim/utils/demo_util/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import yaml

#: File extensions the loader dispatches on; the directory resolver searches the same set.
TRAJ_SUFFIXES = (".pkl", ".pkl.gz", ".json", ".yaml", ".yml")
TRAJ_SUFFIXES = (".pkl", ".pkl.gz", ".json", ".json.gz", ".yaml", ".yml")
"""``.json.gz`` is the format the benchmark instance sets in the repository use: gzip-compressed JSON, so a
reviewer can read it and nothing executes on load (a pickle does)."""


class TrajectoryFileError(RuntimeError):
Expand All @@ -33,6 +35,9 @@ def load_traj_file(path: str):
elif path.endswith(".pkl.gz"):
with gzip.open(path, "rb") as f:
return pickle.load(f)
elif path.endswith(".json.gz"):
with gzip.open(path, "rt", encoding="utf-8") as f:
return json.load(f)
elif path.endswith(".json"):
with open(path) as f:
return json.load(f)
Expand All @@ -56,6 +61,9 @@ def save_traj_file(data: dict, path: str):
elif path.endswith(".pkl.gz"):
with gzip.open(path, "wb", compresslevel=1) as f:
pickle.dump(data, f)
elif path.endswith(".json.gz"):
with gzip.open(path, "wt", encoding="utf-8", compresslevel=9) as f:
json.dump(data, f, separators=(",", ":"))
elif path.endswith(".json"):
with open(path, "w") as f:
json.dump(data, f)
Expand Down
Loading
Loading