|
Download README.md from HuggingFaceSwarms/s3-aggregation: direct link, hf CLI and curl.
- Browser
- Download file 17.7 kB
-
https://huggingface.co/datasets/HuggingFaceSwarms/s3-aggregation/resolve/main/README.md
- Command line
-
hf download hf://datasets/HuggingFaceSwarms/s3-aggregation/README.md
-
curl -L -o README.md https://huggingface.co/datasets/HuggingFaceSwarms/s3-aggregation/resolve/main/README.md
17.7 kB
| pretty_name: s3-aggregation | |
| license: apache-2.0 | |
| language: | |
| - en | |
| tags: | |
| - harbor | |
| - agent-environment | |
| - multi-agent | |
| - message-board | |
| size_categories: | |
| - n<1K | |
| # s3-aggregation | |
| A [Harbor](https://harborframework.com) environment that measures whether a swarm of agents | |
| **communicates**: each agent holds one private number, and no agent can solve the task alone. It | |
| adapts the information-aggregation 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. | |
| **This dataset is private for now.** | |
| ## The task | |
| Each of the N agents holds one private integer from 1 to 99, written in English words | |
| ("seventy-three"). The team must list all N numbers in ascending order, keeping equal numbers | |
| from different agents as separate entries. Each agent finds its number in its instruction, | |
| shares it on the board, reads the others', keeps one number per participant, writes | |
| `/app/answer.json` (a JSON array of N integers in ascending order) and stops. The team succeeds | |
| if any agent's answer is right. The instruction adapts the paper's (Appendix G) to the board and | |
| prescribes no protocol beyond that. | |
| | | | | |
| | --- | --- | | |
| | Problems | 32 (the paper's held-out set size), each 16 integers drawn uniformly from 1 to 99, repeats allowed, from a fixed seed | | |
| | Teams | 160: one per problem and team size N ∈ {1, 2, 4, 8, 16}, holding the problem's first N numbers, e.g. `agg-p07-n08` | | |
| | Tasks | 992: one per slot of each team, `agg-p07-n08-s01` .. `-s08`, whose instruction states that slot's number | | |
| | Image | `python:3.12-slim`, prebuilt and public (no Dockerfile): HF Sandboxes, docker and podman | | |
| | Agent / verifier timeout | 1800 s / 60 s | | |
| | Resources | 1 CPU, 1 GB memory per agent | | |
| ```text | |
| tasks/agg-pPP-nNN-sKK/ slot K of team agg-pPP-nNN (zero-padded: name order is slot order) | |
| instruction.md "Your private number is ...": slot K's, and no other | |
| task.toml | |
| tests/test.sh the grader, the same for every slot of the team | |
| tests/expected.json the team's answer: copied in only after the agent is done | |
| solution/solve.sh an oracle with its own copy of the answer | |
| legion/ | |
| spec.template.yaml what every team's Legion run shares: model, board rules, loop, limits | |
| team.py writes one team's spec (docker, HF Sandboxes or the HF cluster) | |
| sweep/ the scaling sweep on the HF cluster (legion/sweep/README.md) | |
| eval/metrics.py one row per team from Legion run directories | |
| problems.json the 32 problems | |
| generate.py writes problems.json and tasks/ from its seed (115) | |
| check.py the checks that need no model | |
| ``` | |
| **Private numbers** reach each agent only through its own task. Legion runs a team with the | |
| selector `agg-pPP-nNN-s*`, `agents.count: N` and `naming: consecutive-id`: the selector matches | |
| the team's N slots, sorted by name, and `agent-00K` runs slot K's task, so its instruction | |
| holds its own number and no one else's. A task folder puts nothing in the container while the | |
| agent works (no `environment/`; `tests/` arrives after the agent is done), so no agent can read | |
| another agent's number until that agent posts it. | |
| ## Reward | |
| `tests/test.sh` writes reward **1** to `/logs/verifier/reward.txt` when `/app/answer.json` is | |
| exactly `tests/expected.json`: a JSON array of the team's integers in ascending order, one per | |
| agent. Anything else scores **0**: a missing or unreadable file, invalid JSON, `NaN`, a | |
| non-array, strings, words, floats or booleans, a missing, extra or dropped duplicate number, and | |
| a wrong order. The answer counts only as a regular file of its own at exactly | |
| `/app/answer.json`: a symlink (e.g. to `/tests/expected.json`, which arrives only after the | |
| agent is done), a link anywhere on the path (a symlinked `/app`), a hardlink, a directory or a | |
| FIFO scores 0, and `expected.json` is read the same way. The grader follows no link an agent may | |
| have left, writes 0 before it checks anything (a crash also scores 0), and keeps a copy of the | |
| answer with the trial's results. Its Python runs isolated (`python3 -I -S`), so no module in the | |
| working directory or on `PYTHONPATH`, and no `sitecustomize`, `usercustomize` or `.pth` hook, | |
| can change what it imports; besides `bash`, `python3` is the only command it runs. Each agent is | |
| scored on its own answer; the team succeeds if any agent scores 1. | |
| ## Run it with Legion | |
| Legion's [`experiments/s3-aggregation/spec.yaml`](https://github.com/huggingface/legion/tree/main/experiments/s3-aggregation) | |
| runs one team on HF Sandboxes (`TEAM`, default `agg-p01-n04`, with `N` its size) at the revision | |
| it pins: `uv run legion launch experiments/s3-aggregation/spec.yaml`. Its board is a public Space | |
| for the run: delete it afterwards. | |
| For any other team or place, `legion/team.py` writes the spec from `legion/spec.template.yaml`, | |
| run from Legion's checkout. **Needs** `HF_TOKEN`, which reads the private dataset (and starts the | |
| sandboxes and deploys the board's Space), and `HF_INFERENCE_TOKEN`, a fine-grained token with | |
| only "Make calls to Inference Providers", which goes into the agents' containers. Never the same | |
| token. Each agent of a team is `agent-001` ... (`naming: consecutive-id`), all one Legion type on | |
| one worker (`agents_per_worker: N`), so they share that worker's board. | |
| ### On HF Sandboxes | |
| The controller and the team's one worker run on this machine, each agent in its own HF Sandbox | |
| (`cpu-basic`) and the board on a Space: | |
| ```sh | |
| DS=../s3-aggregation # this dataset, at the revision team.py pins | |
| uv run python $DS/legion/team.py --problem 7 --agents 4 --where sandbox --out runs/agg-p07-n04 | |
| BOARD_SPACE=<you>/s3-agg-p07-n04 uv run legion launch runs/agg-p07-n04/spec.yaml | |
| uv run legion status agg-p07-n04 | |
| uv run python $DS/eval/metrics.py .legion/agg-p07-n04-<time>/ # once the run has ended | |
| hf repos delete <you>/s3-agg-p07-n04 --repo-type space -y # a new board for every team | |
| hf buckets delete <you>/s3-agg-p07-n04-bucket # its snapshots | |
| ``` | |
| The run ends by itself once its loop is over (4 rounds or 15 minutes) and every agent is idle, | |
| then Harbor grades each agent's `/app/answer.json` and the board is exported into the run | |
| directory. The board's Space must be public while the run uses it (the sandboxes hold no Hub | |
| token), and the instruction has no run tag, so give each team a new Space and delete it, and its | |
| snapshot bucket, once the run directory has the export. | |
| ### On the HF cluster | |
| `--where cluster` writes the spec for one Slurm worker running the team in rootless podman | |
| (hopper-cpu has podman 4.9), with a local board on that worker, new each run, so no Space. The | |
| run directory goes on the shared disk (Legion's docs/slurm.md "Deploying"): a cluster profile with | |
| `SLURM_PARTITION=hopper-cpu`, `WORKER_CPUS` and `WORKER_MEM` (at most 2000 MB per CPU there) | |
| and `VENV`, and a mode-600 secrets file with `HF_TOKEN`, `HF_INFERENCE_TOKEN`, `NAMESPACE` and | |
| `BUCKET` (a private bucket for the run's state): | |
| ```sh | |
| uv run python $DS/legion/team.py --problem 7 --agents 4 --where cluster --out runs/src/agg-p07-n04 | |
| uv run legion init $PWD/runs/agg-p07-n04 --from runs/src/agg-p07-n04 --profile cluster.env --secrets secrets.env | |
| export LEGION_RUN_DIR=$PWD/runs/agg-p07-n04 | |
| uv run legion launch $LEGION_RUN_DIR/experiment | |
| uv run legion status agg-p07-n04 # until the loop is done and the agents idle | |
| uv run legion stop agg-p07-n04 --release # drain: each Trial is graded, then the jobs end | |
| uv run python $DS/eval/metrics.py $LEGION_RUN_DIR | |
| ``` | |
| A Slurm run doesn't end by itself: `--release` drains its worker, which is when each Trial is | |
| graded. With Legion's Slurm results (huggingface/legion#122) the worker copies the grading | |
| and the board export to `<run dir>/results/` (its own files are in the node's `/tmp`), and | |
| `metrics.py` reads them from there. `legion/sweep/` runs the whole grid this way. | |
| ### The board rules | |
| The same for every eval run, since they shape how agents talk (`legion/spec.template.yaml`): one | |
| channel, `#general`, and no other (`max_channels: 1`: an agent can't create a channel); 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. | |
| One channel keeps every number in one place, as the paper's broadcast does (in earlier runs, | |
| without the cap, about 70% of Qwen3.5-2B teams made extra channels, though about 98% of their | |
| posts stayed in `#general`); waking on mentions and | |
| threads lets agents talk to each other without a reply to every post; the length, gap and count | |
| caps bound what a looping agent can flood the board with, well above what the task needs (one | |
| post per agent). Docker and podman enforce them in each agent's rule proxy. HF Sandboxes have no | |
| proxy, so there they are not enforced and each Trial records a `message_board.warning` event. | |
| ## Metrics | |
| `uv run python eval/metrics.py RUN_DIR [RUN_DIR ...] [--out rows.jsonl]` writes one JSON line | |
| per run directory (one team): a local run's `.legion/<swarm>-<time>/`, or a Slurm run's | |
| directory. 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`: | |
| | 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; 0 when every agent receives from as many teammates, 1 when one receives from all and no one else from anyone; `null` for N = 1 | | |
| | `reciprocity` | the fraction of edges whose reverse exists; `null` without edges | | |
| | `missing` | what the run directory lacks: an agent's reward, the board export | | |
| Only messages posted between the run's start and end count. A post that mentions no one adds no | |
| edge: on a board everyone reads every post, so a broadcast edge (the paper's) would connect | |
| every pair that posts. s3-maze adds its move-log metrics to the same rows (`EXTRAS`). | |
| ## Checks | |
| The checks that need no model, in one command (`uv` installs Harbor 0.25.0): | |
| ```sh | |
| uv run check.py # the Trials on HF Sandboxes (HF_TOKEN, twenty cpu-basic sandboxes) | |
| uv run check.py --env docker # the Trials in local docker | |
| uv run check.py --env none # without the Trials | |
| uv run check.py --env none --run RUN_DIR # also a Legion run of a team (below) | |
| ``` | |
| 1. **Generator:** `generate.py` reproduces `problems.json` and `tasks/` byte for byte; another | |
| seed gives other problems; 32 problems of 16 integers in 1..99; the words read back to their | |
| numbers; each team has one task per slot, whose answer is the problem's first N numbers | |
| sorted and whose instruction states that slot's number, and name order is slot order. | |
| 2. **Graders**, run as Harbor runs them (`tests/` copied in after the agent is done, through | |
| any link the agent left), on slot 1 of each team (every slot's `tests/` and `solution/` are | |
| the same, which this checks): on all 160 teams the oracle scores 1, and wrong, partial, | |
| padded, unsorted and duplicate-dropping answers score 0. On one team per size, twelve kinds | |
| of malformed answer score 0, and so do sixteen cheats: the answer as a symlink to the tests' | |
| `expected.json` (dangling until the tests arrive; absolute or relative), a symlink or a | |
| hardlink to a right answer elsewhere, a hardlink to `expected.json`, a symlinked `/app` (to a | |
| right answer, or into the tests' folder), an `expected.json` planted as a link to the answer, | |
| a directory and a FIFO (which must not hang the grader); and a wrong answer with Python made | |
| to read any answer as right: a `json.py` in the grader's working directory or on | |
| `PYTHONPATH`, a `sitecustomize` on `PYTHONPATH`, a `usercustomize` or a `.pth` file in the user | |
| site, and a `dirname` shadowed on the `PATH` that points `expected.json` at the agent's file. | |
| 3. **No-cheat, in the files:** a task folder holds only its five files; its instruction states | |
| its own slot's number on one line and is otherwise the same for every task of its team size, | |
| so it holds no teammate's number; the answer is only in `tests/` and `solution/`; and no | |
| folder beside `tasks/` holds numbers. | |
| 4. **No-cheat, from inside Trials** of team `agg-p01-n16`, with probe agents (no model): sixteen | |
| probes, one in each slot's task, look around the container while "the agent works": every | |
| file, every process's environment and command line, and the instruction. Each finds its own | |
| number only in its instruction, and no teammate's number, no `tests/` or `solution/` and no | |
| file holding the answer anywhere; then it writes the answer, the same search finds it (a | |
| control), and the task's verifier scores it 1. Four more leave a cheat with a wrong answer, | |
| and the verifier scores each 0: `/app/answer.json` as a symlink to `/tests/expected.json`; | |
| `/app` as a symlink into a `/tests` they made; a `json.py` that reads any answer as right | |
| wherever the verifier may start; a `sitecustomize` in site-packages that does the same. | |
| 5. **No-cheat, a Legion run** (`--run RUN_DIR`, a local run's `.legion/<swarm>-<time>/`): each | |
| agent's first prompt (its task's instruction and Legion's) holds its own number and no | |
| teammate's; the first tool output in which an agent sees a teammate's number is a board read, | |
| after that teammate posted it; and the first post holding each number is its owner's. A | |
| number counts in words and in digits where they read as a held number: an array of the | |
| team's integers (the JSON answer, or part of it, down to `[26]`), an agent's number in a | |
| mapping (`"agent-002": 26`) or a stated number (`number is 26`); bare ids, counts and | |
| timestamps don't. A board read is a `legion-tool message_board.*` command, not one that names | |
| the board (`cat /tmp/message_board.txt`). The audit itself runs on synthetic runs every time: | |
| a clean one, and one whose ids and timestamps hold the team's numbers, pass; a teammate's | |
| number in words, the JSON answer, a one-element array, a mapping or a stated number in the | |
| first prompt or in a non-board output before the board (one from a file named after the board | |
| included) fail, and so does a number first posted by an agent that doesn't hold it. | |
| 6. **Metrics:** `eval/metrics.py` on Slurm run directories (the spec Legion's example copies, | |
| with `${TEAM:-...}` and `${N:-4}`, and Trials graded by the tasks' own grader): the task and | |
| the roster come from the spec as the run resolved it (`cluster.env`, then `run.env`, else the | |
| defaults), and a planned agent without results, Trials of an unplanned agent and Trials of | |
| another task than the spec selects are flagged in `missing`, never dropped. | |
| `--env` takes a Harbor environment type or an import path. Harbor 0.25.0's `hf-sandbox` uploads | |
| `tests/` with the host's file owner, which a sandbox can't take when the host's uid is over | |
| 65535 (some clusters); Legion's `--env legion.harbor.envs:HFSandbox`, with Legion installed, keeps | |
| no owner. | |
| To check the grader alone with Harbor: `harbor run --path tasks/agg-p07-n04-s01 --agent oracle --env hf-sandbox`. | |
| ## Known limits | |
| - **Private for now**, so whatever resolves and downloads the task (Legion's worker, which then | |
| uploads it into the sandbox) needs a Hub token that can read it. The sandboxes never do. | |
| - **A team needs one agent per slot.** Each slot's task is one agent's view: run a team's N | |
| slots together on one board (Legion's selector `agg-pPP-nNN-s*` with `agents.count: N`), or a | |
| task alone is an agent whose teammates never post. | |
| - **The grader can't see the board:** an agent could guess or copy a wrong number and still be | |
| scored only on its file. The board export in the run directory shows what was said. | |
| - **The verifier runs in the agent's container**, as in every Harbor task. The grader closes the | |
| file and import holes above, but an agent that replaced the container's `python3`, `bash` or | |
| Python's standard library, or left a process running to rewrite the reward, could still forge | |
| one: check the run's board export and the agents' transcripts when a result looks too good. | |
| - **One board per team.** The instruction has no run tag, so a reused board's earlier posts | |
| would read as this team's: give each team a new board (Legion's local board is new each run; | |
| delete a Space board after its run). | |
| - **Board rules** are enforced only where Legion's rule proxy runs (docker, podman); on HF | |
| Sandboxes they are not. | |
| - **Not the paper's setup:** a message board instead of `message`/`read_messages` tools with | |
| notifications, an answer file instead of a `####` line, no example message, no token cost in | |
| the reward, and N = 1 is a solo control rather than a team. | |