Instruction file imported from rompoggi/smth2smth (
.cursor/rules/start-resume-runs.mdc). Copyright stays with the author.
Starting and resuming runs (mandatory)
Use with distributed run log (.cursor/rules/distributed-run-log.mdc). After a healthy start, update report/$(whoami)/$(hostname).md and tell the user clearly where to look.
Launch stack
- Always
nohupfor long jobs (unless user asks foreground debug). - Always
uv run+PYTHONPATH=src+PYTHONUNBUFFERED=1(orpython -u). - Prefer existing
scripts/launch_*.shwhen they match the experiment — but do not trust defaultLOGpaths (many scripts still write to flatlogs/at repo root). - Before launch: read the script (or its echoed
log / pidlines) and confirm the resolved log path matcheslogs/{track_a|track_b|study}/below. If not, overrideLOG(andPIDFILEif any) on the command line, or wrap with explicit paths — do not change launch scripts unless the user asks. - After
nohup, verify the process is actually writing to that path (tailthe intended file, not an old flatlogs/*.log).
Run and log naming
| Item | Rule |
|---|---|
| Run name | Semantic, stable: mae150-ft-f4, mae350-ft-f4-val90-lr5e5 — not e1_rouget, train1, etc. |
| Log file | logs/{dir}/{RUN_NAME}_{YYYYMMDD}.log — date = start day (wall clock). |
| Reuse on restart | Same RUN_NAME + same log path → append (do not rotate) unless the log is only a failed boot (see below). |
Log directory (logs/)
Resolve {dir} from Hydra track= / experiment:
| Case | Directory | Examples |
|---|---|---|
| Track A | logs/track_a/ |
official SSv2 FT, SSL finetune on track A |
| Track B | logs/track_b/ |
V-JEPA, Track B presets |
| Dedicated study | logs/{tag}/ |
HC ablation → logs/hc/; ensemble → logs/ensemble/ if already used |
| Unclear | Infer from `track=a | b` in command; if still ambiguous, ask the user before launching |
mkdir -p the directory before nohup.
Log file header (write first)
Before or as the process starts, ensure the log begins with a short ASCII header (survives tail -f):
# run: mae150-ft-f4
# started: 2026-05-25T01:50:00+02:00
# track: a
# experiment_doc: experiments/new_ideas_tracka.md
# hydra: experiment=track_a_videomae_official_ssv2_ft
started: ISO-8601 fromdate -Is.experiment_doc: repo-relative path to theexperiments/*.mdspec (read-only; no line anchors). Match tags/topic in that doc when useful.- Do not put non-ASCII in the header.
Example prepend when launching:
LOG=logs/track_a/mae150-ft-f4_20260525.log
mkdir -p "$(dirname "$LOG")"
{
echo "# run: mae150-ft-f4"
echo "# started: $(date -Is)"
echo "# track: a"
echo "# experiment_doc: experiments/new_ideas_tracka.md"
echo "# hydra: experiment=track_a_videomae_official_ssv2_ft"
} >>"$LOG"
# then nohup ... >>"$LOG" 2>&1 &
PID files (minimal use)
| Situation | Do |
|---|---|
Long train, user/agent will kill -0 / monitor |
Optional {LOG%.log}.pid; record PID inside the log and add a header line # pid_file: logs/track_a/....pid |
Submit, short eval, or PID easy via pgrep |
No .pid file — write trainer_pid=... into the log after start |
| Run finished (DONE / FAILED / STOPPED) | rm -f the .pid file if it exists |
In the markdown run log, link the pid file only when it exists and the run is still RUNNING; omit after cleanup.
W&B
| Job type | W&B |
|---|---|
| Long train / pretrain | On (WANDB_MODE=online default in launchers). Capture URL from log line [wandb] run started: https://... |
| Submit, dry-run, short cache/eval | Off (training.wandb.enabled=false or WANDB_MODE=disabled) |
Resume after crash / VM reboot: keep the same training config (checkpoint, optimizer, scheduler, LR policy as the interrupted run). Append to the same log file.
- Prefer
WANDB_RESUME=allow+WANDB_RUN_ID=<id>(id from the previous log’s[wandb]line or W&B UI). Same entity/project as the original run. - Do not start a fresh W&B run for a continuation unless the user asks.
- Training checkpoint:
training.resume_from=<last.pt>(and matching Hydra flags the prior run used). Do not change LR/scheduler unless the user requests a new phase.
(Code may not yet pass resume into wandb.init; env vars are the default until extended.)
Logging health check (required after start)
Wait ~30–90s (or ≥2× log_interval_steps batches), then inspect the log. Fail the launch if any of:
- No step lines while training should run (check
training.log_interval_stepsin preset). - One step per line broken: blank line between every step, or multiple
stepon one line. - Mojibake / non-ASCII in training lines (config dump may be large; focus on
[HH:MM:SS] step/Epochlines). - Traceback or CUDA OOM at start.
Healthy pattern (example):
[01:52:07] step 1150/5625 | avg train loss ...
Checks:
tail -40 "$LOG"
LC_ALL=C grep -n 'step .*step' "$LOG" | tail -5 # multiple steps on one line?
LC_ALL=C grep -P '[^\x00-\x7F]' "$LOG" | grep -E 'step |Epoch' | head -3
If unhealthy: stop the process, tell the user what failed, ask whether to truncate/reuse the same log after fixing (flush/PYTHONUNBUFFERED, config, etc.).
Failed boot vs real restart
| Case | Log file |
|---|---|
| Crash before meaningful training (config + error only) | User agrees → delete polluted log or truncate; relaunch into same path |
| VM stop mid-epoch, wrong config fix, GPU preemption | Keep log; resume training; append; fix W&B resume as above |
After a healthy start (agent → user message)
Include explicitly:
- Log path (markdown link in chat):
[`logs/track_a/mae150-ft-f4_20260525.log`](logs/track_a/...) - Healthy: yes/no (one line: e.g. “step logging OK at interval 25”).
- W&B: markdown link to run URL if training and line present; else “n/a (submit/short job)”.
- Monitor:
tail -f …and, if pid file exists,`kill -0 $(cat …pid)`
Then prepend/update the distributed run log (.cursor/rules/distributed-run-log.mdc) with:
- Log: markdown link to the log file (
../../logs/track_a/...fromreport/{user}/{host}.md). - W&B: markdown link when applicable.
- PID: only if a pid file is in use and run is RUNNING.
Do not
- Edit
experiments/**or sharedreport/track_*.texwhen only launching/logging (see distributed-run-log). - Leave stale
.pidfiles after a run ends. - Invent
logs/e1_host.log-style names. - Assume
scripts/launch_*.shalready useslogs/track_a/— verify every time; scripts are not authoritative until updated separately.