Reruns reserve servers under their own name; a cut-off move log is missing
Browse files#123 review #4: sweep.py reserves a rerun's server capacity under the -rK name it launches as (and an adopted team's under its in-flight run's name), since flock hashes agents by run and name. A worker not started 3 minutes after its launch is now released at once, so its team reruns without waiting out its time cap. #5: metrics.py flags any unreadable move-log line as missing, the last one included, with a check.py case (a winning log cut off mid-line). #6: the README and the spec template no longer say DMs work with max_channels: 1. tasks/ is unchanged.
- README.md +4 -5
- check.py +12 -2
- eval/metrics.py +3 -3
- flock/spec.template.yaml +1 -1
- flock/sweep/README.md +5 -2
- flock/sweep/sweep.py +29 -16
README.md
CHANGED
|
@@ -227,10 +227,9 @@ itself on Slurm: `flock stop --release` drains the worker, which is when its Tri
|
|
| 227 |
### The board rules
|
| 228 |
|
| 229 |
The same for every eval run, since they shape how agents talk (`flock/spec.template.yaml`):
|
| 230 |
-
one channel, `#general`, and no more (`max_channels: 1`
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
enforces them in each agent's rule proxy.
|
| 234 |
|
| 235 |
### The protocol hint
|
| 236 |
|
|
@@ -261,7 +260,7 @@ move logs the grader keeps:
|
|
| 261 |
| `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 |
|
| 262 |
| `exit_reached_by` | the agents whose walk reached the exit |
|
| 263 |
| `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 |
|
| 264 |
-
| `missing` | what the run directory lacks (an agent's reward or move log, the board export), and where its spec and its Trials disagree |
|
| 265 |
|
| 266 |
A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
|
| 267 |
result: the agent's container can write into its `verifier/` folder while it works, and only
|
|
|
|
| 227 |
### The board rules
|
| 228 |
|
| 229 |
The same for every eval run, since they shape how agents talk (`flock/spec.template.yaml`):
|
| 230 |
+
one channel, `#general`, and no more (`max_channels: 1`); an agent is woken by a mention or a
|
| 231 |
+
reply in its thread; a post is at most 1000 characters, at least 5 s after the agent's previous
|
| 232 |
+
one, and at most 40 per agent. Podman enforces them in each agent's rule proxy.
|
|
|
|
| 233 |
|
| 234 |
### The protocol hint
|
| 235 |
|
|
|
|
| 260 |
| `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 |
|
| 261 |
| `exit_reached_by` | the agents whose walk reached the exit |
|
| 262 |
| `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 |
|
| 263 |
+
| `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 |
|
| 264 |
|
| 265 |
A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
|
| 266 |
result: the agent's container can write into its `verifier/` folder while it works, and only
|
check.py
CHANGED
|
@@ -54,7 +54,8 @@
|
|
| 54 |
size, also with comments after quoted and unquoted values (read as flock reads them); a team
|
| 55 |
with one agent's results gone keeps that agent and flags its reward and move
|
| 56 |
log as missing; and the row flags Trials of another task than the spec selects (a `run.env`
|
| 57 |
-
gone) and of an agent the spec didn't plan
|
|
|
|
| 58 |
6. Trials (`--env`), on maze-t01, with agents that need no model:
|
| 59 |
- a walker checks flock's success_check in the maze service (false), walks the shortest path
|
| 60 |
with `maze move`, checks it again (true), and scores 1; the verifier's folder then holds
|
|
@@ -770,7 +771,16 @@ def check_metrics(work: Path) -> int:
|
|
| 770 |
moved = {a: 30 if w else 20 for a, w in walks.items() if a in r["rewards"]}
|
| 771 |
check({a: n for a, n in r["moves"].items() if a in moved} == moved,
|
| 772 |
f"metrics, {case}: moves {r['moves']}")
|
| 773 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 774 |
|
| 775 |
|
| 776 |
# ------------------------------------------------------------------ Trials
|
|
|
|
| 54 |
size, also with comments after quoted and unquoted values (read as flock reads them); a team
|
| 55 |
with one agent's results gone keeps that agent and flags its reward and move
|
| 56 |
log as missing; and the row flags Trials of another task than the spec selects (a `run.env`
|
| 57 |
+
gone) and of an agent the spec didn't plan, and a winning move log whose last line was cut
|
| 58 |
+
off.
|
| 59 |
6. Trials (`--env`), on maze-t01, with agents that need no model:
|
| 60 |
- a walker checks flock's success_check in the maze service (false), walks the shortest path
|
| 61 |
with `maze move`, checks it again (true), and scores 1; the verifier's folder then holds
|
|
|
|
| 771 |
moved = {a: 30 if w else 20 for a, w in walks.items() if a in r["rewards"]}
|
| 772 |
check({a: n for a, n in r["moves"].items() if a in moved} == moved,
|
| 773 |
f"metrics, {case}: moves {r['moves']}")
|
| 774 |
+
# a winning move log whose last line was cut off (a Trial stopped mid-write): its moves and
|
| 775 |
+
# its exit are unknown, so the row flags it as missing rather than counting 29 moves
|
| 776 |
+
root = run_dir(work / "run-a-cut-off-move-log", work, "maze-t01",
|
| 777 |
+
{"agent-001": True, "agent-002": False}, {"run.env": "N=2\n"})
|
| 778 |
+
log = root / "results/s3-maze/agent-001/trials/s3-maze-agent-001-t1/verifier/moves.jsonl"
|
| 779 |
+
log.write_text(log.read_text().rstrip("\n")[:-20])
|
| 780 |
+
r = metrics.row(root)
|
| 781 |
+
check(any(m.startswith("move log: agent-001 (line 30 of 30 unreadable)") for m in r["missing"]),
|
| 782 |
+
f"metrics, a cut-off move log: missing {r['missing']}")
|
| 783 |
+
return len(cases) + 1
|
| 784 |
|
| 785 |
|
| 786 |
# ------------------------------------------------------------------ Trials
|
eval/metrics.py
CHANGED
|
@@ -204,9 +204,9 @@ def maze_moves(run_dir: Path, team: list[str], trials: dict[str, list[Path]]) ->
|
|
| 204 |
for i, line in enumerate(lines):
|
| 205 |
try:
|
| 206 |
record = json.loads(line) if line.strip() else {}
|
| 207 |
-
except ValueError: #
|
| 208 |
-
|
| 209 |
-
|
| 210 |
continue
|
| 211 |
if record.get("ok") is True:
|
| 212 |
moves += 1
|
|
|
|
| 204 |
for i, line in enumerate(lines):
|
| 205 |
try:
|
| 206 |
record = json.loads(line) if line.strip() else {}
|
| 207 |
+
except ValueError: # e.g. cut off when the Trial stopped mid-write: the moves
|
| 208 |
+
# (or the exit) after it are unknown, so the run doesn't count
|
| 209 |
+
missing.append(f"move log: {name} (line {i + 1} of {len(lines)} unreadable)")
|
| 210 |
continue
|
| 211 |
if record.get("ok") is True:
|
| 212 |
moves += 1
|
flock/spec.template.yaml
CHANGED
|
@@ -35,7 +35,7 @@ resources:
|
|
| 35 |
max_len: 1000
|
| 36 |
min_post_gap: 5s
|
| 37 |
max_posts: 40
|
| 38 |
-
max_channels: 1
|
| 39 |
workers:
|
| 40 |
agents_per_worker: 1 # team.py: N, the whole team on one worker and board
|
| 41 |
turn_timeout: 20m
|
|
|
|
| 35 |
max_len: 1000
|
| 36 |
min_post_gap: 5s
|
| 37 |
max_posts: 40
|
| 38 |
+
max_channels: 1
|
| 39 |
workers:
|
| 40 |
agents_per_worker: 1 # team.py: N, the whole team on one worker and board
|
| 41 |
turn_timeout: 20m
|
flock/sweep/README.md
CHANGED
|
@@ -44,8 +44,11 @@ A run counts only when its worker started within 2 minutes of its launch (the lo
|
|
| 44 |
count from the launch), on one worker incarnation, with its controller kept, every agent's
|
| 45 |
reward and move log and the board export, and no agent's model server thrashing for 5 minutes or
|
| 46 |
more during it (below). Anything else is the infrastructure's: the team runs again as
|
| 47 |
-
`<task>-rK`, and `setaside.py` says why.
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
## Model servers: thinking, KV cache and names
|
| 51 |
|
|
|
|
| 44 |
count from the launch), on one worker incarnation, with its controller kept, every agent's
|
| 45 |
reward and move log and the board export, and no agent's model server thrashing for 5 minutes or
|
| 46 |
more during it (below). Anything else is the infrastructure's: the team runs again as
|
| 47 |
+
`<task>-rK`, and `setaside.py` says why. A worker still not started 3 minutes after its launch
|
| 48 |
+
is released at once, so its team reruns without waiting out its time cap. A rerun's server
|
| 49 |
+
capacity is reserved under the `-rK` name it runs as, since flock hashes agents by run and name.
|
| 50 |
+
What the model does (no move, no post, no exit) is a result. A restarted driver adopts the teams
|
| 51 |
+
in flight and keeps each team's own start time.
|
| 52 |
|
| 53 |
## Model servers: thinking, KV cache and names
|
| 54 |
|
flock/sweep/sweep.py
CHANGED
|
@@ -178,6 +178,12 @@ def wait_done(run_dir: Path, task: str, n: int, timeout: float) -> str:
|
|
| 178 |
that stops answering and isn't running (a spot reclaim requeued it, or it is gone) is LOST."""
|
| 179 |
deadline, unanswered, stopped = time.monotonic() + timeout, 0, None
|
| 180 |
while time.monotonic() < deadline:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
status = flock(run_dir, "status", task, timeout=120)
|
| 182 |
text = status.stdout
|
| 183 |
unanswered = unanswered + 1 if status.returncode != 0 else 0
|
|
@@ -340,14 +346,21 @@ def valid(row: dict) -> bool:
|
|
| 340 |
return not why_invalid(row)
|
| 341 |
|
| 342 |
|
| 343 |
-
def run_team(args, root: Path, secrets: Path, tree: int, n: int,
|
| 344 |
-
|
| 345 |
-
"""A team, run again (as `<task>-rK`) until its run counts.""
|
|
|
|
|
|
|
| 346 |
task = f"{args.tag}maze-t{tree:02d}-n{n:02d}"
|
| 347 |
row = None
|
| 348 |
for reruns in range(args.max_reruns + 1):
|
| 349 |
-
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if row is None:
|
| 352 |
return None
|
| 353 |
row["reruns"] = reruns
|
|
@@ -419,13 +432,13 @@ class Slots:
|
|
| 419 |
self.cond.notify_all()
|
| 420 |
|
| 421 |
|
| 422 |
-
def
|
| 423 |
-
"""The
|
| 424 |
-
|
| 425 |
for spec in sorted((root / "src").glob(f"{tag}maze-t{tree:02d}-n{n:02d}*/spec.yaml")):
|
| 426 |
if job_state(f"flock-ctl-{spec.parent.name}"):
|
| 427 |
-
return yaml.safe_load(spec.read_text())["inference"]["urls"]
|
| 428 |
-
return None
|
| 429 |
|
| 430 |
|
| 431 |
def upload(root: Path, dataset: str, prefix: str) -> None:
|
|
@@ -532,20 +545,20 @@ def main(argv=None) -> int:
|
|
| 532 |
f"{args.parallel} teams and {args.max_agents} agents at once, on {args.urls}")
|
| 533 |
slots = Slots(root, args.urls, args.parallel, args.max_agents, args.per_server)
|
| 534 |
|
| 535 |
-
def one(t: int, n: int, urls: list[str]):
|
| 536 |
try:
|
| 537 |
-
return run_team(args, root, secrets, t, n, urls)
|
| 538 |
except Exception as e: # noqa: BLE001 - one team's failure must not stop the grid
|
| 539 |
say(f"{args.tag}maze-t{t:02d}-n{n:02d}", "failed:", repr(e)[:300])
|
| 540 |
finally:
|
| 541 |
-
slots.give(n,
|
| 542 |
|
| 543 |
try:
|
| 544 |
with ThreadPoolExecutor(args.parallel) as pool:
|
| 545 |
for t, n in teams:
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
pool.submit(one, t, n, urls)
|
| 549 |
finally:
|
| 550 |
secrets.unlink(missing_ok=True)
|
| 551 |
if args.dataset:
|
|
|
|
| 178 |
that stops answering and isn't running (a spot reclaim requeued it, or it is gone) is LOST."""
|
| 179 |
deadline, unanswered, stopped = time.monotonic() + timeout, 0, None
|
| 180 |
while time.monotonic() < deadline:
|
| 181 |
+
# a worker that hasn't started WAIT_LIMIT after its launch can't count: stop waiting
|
| 182 |
+
# for the team now, so it runs again at once, rather than after its whole time cap
|
| 183 |
+
launches = list((run_dir / "launch").glob("*.env"))
|
| 184 |
+
if (launches and not any((run_dir / "logs").glob("*-agent-w*.out"))
|
| 185 |
+
and time.time() - min(p.stat().st_mtime for p in launches) > WAIT_LIMIT + 60):
|
| 186 |
+
return f"worker not started {WAIT_LIMIT + 60} s after its launch"
|
| 187 |
status = flock(run_dir, "status", task, timeout=120)
|
| 188 |
text = status.stdout
|
| 189 |
unanswered = unanswered + 1 if status.returncode != 0 else 0
|
|
|
|
| 346 |
return not why_invalid(row)
|
| 347 |
|
| 348 |
|
| 349 |
+
def run_team(args, root: Path, secrets: Path, tree: int, n: int, urls: list[str],
|
| 350 |
+
slots: "Slots", held: dict) -> dict | None:
|
| 351 |
+
"""A team, run again (as `<task>-rK`) until its run counts. `held["run"]` is the run name its
|
| 352 |
+
server capacity is reserved under: each attempt moves the reservation to its own name, since
|
| 353 |
+
flock hashes agents by run and name (a rerun's agents land on other servers)."""
|
| 354 |
task = f"{args.tag}maze-t{tree:02d}-n{n:02d}"
|
| 355 |
row = None
|
| 356 |
for reruns in range(args.max_reruns + 1):
|
| 357 |
+
name = task if reruns == 0 else f"{task}-r{reruns}"
|
| 358 |
+
if name != held["run"] and (not (root / "runs" / name).exists()
|
| 359 |
+
or job_state(f"flock-ctl-{name}")):
|
| 360 |
+
slots.give(n, held["run"], urls) # a finished attempt is only scored again: keep
|
| 361 |
+
held["run"] = name
|
| 362 |
+
slots.take(n, name, urls if job_state(f"flock-ctl-{name}") else None)
|
| 363 |
+
row = attempt(args, root, secrets, tree, n, name, urls)
|
| 364 |
if row is None:
|
| 365 |
return None
|
| 366 |
row["reruns"] = reruns
|
|
|
|
| 432 |
self.cond.notify_all()
|
| 433 |
|
| 434 |
|
| 435 |
+
def live_run(root: Path, tag: str, tree: int, n: int) -> tuple[str, list[str] | None]:
|
| 436 |
+
"""The run of a team that a stopped driver launched and whose controller is still there,
|
| 437 |
+
with its URLs (it keeps them); else the team's first run name and None."""
|
| 438 |
for spec in sorted((root / "src").glob(f"{tag}maze-t{tree:02d}-n{n:02d}*/spec.yaml")):
|
| 439 |
if job_state(f"flock-ctl-{spec.parent.name}"):
|
| 440 |
+
return spec.parent.name, yaml.safe_load(spec.read_text())["inference"]["urls"]
|
| 441 |
+
return f"{tag}maze-t{tree:02d}-n{n:02d}", None
|
| 442 |
|
| 443 |
|
| 444 |
def upload(root: Path, dataset: str, prefix: str) -> None:
|
|
|
|
| 545 |
f"{args.parallel} teams and {args.max_agents} agents at once, on {args.urls}")
|
| 546 |
slots = Slots(root, args.urls, args.parallel, args.max_agents, args.per_server)
|
| 547 |
|
| 548 |
+
def one(t: int, n: int, urls: list[str], held: dict):
|
| 549 |
try:
|
| 550 |
+
return run_team(args, root, secrets, t, n, urls, slots, held)
|
| 551 |
except Exception as e: # noqa: BLE001 - one team's failure must not stop the grid
|
| 552 |
say(f"{args.tag}maze-t{t:02d}-n{n:02d}", "failed:", repr(e)[:300])
|
| 553 |
finally:
|
| 554 |
+
slots.give(n, held["run"], urls)
|
| 555 |
|
| 556 |
try:
|
| 557 |
with ThreadPoolExecutor(args.parallel) as pool:
|
| 558 |
for t, n in teams:
|
| 559 |
+
run, live = live_run(root, args.tag, t, n)
|
| 560 |
+
urls = slots.take(n, run, live)
|
| 561 |
+
pool.submit(one, t, n, urls, {"run": run})
|
| 562 |
finally:
|
| 563 |
secrets.unlink(missing_ok=True)
|
| 564 |
if args.dataset:
|