diff --git a/README.md b/README.md index 60896aeab2aa622e63e40b848cfdc219c54f8e0a..126d20465fdfcf1d39ed524fcc9074305f095a00 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,9 @@ A [Harbor](https://harborframework.com) environment that measures whether a swar **communicates when it pays off**: any agent can find the exit alone, but the maze is too large for one agent's move budget, so sharing what each one has explored lets a team search it in time. It adapts the parallel-exploration task of -[s³: Simple Scaling of Swarms via Cooperative Multi-agent RL](https://arxiv.org/abs/2611.08615) -([scalingswarms.com](https://scalingswarms.com)) to [Legion](https://github.com/huggingface/legion) -swarms, whose agents talk over a shared message board. It isn't a replication of the paper: the -agents are Pi with Legion's board, and the board is what we measure. Its companion, -[s3-aggregation](https://huggingface.co/datasets/HuggingFaceSwarms/s3-aggregation), needs -communication instead. - -**This dataset is private for now.** +[s³: Simple Scaling of Swarms via Cooperative Multi-agent RL](https://arxiv.org/abs/2611.08615). +The companion [s3-aggregation](https://huggingface.co/datasets/HuggingFaceSwarms/s3-aggregation) +requires communication to obtain the teammates' private numbers. ## The task @@ -67,16 +62,10 @@ tasks/maze-tNN/ environment/docker-compose.yaml main (the agent) and maze, on an internal network only main reaches environment/agent/ main's image: its Dockerfile and the `maze` command, nothing else environment/maze/ the service's image: tree.json (private), engine.py, service.py, - success.py (Legion's success check), export.py (the collect hook) + success.py (exit status), export.py (the collect hook) tests/ the grader's own image: test.sh, grade.py, expected.json solution/solve.sh an oracle that walks the shortest path with `maze move` template/ the files every task shares (generate.py copies them) -legion/ - spec.template.yaml what every team's Legion run shares: model, board rules, loop, limits - team.py writes one team's spec (the HF cluster, or local docker) - registries.conf podman pulls Docker Hub images through mirror.gcr.io - sweep/ the scaling sweep (every tree at N = 1..16, one model per grid): its README -eval/metrics.py one row per team from Legion run directories generate.py writes tasks/ from its seed (115) budget.py the move-budget table below, from the service's own engine check.py the checks that need no model @@ -114,17 +103,15 @@ doesn't count), it writes 0 before it checks anything, never writes through a li Python runs isolated (`python3 -I -S`). It keeps copies of `moves.jsonl` and `final.json` in `/logs/verifier/` for the metrics. -**Stop on success.** Legion's `stop_on_success` with the service's `success_check` -(`python3 -I -S /app/success.py`, run in the maze service, never in the agent's container) -ends the run when the first agent gets out: the check is read-only and prints -`{"success": , "evidence": {"exit_reached", "moves", "reached_at"}}` -from the service's state. Legion polls it every 30 s per agent, then interrupts the turns, -releases the workers and grades each agent's Trial. +**Exit status.** Run `python3 -I -S /app/success.py` in the maze service to read the exit state. +It prints JSON with a `success` boolean and, when available, evidence with `exit_reached`, +`moves` and `reached_at`. A team runner can use this signal to end the search before grading +the Trials. ## The move budget Simulated with the service's own engine (`template/environment/maze/engine.py`: every move -goes through the same `Walk` the service holds), without Legion or containers: +goes through the same `Walk` the service holds), without containers: `python budget.py` over the 32 trees, for N agents and a per-agent budget: - **(a)** one agent, depth-first: the first door it hasn't been through, in the listed order, @@ -186,91 +173,21 @@ habits of 1, 0.8, 0.5 and 0 (`--habit 0`: independent random orders), and at N = (c) is what sharing explored branches can buy. The budget is in every task's tree, grader, instruction and `task.toml` (`move_budget`). -## Run it with Legion on the HF cluster +## Run a Harbor task -The maze needs a second container per agent, so it runs where Legion runs Trials in docker or -podman. On the HF cluster: `compute: slurm`, one worker on **hopper-cpu** running the whole -team in rootless podman with `podman-compose` (hopper-cpu has podman 4.9.3; the B200 nodes' -podman 3.4.4 can't create Legion's per-agent networks), and a local board on that worker, new -each run. Legion's [`experiments/s3-maze/spec.yaml`](https://github.com/huggingface/legion/tree/main/experiments/s3-maze) -runs one team (`TREE`, default `maze-t01`, and `N`, default 4) at the revision it pins; Legion's -`docs/tasks.md` ("s3-maze") has the commands. For any other team, `legion/team.py` writes the -spec from `legion/spec.template.yaml`, run from Legion's checkout: +The maze uses two containers per Trial, so use Docker or Podman. Validate the search and +grader with Harbor's oracle: ```sh -DS=/fsx/$USER/s3-maze # this dataset on the shared disk (the workers read registries.conf) -hf download HuggingFaceSwarms/s3-maze --repo-type dataset --revision --local-dir $DS -uv run python $DS/legion/team.py --tree 7 --agents 4 --out runs/src/maze-t07-n04 -uv run legion init $PWD/runs/maze-t07-n04 --from runs/src/maze-t07-n04 --profile cluster.env --secrets secrets.env -export LEGION_RUN_DIR=$PWD/runs/maze-t07-n04 -uv run legion launch $LEGION_RUN_DIR/experiment -uv run legion status maze-t07-n04 # STOPPED ON SUCCESS once an agent gets out -uv run legion stop maze-t07-n04 --release # ends the controller (and a run nobody won) -uv run python $DS/eval/metrics.py $LEGION_RUN_DIR +uv run --with harbor==0.25.0 harbor run --path tasks/maze-t01 --agent oracle --env docker ``` -**Needs:** a cluster profile with `SLURM_PARTITION=hopper-cpu`, `SLURM_MAX_MEM_PER_CPU_MB=2000`, -`VENV` (Legion's venv on the shared disk) and `CONTAINERS_REGISTRIES_CONF=$DS/legion/registries.conf` -(Docker Hub's pull limit hits the cluster's shared address hard); and a mode-600 secrets file -with `HF_TOKEN` (reads this private dataset and the run's bucket), `HF_INFERENCE_TOKEN` (a -fine-grained token with only "Make calls to Inference Providers", which goes into the agents' -containers: never the same token), `NAMESPACE` and `BUCKET` (a private bucket for the run's -state). The worker gets a CPU per agent and two more, at 1900 MB per CPU. hopper-cpu -autoscales: a scale-up from 0 can take about 15 minutes. - -With stop on success, the run ends when the first agent reaches the exit: Legion grades every -Trial as it releases the worker, and the worker copies the grading (with the move logs) and the -board export to `/results/` (Legion's `LEGION_RESULTS_DIR`), where `metrics.py` reads -them. A run that nobody wins ends its loop after 45 minutes or 6 rounds, and doesn't end by -itself on Slurm: `legion stop --release` drains the worker, which is when its Trials are graded. - -### The board rules - -The same for every eval run, since they shape how agents talk (`legion/spec.template.yaml`): -one channel, `#general`, and no more (`max_channels: 1`); an agent is woken by a mention or a -reply in its thread; a post is at most 1000 characters, at least 5 s after the agent's previous -one, and at most 40 per agent. Podman enforces them in each agent's rule proxy. - -### The protocol hint - -`team.py --hint` adds `legion/team.md` as the team's `team_file`, which Legion appends to each -agent's instructions: "Before you go through a door, read the board and post which door you are -taking; pick one no teammate has claimed; post when a branch is a dead end." Without it, the -team gets the neutral instructions. +For a cooperative run, give each participant its own Trial of the same task and supply a +shared message board. The team succeeds if any participant earns 1. -## Metrics +The maintained team recipe connects the exit status and a shared board. [Legion experiment](https://github.com/huggingface/legion/tree/main/experiments/s3-maze) -`uv run python eval/metrics.py RUN_DIR [RUN_DIR ...] [--out rows.jsonl]` writes one JSON line -per run directory (one team), as s3-aggregation's does, with the maze's fields added from the -move logs the grader keeps: - -| field | | -| --- | --- | -| `task`, `agents`, `revision`, `stop_reason`, `duration_s` | the team and how its run ended | -| `success` | any agent's reward is 1 (`null`: no rewards found) | -| `rewards` | each agent's reward: its latest Trial's verifier result | -| `tokens`, `cost_usd` | the team's tokens (input, output, cache, reasoning) and cost | -| `posts`, `other_posts` | the team's board posts in the run; posts by anyone else | -| `per_agent` | each agent's reward, tokens, posts and turns | -| `edges` | the message graph: sender -> each teammate it mentions (a group mention names every member) or messages directly (a DM, or a private channel of the two) | -| `centralization` | the paper's (Appendix M): the sum over agents of (k* - k_j) / (N - 1)^2, k_j the in-degree; `null` for N = 1 | -| `reciprocity` | the fraction of edges whose reverse exists; `null` without edges | -| `moves`, `refused_moves` | each agent's accepted and refused moves (over all its Trials) | -| `rooms`, `rooms_union` | the rooms each agent visited (the start included), and the team's together | -| `room_overlap` | the paper's (Appendix M): (V - U) / V, V = sum_i (\|R_i\| - 1), U = \|union of the R_i\| - 1: 0 when no two agents visit the same room, near 1 when all walk the same path; `null` when no agent moved | -| `exit_reached_by` | the agents whose walk reached the exit | -| `first_exit` | the first agent to reach the exit, how long after the team's Trials started, with how many moves of its own, and the team's moves by then; `null` when no agent got out | -| `missing` | what the run directory lacks (an agent's reward or move log, a move log's unreadable line, the board export), and where its spec and its Trials disagree | - -A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier -result: the agent's container can write into its `verifier/` folder while it works, and only -the verifier's run replaces what is there. A Slurm run has no local bundle, so there the tokens -come from Harbor's Trial results (no reasoning split), and `stop_reason`, `cost_usd` and the -turns are `null`. Its task and roster come from `experiment/spec.yaml` as the run resolved it: -`${VAR}`s from `cluster.env` then `run.env`, else their defaults. Every agent the spec planned -is in the row, so one whose results are missing is flagged rather than dropped; so are Trials -of an agent the spec didn't plan, or of another task than it selects (e.g. a run directory -whose `run.env` is gone, read with the defaults). +The prior sweep and metrics are archived with the original run setup. [Dataset revision `3421ea2`](https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze/tree/3421ea2d46e8963e59cf3690da6ea47739eefb2f) ## Checks @@ -278,15 +195,10 @@ The checks that need no model, in one command, on a machine with podman (or dock Trials (`uv` installs Harbor 0.25.0): ```sh -uv run check.py --env podman # all of them (on the HF cluster: a hopper-cpu node, below) +uv run check.py --env podman # include the Trials uv run check.py --env none # without the Trials ``` -On the HF cluster, from Legion's checkout, with rootless podman set up as a worker has it: -`srun -p hopper-cpu -c 8 --mem=15G bash -c 'source scripts/slurm/podman-node.sh && -CONTAINERS_REGISTRIES_CONF=$DS/legion/registries.conf .venv/bin/python $DS/check.py --env podman; -podman_node_cleanup'`. - 1. **Generator:** `generate.py` reproduces `tasks/` byte for byte, and another seed gives other trees, which record that seed in their `task.toml` and regenerate from it. Each tree has 391 rooms with distinct 4-digit labels, is a tree (390 two-way doors, all reachable), has 27 dead ends all 30 moves from the start, one of them the exit; the @@ -322,15 +234,8 @@ podman_node_cleanup'`. `maze` command and names no room, nor do the instruction, `task.toml` or the compose file; the exit is named only in the service's `tree.json`, `tests/expected.json` and `solution/solve.sh`; no folder beside `tasks/` holds a tree. -5. **Metrics** (`eval/metrics.py`) on Slurm run directories made of the service's real exports - and the grader's real grades, with Legion's example spec (`${TREE:-maze-t01}`, - `${N:-4}`): with no env files the row's task is `maze-t01` and its team four agents; - `run.env` (over `cluster.env`) sets another tree and team size; a team with one agent's - results gone keeps that agent and flags its reward and move log as missing; and the row - flags Trials of another task than the spec selects (a `run.env` gone) and of an agent the - spec didn't plan. -6. **Trials** (`--env podman` or `docker`, on `maze-t01`, with agents that need no model): - - a walker runs Legion's success check in the maze service (false), walks the shortest path +5. **Trials** (`--env podman` or `docker`, on `maze-t01`, with agents that need no model): + - a walker runs the exit status check in the maze service (false), walks the shortest path with `maze move`, runs it again (true), and scores 1, with the move log and the export in its verifier's folder; - Harbor's oracle agent (`solution/solve.sh`) scores 1; @@ -341,50 +246,20 @@ podman_node_cleanup'`. `/logs/artifacts` and `/logs/verifier`, a `reward.txt` of 1, a `json.py` and a `sitecustomize`, makes three moves short of the exit, and scores 0. -Last run on a hopper-cpu node (podman 4.9.3), before the Legion rename: all checks passed. - -## Dummy run - -One team, `maze-t01` with N = 4, from the pre-rename `experiments/s3-maze/spec.yaml` (dataset revision -`0f1fe651`, whose `tasks/` are this revision's) on the HF cluster on 2026-11-17: -`Qwen/Qwen3.8-27B` on the HF router (deepinfra), one hopper-cpu worker of 6 CPUs running the -four Trials in rootless podman, and a local board. - -- **The team found the exit.** agent-003 reached it after 154 moves, 10 min 22 s after the - Trials started. Legion's success check saw it 27 s later, held the run, interrupted the other - agents and released the worker; every Trial was graded within a minute and the worker ended, - at 11:50 UTC. Only agent-003 scored 1. -- **They split the tree on the board** without being told to: agents posted the corridors they - walked, claimed branches at junctions, reported each dead end and re-planned around a silent - teammate; agent-003 took the last unclaimed branch at the start room, and found the exit there. -- **The budget binds.** agent-002 wrote a search script that walked into one dead end and then - bounced between it and its neighbour until its 200th move, and posted once. -- **The metrics row** (`eval/metrics.py` on the run directory): `success` true; rewards 0, 0, 1, - 0; posts 7, 1, 12, 10; moves 101, 200, 154, 158 (one refused); rooms 52, 31, 93, 89, 211 - together; room overlap 0.195; no @-mentions or DMs, so no edges (centralization 0, - reciprocity `null`); 413k input, 6.86M cached and 70k output tokens, about $1.20 on deepinfra; - nothing missing. - ## Known limits - **HF Sandboxes can't run it:** each agent's Trial is two containers (the agent's and its maze service), and HF Sandboxes run one container per Trial. It needs multi-container support there, as AgentEscapeBench does. Until then it runs on docker or podman (the HF cluster). -- **Private for now**, so whatever resolves and downloads the task (Legion's worker, and - `legion init`/`launch`) needs a Hub token that can read it. The agents' containers never do. -- **A new Trial starts a new maze.** If an agent's Trial fails and Legion starts another (or a - worker is relaunched), that agent gets a fresh copy of the maze at the start, with a fresh - budget, while its Pi session remembers the old walk. `metrics.py` counts moves over all of an - agent's Trials, and its reward is its latest Trial's. -- **The first exit ends the run, not the episode at once:** Legion checks every 30 s, so the - other agents may move for up to about 30 s more before their turns are interrupted. +- **A new Trial starts a new maze.** It starts with a fresh position and move budget. + - **The grader trusts the maze service.** The agent reaches it only through `maze look` and `maze move` (an internal network, two routes, bodies up to 4 KiB); an agent that could reach the service any other way could forge its record. The service runs without capabilities, with a pids and memory limit, so flooding it only hurts the agent's own maze. -- **The move log's `agent`** is the Trial's compose project (`--tN`), which names - the Legion agent; `metrics.py` attributes moves by the Trial's folder instead. +- **The move log's `agent`** identifies the Trial's compose project. + - **Not the paper's setup:** a per-agent move budget instead of a token allowance (looking and refused moves are free), a message board instead of `message`/`read_messages` tools with - notifications, Legion's loop prompting again at each turn's end, the moves left in every + notifications, the moves left in every observation, and N = 1 is a solo control. diff --git a/budget.py b/budget.py index cb80a4a0d570ab747ca8263dcd7e9cb7e9fee418..f35e67394e85782f2b9e67cb23f8e4e3f1e66b40 100644 --- a/budget.py +++ b/budget.py @@ -3,7 +3,7 @@ Simulates searches on the 32 trees in tasks/ with the maze service's own engine (template/environment/maze/engine.py: every move goes through engine.Walk, which refuses what -the service refuses), without Legion or containers, and prints the success rate of each strategy +the service refuses), without containers, and prints the success rate of each strategy by team size N and per-agent move budget, as the Markdown table in README.md: - (a) one agent, depth-first: it takes the first door it hasn't been through, in the order the diff --git a/check.py b/check.py index 98cbfe69c9ce7eda15ace7d6b6b635fa4688ed37..72c00efb7ccb503fd082e9a7e74968cc1df5e4b3 100644 --- a/check.py +++ b/check.py @@ -1,6 +1,6 @@ # /// script # requires-python = ">=3.12" -# dependencies = ["harbor==0.25.0", "pyyaml"] +# dependencies = ["harbor==0.25.0"] # /// """s3-maze's checks that need no model (huggingface/legion#115, section 5): @@ -27,7 +27,7 @@ no answer names a room other than the current one and its doors (or what the agent asked for); the exit is named only once the agent stands in it. The move log has one record per move request, refused ones included, each with agent, from, to and time, and its accepted - moves are the walk. success.py (legion's success_check) says false until the exit is reached + moves are the walk. success.py says false until the exit is reached and true after, and false for a missing or linked state file; export.py writes the service's record for the grader; a restarted service resumes the walk. The `maze` command prints the service's JSON and exits 0, 1 for a refused move, 2 for a usage error. @@ -48,16 +48,8 @@ Dockerfile and the `maze` command, and names no room; nor do the instruction, task.toml or the compose file; the exit is named only in environment/maze/tree.json, tests/expected.json and solution/solve.sh; and no folder beside tasks/ holds a tree. -5. Metrics (eval/metrics.py) on Slurm run directories made of real exports and grades, with - the example spec's `${TREE:-maze-t01}` and `${N:-4}`: with no env files the row's task is - maze-t01 and its team four agents; `run.env` (over `cluster.env`) sets another tree and team - size, also with comments after quoted and unquoted values (read as legion reads them); a team - with one agent's results gone keeps that agent and flags its reward and move - log as missing; and the row flags Trials of another task than the spec selects (a `run.env` - gone) and of an agent the spec didn't plan, and a winning move log whose last line was cut - off. -6. Trials (`--env`), on maze-t01, with agents that need no model: - - a walker checks legion's success_check in the maze service (false), walks the shortest path +5. Trials (`--env`), on maze-t01, with agents that need no model: + - a walker checks success.py in the maze service (false), walks the shortest path with `maze move`, checks it again (true), and scores 1; the verifier's folder then holds the move log and the export; - Harbor's oracle agent (solution/solve.sh) scores 1; @@ -92,9 +84,7 @@ HERE = Path(__file__).resolve().parent sys.dont_write_bytecode = True # nothing new in tasks/ or template/ sys.path.insert(0, str(HERE)) sys.path.insert(0, str(HERE / "template" / "environment" / "maze")) -sys.path.insert(0, str(HERE / "eval")) import generate as g # noqa: E402 -import metrics # noqa: E402 from engine import Maze, Walk # noqa: E402 LABEL = re.compile(rf"R\d{{{g.DIGITS}}}") @@ -681,108 +671,13 @@ def check_files() -> None: check(holders == {"environment/maze/tree.json", "tests/expected.json", "solution/solve.sh"}, f"{task.name}: the exit is named in {holders}") beside = {p.name for p in HERE.iterdir() if p.is_dir()} - { - "tasks", "template", "legion", "eval", ".cache", "__pycache__", ".git"} + "tasks", "template", ".cache", "__pycache__", ".git"} check(not beside, f"folders beside tasks/: {sorted(beside)}") check(not LABEL.search("".join(p.read_text(errors="ignore") for p in (HERE / "template").rglob("*") if p.is_file())), "template/ names a room") -# ------------------------------------------------------------------ metrics - -# The example spec's lines that metrics.py reads (Legion's experiments/s3-maze/spec.yaml) -RUN_SPEC = """name: ${RUN_NAME:-s3-maze} -naming: consecutive-id -task: - repo: https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze - selector: ${TREE:-maze-t01} - revision: REVISION -agents: - count: ${N:-4} -""" - - -def run_dir(root: Path, work: Path, tree: str, walks: dict[str, bool], - env_files: dict[str, str]) -> Path: - """A Slurm run's directory, as `legion init` and the workers leave it: the spec, the env - files and, per agent in `walks`, one Trial of `tree` (the exit reached or not) graded by the - task's own grader on the maze service's own export.""" - task = HERE / "tasks" / tree - layout = tree_of(task) - (root / "experiment").mkdir(parents=True) - (root / "experiment" / "spec.yaml").write_text(RUN_SPEC) - for name, text in env_files.items(): - (root / name).write_text(text) - for k, (agent, wins) in enumerate(walks.items()): - rooms = g.shortest_path(layout) if wins else dead_end_walk(layout, 20) - source = evidence(task, work, f"{root.name}-{agent}", rooms) - trial = root / "results" / "s3-maze" / agent / "trials" / f"s3-maze-{agent}-t1" - env = {**os.environ, "EVIDENCE_DIR": str(source), "VERIFIER_DIR": str(trial / "verifier")} - subprocess.run(["bash", str(task / "tests" / "test.sh")], env=env, capture_output=True, - timeout=60, check=True) - reward = float((trial / "verifier" / "reward.txt").read_text()) - (trial / "result.json").write_text(json.dumps({ - "task_name": f"HuggingFaceSwarms/{tree}", "trial_name": trial.name, - "started_at": f"2026-11-17T11:38:1{k}+00:00", - "finished_at": "2026-11-17T11:50:04+00:00", - "agent_result": {"n_input_tokens": 1000, "n_cache_tokens": 800, "n_output_tokens": 50}, - "verifier_result": {"rewards": {"reward": reward}}})) - return root - - -def check_metrics(work: Path) -> int: - team4 = {f"agent-{k:03d}": k == 3 for k in range(1, 5)} - cases = { # name: (tree, walks, env files, task, agents, missing besides the board export) - "defaults": ("maze-t01", team4, {}, "maze-t01", 4, []), - "run.env": ("maze-t02", {"agent-001": True, "agent-002": False}, - {"cluster.env": "N=3\nTREE=maze-t05\n", - "run.env": "#TREE=maze-t01\nTREE=maze-t02\nN=2\nRUN_NAME=s3-maze-b\n"}, - "maze-t02", 2, []), - # comments after values, read as legion's read_env_file does: a quoted value ends at - # its quote, an unquoted one at ` #` - "comments in env files": ("maze-t02", {"agent-001": True, "agent-002": False}, - {"cluster.env": "export N=3 # three\nTREE=maze-t05 # five\n", - "run.env": "TREE=\"maze-t02\" # group\nN=2 # pair\n" - "RUN_NAME='s3-maze-c' # name\n"}, - "maze-t02", 2, []), - "an agent's results gone": ("maze-t01", {a: w for a, w in team4.items() - if a != "agent-004"}, {}, "maze-t01", 4, - ["reward: agent-004", "move log: agent-004"]), - "run.env gone": ("maze-t02", {"agent-001": True, "agent-002": False}, {}, "maze-t01", 4, - ["task: the spec selects 'maze-t01', the Trials ran maze-t02", - "reward: agent-003", "reward: agent-004", "move log: agent-003", - "move log: agent-004"]), - "an unplanned agent": ("maze-t01", {"agent-001": True, "agent-002": False, - "agent-003": False}, {"run.env": "N=2\n"}, - "maze-t01", 2, - ["agents: Trials of agents the spec didn't plan: agent-003"]), - } - for case, (tree, walks, env_files, task, agents, missing) in cases.items(): - name = "run-" + re.sub(r"\W+", "-", case) - r = metrics.row(run_dir(work / name, work, tree, walks, env_files)) - expected_rewards = {a: float(w) for a, w in walks.items() if a in r["rewards"]} - check(r["task"] == task and r["agents"] == agents and len(r["rewards"]) == agents, - f"metrics, {case}: task {r['task']!r}, {r['agents']} agents, not {task!r}, {agents}") - check(sorted(r["missing"]) == sorted(missing + ["board export"]), - f"metrics, {case}: missing {r['missing']}") - check({a: v for a, v in r["rewards"].items() if v is not None} == expected_rewards - and r["success"] is any(expected_rewards.values()), - f"metrics, {case}: rewards {r['rewards']}") - moved = {a: 30 if w else 20 for a, w in walks.items() if a in r["rewards"]} - check({a: n for a, n in r["moves"].items() if a in moved} == moved, - f"metrics, {case}: moves {r['moves']}") - # a winning move log whose last line was cut off (a Trial stopped mid-write): its moves and - # its exit are unknown, so the row flags it as missing rather than counting 29 moves - root = run_dir(work / "run-a-cut-off-move-log", work, "maze-t01", - {"agent-001": True, "agent-002": False}, {"run.env": "N=2\n"}) - log = root / "results/s3-maze/agent-001/trials/s3-maze-agent-001-t1/verifier/moves.jsonl" - log.write_text(log.read_text().rstrip("\n")[:-20]) - r = metrics.row(root) - check(any(m.startswith("move log: agent-001 (line 30 of 30 unreadable)") for m in r["missing"]), - f"metrics, a cut-off move log: missing {r['missing']}") - return len(cases) + 1 - - # ------------------------------------------------------------------ Trials # Runs in the agent's container as `python3 -c PROBE_PY `; its config travels @@ -1029,15 +924,12 @@ def main() -> int: before = len(failures) check_files() print(f"4. no-cheat (files): {len(failures) - before} failures") - before = len(failures) - cases = check_metrics(work) - print(f"5. metrics: {len(failures) - before} failures; {cases} run directories") if args.env != "none": before = len(failures) jobs = args.jobs_dir or work / "jobs" jobs.mkdir(parents=True, exist_ok=True) report = asyncio.run(check_trials(args.env, jobs, work)) - print(f"6. Trials on {args.env} ({PROBE_TASK}): {len(failures) - before} failures; " + print(f"5. Trials on {args.env} ({PROBE_TASK}): {len(failures) - before} failures; " f"{json.dumps(report)}") for failure in failures: print("FAIL:", failure) diff --git a/eval/metrics.py b/eval/metrics.py deleted file mode 100644 index 0b2ec17dcb74bdb536862e616174bab63f5c4b15..0000000000000000000000000000000000000000 --- a/eval/metrics.py +++ /dev/null @@ -1,404 +0,0 @@ -"""One row per team from s³ runs (huggingface/legion#115): `uv run eval/metrics.py -RUN_DIR [RUN_DIR ...] [--out rows.jsonl]`. - -s3-aggregation's eval/metrics.py, with s3-maze's move-log metrics added (`maze_moves` in -EXTRAS). A run directory is one team: a local run's bundle (`.legion/-