flock/sweep: a run counts only if its worker started within 2 min of its launch; an adopted team keeps its original start; set-aside reasons for memory and Trial failures
Browse files- flock/sweep/README.md +2 -1
- flock/sweep/setaside.py +3 -0
- flock/sweep/sweep.py +25 -2
flock/sweep/README.md
CHANGED
|
@@ -55,7 +55,8 @@ the end.
|
|
| 55 |
|
| 56 |
**A run counts only when it is complete**: one worker incarnation (until flock#121 is fixed, a
|
| 57 |
relaunched or preempted worker overwrites results), its controller kept, every agent's reward
|
| 58 |
-
and the board export
|
|
|
|
| 59 |
mid-run, and a missing reward means the verifier never ran. A run that doesn't count goes to
|
| 60 |
`rows-discarded.jsonl` and the team runs again as `<task>-rK` (up to 5 times); its row records
|
| 61 |
the reruns.
|
|
|
|
| 55 |
|
| 56 |
**A run counts only when it is complete**: one worker incarnation (until flock#121 is fixed, a
|
| 57 |
relaunched or preempted worker overwrites results), its controller kept, every agent's reward
|
| 58 |
+
and the board export, and its worker started within 2 min of the launch (the loop's 15 minutes
|
| 59 |
+
and the driver's 40 count from the launch, also for a team a restarted driver adopts). hopper-cpu is spot capacity, so reclaims take workers and controllers
|
| 60 |
mid-run, and a missing reward means the verifier never ran. A run that doesn't count goes to
|
| 61 |
`rows-discarded.jsonl` and the team runs again as `<task>-rK` (up to 5 times); its row records
|
| 62 |
the reruns.
|
flock/sweep/setaside.py
CHANGED
|
@@ -6,6 +6,7 @@ reason uses them all. Writes `<root>/setaside.md`; the reasons, first that appli
|
|
| 6 |
- the worker was relaunched (more than one incarnation: flock#121's case) after it ran out of memory
|
| 7 |
(the worker's memory ladder rotated or preempted it), or else after a node failure;
|
| 8 |
- the worker ran out of memory and was preempted or killed without a relaunch;
|
|
|
|
| 9 |
- the controller's node was reclaimed (spot) mid-run;
|
| 10 |
- the task image couldn't be pulled (Docker Hub's unauthenticated limit), so the Trials never
|
| 11 |
started;
|
|
@@ -31,6 +32,8 @@ def reason(row: dict, run_dir: Path) -> str:
|
|
| 31 |
if re.search(r"preempted \(memory\)|draining \(memory\)|rotation wanted", workers):
|
| 32 |
return "worker relaunched after running out of memory (flock#121's case)"
|
| 33 |
return "worker relaunched after a node failure (flock#121's case)"
|
|
|
|
|
|
|
| 34 |
if "DUE TO NODE FAILURE" in controllers or row.get("outcome") == "controller lost":
|
| 35 |
return "controller's node reclaimed (spot)"
|
| 36 |
if "toomanyrequests" in workers:
|
|
|
|
| 6 |
- the worker was relaunched (more than one incarnation: flock#121's case) after it ran out of memory
|
| 7 |
(the worker's memory ladder rotated or preempted it), or else after a node failure;
|
| 8 |
- the worker ran out of memory and was preempted or killed without a relaunch;
|
| 9 |
+
- the worker started more than 2 min after the launch (the loop's 15 minutes count from it);
|
| 10 |
- the controller's node was reclaimed (spot) mid-run;
|
| 11 |
- the task image couldn't be pulled (Docker Hub's unauthenticated limit), so the Trials never
|
| 12 |
started;
|
|
|
|
| 32 |
if re.search(r"preempted \(memory\)|draining \(memory\)|rotation wanted", workers):
|
| 33 |
return "worker relaunched after running out of memory (flock#121's case)"
|
| 34 |
return "worker relaunched after a node failure (flock#121's case)"
|
| 35 |
+
if (row.get("worker_wait_s") or 0) > 120: # sweep.py's WAIT_LIMIT
|
| 36 |
+
return "worker queued past the launch (the loop counts from it)"
|
| 37 |
if "DUE TO NODE FAILURE" in controllers or row.get("outcome") == "controller lost":
|
| 38 |
return "controller's node reclaimed (spot)"
|
| 39 |
if "toomanyrequests" in workers:
|
flock/sweep/sweep.py
CHANGED
|
@@ -45,6 +45,9 @@ MODEL = "Qwen/Qwen3.5-27B"
|
|
| 45 |
SECRET = re.compile(r"hf_[A-Za-z0-9]{30,}")
|
| 46 |
lock, init_lock = threading.Lock(), threading.Semaphore(4)
|
| 47 |
LOST, GONE = "controller lost", "no controller left"
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
def load(name: str, path: Path):
|
|
@@ -175,7 +178,8 @@ def attempt(args, root: Path, secrets: Path, problem: int, n: int, name: str) ->
|
|
| 175 |
def finish(args, run_dir: Path, name: str, problem: int, n: int, started: float,
|
| 176 |
why: str | None = None) -> dict:
|
| 177 |
"""Wait for a launched team, release it (its Trials are graded) and make its row."""
|
| 178 |
-
|
|
|
|
| 179 |
if why == LOST: # nothing to release: end its jobs, and the team runs again
|
| 180 |
say(name, "controller lost (spot reclaim?): cancelling its jobs")
|
| 181 |
for job in (f"flock-ctl-{name}", f"{name}-agent-w0000"):
|
|
@@ -193,15 +197,34 @@ def finish(args, run_dir: Path, name: str, problem: int, n: int, started: float,
|
|
| 193 |
# each launch of the worker slot writes one env file: more than one is a relaunch or a
|
| 194 |
# preemption, whose results a later incarnation overwrites (flock#121)
|
| 195 |
"incarnations": len(list((run_dir / "launch").glob("*.env"))),
|
|
|
|
| 196 |
"started_at": datetime.fromtimestamp(started, UTC).isoformat()}
|
| 197 |
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
def why_invalid(row: dict) -> str:
|
| 200 |
"""Why a team's run doesn't count ('' when it does): a model result needs the run on one
|
| 201 |
worker incarnation (flock#121), its controller kept, every agent's reward and the board export.
|
| 202 |
-
A missing reward means the verifier never ran: the infrastructure failed, not the team.
|
|
|
|
|
|
|
| 203 |
return "; ".join(why for why, bad in (
|
| 204 |
(f"{row.get('incarnations')} worker incarnations", row.get("incarnations") != 1),
|
|
|
|
| 205 |
(LOST, row.get("outcome") == LOST),
|
| 206 |
(f"missing {', '.join(row['missing'])}"[:120], bool(row["missing"]))) if bad)
|
| 207 |
|
|
|
|
| 45 |
SECRET = re.compile(r"hf_[A-Za-z0-9]{30,}")
|
| 46 |
lock, init_lock = threading.Lock(), threading.Semaphore(4)
|
| 47 |
LOST, GONE = "controller lost", "no controller left"
|
| 48 |
+
# the loop's `until` (and the driver's team timeout) count from the launch, not from the worker's
|
| 49 |
+
# start: a run whose worker queued longer than this (a busy or scaling partition) doesn't count
|
| 50 |
+
WAIT_LIMIT = 120 # s
|
| 51 |
|
| 52 |
|
| 53 |
def load(name: str, path: Path):
|
|
|
|
| 178 |
def finish(args, run_dir: Path, name: str, problem: int, n: int, started: float,
|
| 179 |
why: str | None = None) -> dict:
|
| 180 |
"""Wait for a launched team, release it (its Trials are graded) and make its row."""
|
| 181 |
+
# the team's limit counts from its own start, also when a restarted driver adopts it
|
| 182 |
+
why = why or wait_done(run_dir, name, n, max(0.0, args.team_timeout - (time.time() - started)))
|
| 183 |
if why == LOST: # nothing to release: end its jobs, and the team runs again
|
| 184 |
say(name, "controller lost (spot reclaim?): cancelling its jobs")
|
| 185 |
for job in (f"flock-ctl-{name}", f"{name}-agent-w0000"):
|
|
|
|
| 197 |
# each launch of the worker slot writes one env file: more than one is a relaunch or a
|
| 198 |
# preemption, whose results a later incarnation overwrites (flock#121)
|
| 199 |
"incarnations": len(list((run_dir / "launch").glob("*.env"))),
|
| 200 |
+
"worker_wait_s": worker_wait(run_dir),
|
| 201 |
"started_at": datetime.fromtimestamp(started, UTC).isoformat()}
|
| 202 |
|
| 203 |
|
| 204 |
+
def worker_wait(run_dir: Path) -> float | None:
|
| 205 |
+
"""Seconds from the controller writing the worker's first launch file to the worker job's
|
| 206 |
+
first log line (None: not known)."""
|
| 207 |
+
launches = sorted((run_dir / "launch").glob("*.env"), key=lambda p: p.stat().st_mtime)
|
| 208 |
+
logs = sorted((run_dir / "logs").glob("*-agent-w*.out"))
|
| 209 |
+
if not launches or not logs:
|
| 210 |
+
return None
|
| 211 |
+
first = logs[0].read_text(errors="replace").split("\n", 1)[0]
|
| 212 |
+
try:
|
| 213 |
+
started = datetime.fromisoformat(first.split(" ", 1)[0])
|
| 214 |
+
except ValueError:
|
| 215 |
+
return None
|
| 216 |
+
return round(started.timestamp() - launches[0].stat().st_mtime, 1)
|
| 217 |
+
|
| 218 |
+
|
| 219 |
def why_invalid(row: dict) -> str:
|
| 220 |
"""Why a team's run doesn't count ('' when it does): a model result needs the run on one
|
| 221 |
worker incarnation (flock#121), its controller kept, every agent's reward and the board export.
|
| 222 |
+
A missing reward means the verifier never ran: the infrastructure failed, not the team. And
|
| 223 |
+
its worker started within WAIT_LIMIT of the launch, so the loop's 15 minutes were the team's."""
|
| 224 |
+
wait = row.get("worker_wait_s") or 0
|
| 225 |
return "; ".join(why for why, bad in (
|
| 226 |
(f"{row.get('incarnations')} worker incarnations", row.get("incarnations") != 1),
|
| 227 |
+
(f"worker started {wait:.0f} s after the launch", wait > WAIT_LIMIT),
|
| 228 |
(LOST, row.get("outcome") == LOST),
|
| 229 |
(f"missing {', '.join(row['missing'])}"[:120], bool(row["missing"]))) if bad)
|
| 230 |
|