auto-optimize 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. auto_optimize/__init__.py +3 -0
  2. auto_optimize/__main__.py +5 -0
  3. auto_optimize/cli.py +651 -0
  4. auto_optimize/skills/auto-optimize-code/LICENSE +21 -0
  5. auto_optimize/skills/auto-optimize-code/SKILL.md +251 -0
  6. auto_optimize/skills/auto-optimize-code/VERSION +1 -0
  7. auto_optimize/skills/auto-optimize-code/references/algorithm.md +182 -0
  8. auto_optimize/skills/auto-optimize-code/references/changes.md +146 -0
  9. auto_optimize/skills/auto-optimize-code/references/cli.md +206 -0
  10. auto_optimize/skills/auto-optimize-code/references/dashboard.md +203 -0
  11. auto_optimize/skills/auto-optimize-code/references/documents.md +55 -0
  12. auto_optimize/skills/auto-optimize-code/references/extending.md +87 -0
  13. auto_optimize/skills/auto-optimize-code/references/external-validation.md +98 -0
  14. auto_optimize/skills/auto-optimize-code/references/glossary.md +134 -0
  15. auto_optimize/skills/auto-optimize-code/references/idea-miner.md +108 -0
  16. auto_optimize/skills/auto-optimize-code/references/issue-bugs.md +182 -0
  17. auto_optimize/skills/auto-optimize-code/references/layout.md +300 -0
  18. auto_optimize/skills/auto-optimize-code/references/main-session.md +45 -0
  19. auto_optimize/skills/auto-optimize-code/references/measuring.md +208 -0
  20. auto_optimize/skills/auto-optimize-code/references/pr-optimization.md +127 -0
  21. auto_optimize/skills/auto-optimize-code/references/pr-tests.md +254 -0
  22. auto_optimize/skills/auto-optimize-code/references/promotion.md +133 -0
  23. auto_optimize/skills/auto-optimize-code/references/reading-a-search.md +65 -0
  24. auto_optimize/skills/auto-optimize-code/references/repo-mode.md +224 -0
  25. auto_optimize/skills/auto-optimize-code/references/resume.md +81 -0
  26. auto_optimize/skills/auto-optimize-code/references/shared-knowledge.md +114 -0
  27. auto_optimize/skills/auto-optimize-code/references/step0-interview.md +298 -0
  28. auto_optimize/skills/auto-optimize-code/references/step1-unit-tests.md +136 -0
  29. auto_optimize/skills/auto-optimize-code/references/step2-baseline.md +708 -0
  30. auto_optimize/skills/auto-optimize-code/references/step3-rounds.md +350 -0
  31. auto_optimize/skills/auto-optimize-code/references/step4-final.md +121 -0
  32. auto_optimize/skills/auto-optimize-code/references/step5-ship.md +220 -0
  33. auto_optimize/skills/auto-optimize-code/references/step6-finish.md +67 -0
  34. auto_optimize/skills/auto-optimize-code/references/subagent.md +467 -0
  35. auto_optimize/skills/auto-optimize-code/references/symptoms.md +67 -0
  36. auto_optimize/skills/auto-optimize-code/references/writing-briefs.md +117 -0
  37. auto_optimize/skills/auto-optimize-code/scripts/attribution.py +156 -0
  38. auto_optimize/skills/auto-optimize-code/scripts/autoopt.py +12863 -0
  39. auto_optimize/skills/auto-optimize-code/scripts/check_seeding.py +334 -0
  40. auto_optimize/skills/auto-optimize-code/scripts/cold.py +90 -0
  41. auto_optimize/skills/auto-optimize-code/scripts/dashboard/README.md +165 -0
  42. auto_optimize/skills/auto-optimize-code/scripts/dashboard/autoopt_monitor.py +850 -0
  43. auto_optimize/skills/auto-optimize-code/scripts/dashboard/gpu_scan.py +954 -0
  44. auto_optimize/skills/auto-optimize-code/scripts/dashboard/monitor_writer.py +684 -0
  45. auto_optimize/skills/auto-optimize-code/scripts/dashboard/scan.py +1030 -0
  46. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.css +775 -0
  47. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.js +3652 -0
  48. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/index.html +191 -0
  49. auto_optimize/skills/auto-optimize-code/scripts/issue_body.py +2118 -0
  50. auto_optimize/skills/auto-optimize-code/scripts/lint_text.py +448 -0
  51. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_body.py +894 -0
  52. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_tables.py +367 -0
  53. auto_optimize/skills/auto-optimize-code/scripts/paired.py +188 -0
  54. auto_optimize/skills/auto-optimize-code/scripts/preflight.py +280 -0
  55. auto_optimize/skills/auto-optimize-code/scripts/probe_run.py +72 -0
  56. auto_optimize/skills/auto-optimize-code/scripts/publish.py +385 -0
  57. auto_optimize/skills/auto-optimize-code/scripts/run_iteration.py +1382 -0
  58. auto_optimize/skills/auto-optimize-code/scripts/ship.py +1193 -0
  59. auto_optimize/skills/auto-optimize-code/scripts/stages.py +651 -0
  60. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_body.py +1267 -0
  61. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_push.py +426 -0
  62. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_tables.py +779 -0
  63. auto_optimize-1.0.0.dist-info/METADATA +610 -0
  64. auto_optimize-1.0.0.dist-info/RECORD +67 -0
  65. auto_optimize-1.0.0.dist-info/WHEEL +4 -0
  66. auto_optimize-1.0.0.dist-info/entry_points.txt +2 -0
  67. auto_optimize-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,206 @@
1
+ # Every script flag
2
+
3
+ `$AO` is the skill's `scripts/` directory (`SKILL.md`, *Paths in every
4
+ command*). What the commands read and write on disk is in
5
+ `references/layout.md`; the read-only commands and what each answers are in
6
+ `references/reading-a-search.md`. The dashboard's flags are in
7
+ `scripts/dashboard/README.md`.
8
+
9
+ ## `autoopt.py` — the search tree
10
+
11
+ `--id` names an existing iteration; `new` and `brief` take `--new-id` (or `--id`) for the one they create. `--id` defaults to the winner (`best`) in `path`, `final`, `end` and `archive`, to the root in `profile` and `validate`, and is required where one iteration is acted on (`finish`, `readme`, `promote`, `variant`, `restore`, `checkers`); `check` takes `--id` or `--reference`.
12
+
13
+ ```bash
14
+ python3 $AO/autoopt.py init <work> --task … --command … --objective … --direction max|min [--unit U] [--gates JSON] [--observers a,b]
15
+ [--runs 5] [--staged [--confirm-runs 10]] [--seed-base N] [--gpus-per-agent 1] [--timeout S]
16
+ [--no-gpu | --gpu-command '<allocator> --'] [--floor V] [--workers N] [--build-env VAR=VALUE …]
17
+ [--subagent-model opus|sonnet|haiku|fable] [--promote auto|orchestrator] [--after JSON]
18
+ [--validation-command CMD --validation-measures a,b --validation-note TEXT]
19
+ [--copy PATH …] [--repo REPO [--allow-dirty]] [--tests CMD [--tests-path tests] [--tests-timeout S]] [--force]
20
+ python3 $AO/autoopt.py tests-branch <original> --work <work> [--date YYYY-MM-DD] # step 1: check, clone, branch
21
+ python3 $AO/autoopt.py tests-branch --work <work> --squash -m '<message>'
22
+ python3 $AO/autoopt.py spec <work> --set FIELD VALUE …
23
+ python3 $AO/autoopt.py config <work> [--set KEY=VALUE … --add-observer NAME … --reason '…']
24
+ python3 $AO/autoopt.py setup <work> [--ask Q [--recommend A] | --answer A | --force | --done]
25
+ python3 $AO/autoopt.py prove <work> [copies …] [--make NAMES] [--dir DIR] [--compare CMD] [--background] # copies: default every one in the scratch directory
26
+ python3 $AO/autoopt.py prove <work> --id A7 --checker PATH --checker-row FILE --faults FILE [--timeout 240]
27
+ python3 $AO/autoopt.py width <work> [--counts 1,2,4] [--reps N] [--write] [--background]
28
+ python3 $AO/autoopt.py busy <work> [--seconds 2]
29
+ python3 $AO/autoopt.py price <work> # after A0: what the later steps that run the base cost
30
+ python3 $AO/autoopt.py harness <work> [--accept --reason '…']
31
+ python3 $AO/autoopt.py mine <work> [--done] [--force] [--without-profile]
32
+ python3 $AO/autoopt.py drop <work> --idea-line N|TEXT --reason '…'
33
+ python3 $AO/autoopt.py loop <work> [--force | --done | --stop] # --stop: the open phase's next `brief --next` briefs nothing and says to hand back
34
+ python3 $AO/autoopt.py brief <work> --new-id A3 --title '…' --category CACHING --idea '…'|@file --tried none|'…'|@file --gpus '…'
35
+ [--idea-line N|TEXT] [--parent A0] [--topic T] [--predict D --predict-basis '…'] [--sections tags]
36
+ [--checks '…'] [--note '…' …] [--validate] [--control] [--after-end] [--replace]
37
+ python3 $AO/autoopt.py brief <work> --next [--count N] # status --brief, new summaries, then a brief when the one slot is free
38
+ python3 $AO/autoopt.py brief <work> --prompt A3 # an existing brief's spawn prompt again
39
+ python3 $AO/autoopt.py new <work> --brief A3 # the iteration a brief describes
40
+ python3 $AO/autoopt.py new <work> --new-id A3 --title '…' --category CACHING [--parent A0] [--topic T]
41
+ [--predict D --predict-basis '…'] [--control] [--idea-key KEY] [--after-end]
42
+ python3 $AO/autoopt.py finish <work> --id A3 [--ledger FILE] [--checker PATH --checker-row FILE]
43
+ python3 $AO/autoopt.py readme <work> --id A3 [--template]
44
+ python3 $AO/autoopt.py ledger <work> --by A7 --add FILE
45
+ python3 $AO/autoopt.py check <work> (--id A7 | --reference)
46
+ python3 $AO/autoopt.py checkers <work> --id A7 [--name NAME … | --touched] [--timeout 1800]
47
+ python3 $AO/autoopt.py profile <work> [--id N]
48
+ python3 $AO/autoopt.py variant <work> --id A7 NAME [--parent] [--no-build]
49
+ python3 $AO/autoopt.py status <work> [--round N] [--json] [--brief|--header [--last N]] [--resume]
50
+ python3 $AO/autoopt.py summary <work> --round N
51
+ python3 $AO/autoopt.py promote <work> --id A7
52
+ python3 $AO/autoopt.py validate <work> [--round N] [--id A7] [--approve] [--dry-run] [--out DIR] [--background]
53
+ python3 $AO/autoopt.py watch <work> [--cap 10800] [--every 60]
54
+ python3 $AO/autoopt.py bg <work> <log> '<command>' # a long command of the main session, detached, with its log
55
+ python3 $AO/autoopt.py wait LOG [--pid N] [--max 200]
56
+ python3 $AO/autoopt.py tokens <work> [--since T] [--subagents-only] [--session ID …] [--exclude-session ID …] [--projects DIR] [--all-projects] [--json]
57
+ # reads the transcripts of the search's own project folders (config.json `origin`, the work directory and its parents), written since shortly before A0; --all-projects reads every one
58
+ python3 $AO/autoopt.py final <work> [--id best] [--json] [--background]
59
+ python3 $AO/autoopt.py end <work> [--reason WORD|TEXT] [--id N] [--background | --reopen]
60
+ python3 $AO/autoopt.py path <work> [--id N|best] [--markdown|--json]
61
+ python3 $AO/autoopt.py table <work> [--fields a,b|all] [--status S,…] [--category C,…] [--round N] [--parent A5]
62
+ [--frontier] [--promoted] [--sort [-]FIELD|best] [--limit N] [--tsv|--json] # read-only
63
+ python3 $AO/autoopt.py show <work> [A7|best] [--chars 600] [--json] # read-only
64
+ python3 $AO/autoopt.py pr <work> [--id best] [--dir D] [--branch NAME] [--remote R --head OWNER:BRANCH] [--other-owner] [--post | --edit]
65
+ python3 $AO/autoopt.py archive <work> [--id N] [--dest DIR] [--force]
66
+ python3 $AO/autoopt.py prune <work> [--keep-recent 20] [--worktrees] [--all] [--outputs-ext .npy,.npz] [--keep-outputs] [--apply]
67
+ python3 $AO/autoopt.py restore <work> --id A7 [--branch NAME]
68
+ python3 $AO/autoopt.py reset <work> [--keep 0,7] [--new-root 7] [--force] [--apply]
69
+ ```
70
+
71
+ `<work>` may be the search's directory or its `autooptimize/` subdirectory. `--help` of each subcommand explains every flag. `new` takes a lock around id allocation, so concurrent calls cannot take the same id. `prune` and `reset` only report without `--apply`, which is given after the user agrees. `brief --gpus` is required unless `gpu` is false or `gpu_command` is set.
72
+
73
+ ## `stages.py` — the stages and the next move
74
+
75
+ ```bash
76
+ python3 $AO/stages.py status $WORK # the six stages: interview, setup, search, final, ship, finish
77
+ python3 $AO/stages.py render $WORK # the same table, written to $WORK/NOTES.md
78
+ python3 $AO/stages.py next $WORK [--run] # the one command or question that is next
79
+ ```
80
+
81
+ Each stage is `not started`, `running` or `complete`, read from `state.json`,
82
+ `ended.json`, `after.ship`, `ship/` and `finish/`. `next` prints the move and its kind (`run`,
83
+ `agent`, `wait`, `stop`: `references/main-session.md`), or `every stage is
84
+ complete`; `--run` starts a `run` move.
85
+
86
+ ## `ship.py` — step 5
87
+
88
+ ```bash
89
+ python3 $AO/ship.py plan <work> [--json] # what this search can ship, and the question to ask
90
+ python3 $AO/ship.py apply <work> [--id best] [--to DIR] [--by-hand] [--yes]
91
+ python3 $AO/ship.py branch <work> [--id best] [--name N] [--repo PATH] [--yes]
92
+ python3 $AO/ship.py brief <work> # the document writer's prompt
93
+ python3 $AO/ship.py status <work>
94
+ python3 $AO/ship.py render <work> [--only bugs|tests|optimization]
95
+ python3 $AO/ship.py rehearse <work> [--branch DOC=NAME …]
96
+ python3 $AO/ship.py post <work> all --approved --digest D [--branch DOC=NAME …] [--other-owner]
97
+ ```
98
+
99
+ `apply` and `branch` preview until `--yes`. `apply --by-hand` records as
100
+ applied, and leaves as it is, a file the user merged the change into by hand.
101
+ `post` refuses any digest but the
102
+ last rehearsal's, inputs changed since, and `--branch` flags other than the
103
+ rehearsal's (`references/step5-ship.md`). `--branch optimization=NAME` or
104
+ `tests=NAME` names the branch a PR pushes, in place of the one its title or
105
+ date gives.
106
+
107
+ The documents' own scripts (`references/pr-optimization.md`,
108
+ `references/pr-tests.md`, `references/issue-bugs.md`):
109
+
110
+ ```bash
111
+ python3 $AO/opt_pr_tables.py <work> [--id best] [--out D] [--tests-format KEY=REGEX …]
112
+ python3 $AO/opt_pr_body.py D (--template | --title T --out D/body.md)
113
+ python3 $AO/tests_pr_tables.py collection --collect-output FILE [--root DIR] [--marker REGEX] --out D
114
+ python3 $AO/tests_pr_tables.py files|coverage|names …
115
+ python3 $AO/tests_pr_body.py D (--template | --title T --out D/body.md) [--prose FILE] [--config FILE] [--allow-source PATH …]
116
+ python3 $AO/tests_pr_push.py D --repo OWNER/REPO [--suite DIR] [--branch B] [--base COMMIT] [--remote-branch B] [--target-branch B]
117
+ [--remote R] [--head OWNER:BRANCH] [--allow-source PATH …] [--post | --edit] [--other-owner]
118
+ python3 $AO/issue_body.py template|dupes|verify|status|render|renumber|file|link D … # --prose FILE on all but template and link
119
+ python3 $AO/issue_body.py dupes D [--repo OWNER/REPO | --issues FILE] [--top 3] [--min-score 4] [--max-issues 2000]
120
+ python3 $AO/attribution.py check --kind optimization|tests|issue --title T --body FILE
121
+ ```
122
+
123
+ ## `run_iteration.py` — one iteration
124
+
125
+ ```bash
126
+ python3 $AO/run_iteration.py $WORK/autooptimize/iterations/3
127
+ ```
128
+
129
+ | Flag | Meaning |
130
+ |---|---|
131
+ | `--runs N` | run N seeds instead of `runs_per_iteration`; below it, the iteration is `partial` |
132
+ | `--confirm-runs N`, `--stage {screen,confirm,all}` | a search made with `init --staged` only: override `confirm_runs`; stop after the screening runs, go straight to `confirm_runs`, or screen then confirm (the default) |
133
+ | `--rerun` | re-run seeds already measured on the current commit |
134
+ | `--no-promote` | never promote, whatever `promote` says, and run no external validation: a re-measurement of a settled iteration |
135
+ | `--full-tests` | run the whole unit-test suite instead of the subset; reuses finished runs, so on a settled iteration it runs only the suite |
136
+ | `--dry-run` | print the runs that would happen, and stop |
137
+ | `--background` | start the same call detached, writing `<iteration>/probe/runner.log` (ending `exit <code>`), and return: watch it with `autoopt.py wait` |
138
+
139
+ It refuses while `spec.md` has a TODO line (`--dry-run` excepted), and never on a busy machine: before A0's runs on a CPU benchmark it names each process outside the search above `busy_percent` (110% of one core by default) over two seconds in its report (`busy at start:`) and `result.json` (`busy_at_start`). Exit code 2
140
+ means `status == "error"`; 0 means the iteration produced a verdict, including
141
+ `gate-failed`. Each run is in its own process group, so Ctrl-C or a timeout
142
+ kills the whole benchmark, not only its shell. A seed already measured on the
143
+ current commit is skipped, so an interrupted iteration resumes where it
144
+ stopped; one measured on an older commit runs again. Run on a settled
145
+ iteration after a gate changed, it re-judges the stored runs under the new
146
+ gate. When `notes.md` exists, it re-assembles `README.md` at the end.
147
+
148
+ ## `check_seeding.py` — does the seed control what it should
149
+
150
+ ```bash
151
+ python3 $AO/check_seeding.py $WORK/autooptimize/iterations/0
152
+ ```
153
+
154
+ `--seed N` is the seed to repeat (default: the search's first), `--repeats N` the runs on it (2), `--others N` the runs on further seeds (2); `--scan-only` reads the source for unseeded randomness and stops; `--keep` keeps the `runs/seedcheck-*` directories and the compiler cache.
155
+
156
+ Exit codes: 0 OK, 1 WARNING (the same seed moved the objective by half or more
157
+ of what changing it did), 2 FAIL (different seeds gave identical answers), 3
158
+ refused or could not run. Its runs, in `runs/seedcheck-*`, leave the
159
+ iteration's own results untouched, and share one compiler cache, `{cache}`, at
160
+ `<iteration>/cache/seedcheck`, emptied before the check and removed after it
161
+ unless `--keep`. What to do about each verdict:
162
+ `references/step2-baseline.md`, *Seeding*.
163
+
164
+ ## `paired.py` — paired separate-process timing, with a stopping rule
165
+
166
+ ```bash
167
+ python3 $AO/paired.py --a DIR_A --b DIR_B --cmd "python3 probe.py --src {src}" [--env K=V …] [--min-pairs 8] [--max-pairs 24] [--alpha 0.005]
168
+ [--direction min|max] [--regex PATTERN] [--cap-hours H] [--run-timeout S] [--log FILE] [--json]
169
+ ```
170
+
171
+ `--regex` is a pattern whose first group is the seconds on the command's last line, for output whose last number is not the time. `--cap-hours` exits 3 before the first pair when `--min-pairs` would take longer; a recorded run past `--run-timeout` seconds (default: ten times that side's unrecorded run, plus 60) is killed, and that exits 4. `--cmd` runs once per timing in a fresh shell with `{src}` and `{side}` (`a`/`b`) substituted; it prints the seconds as the last number on its last line and exits non-zero when its output is wrong. Each side gets `<dir>/.paired-cache` as its compiler cache. The stop rule is the exact two-sided sign test.
172
+
173
+ `verdict` is `B better`, `B worse`, or `no difference resolved` when 24 pairs
174
+ end with p ≥ alpha. It exits non-zero, having decided nothing, if any run
175
+ fails. Why the stopping rule is safe: `references/measuring.md`, *Paired
176
+ separate processes: `paired.py`*.
177
+
178
+ ## `cold.py` — cold first-call time on empty caches
179
+
180
+ ```bash
181
+ python3 $AO/cold.py --side NAME=DIR [--side NAME=DIR ...] --cmd "python3 first_call.py --src {src}" --scratch DIR [--reps 2] [--env K=V …] [--regex PATTERN] [--json]
182
+ ```
183
+
184
+ Each run gets a new empty directory under `--scratch` as `NUMBA_CACHE_DIR`
185
+ (and the Triton and Inductor caches), created with `mkdtemp` and never
186
+ deleted. Sides alternate order each repetition. In `--cmd`, `{src}` is the
187
+ side's `DIR` and `{side}` its `NAME`; the command prints the first call's
188
+ seconds as the last number on its last line. Keep `--scratch` inside
189
+ the iteration directory.
190
+
191
+ ## `preflight.py` and `lint_text.py` — checks without measuring
192
+
193
+ ```bash
194
+ python3 $AO/preflight.py $WORK [--id A12] # the iteration's own change, from its parent; default best
195
+ python3 $AO/preflight.py $WORK --id best --path # the whole path, from the commit the search copied
196
+ python3 $AO/lint_text.py body FILE [--labels A0,A1]
197
+ python3 $AO/lint_text.py title STRING [--labels …]
198
+ python3 $AO/lint_text.py commits REPO REF BASE [--labels …]
199
+ python3 $AO/lint_text.py diff-comments REPO REF BASE [--labels …]
200
+ ```
201
+
202
+ `preflight.py` exits 0 with no problem, 1 with problems (one line each,
203
+ `check: text`), 2 when refused (not a repository search, no such iteration).
204
+ `--path` also writes `$WORK/autooptimize/preflight.json` (`{winner, problems}`).
205
+ `lint_text.py` exits 1 listing every hit with its line. The checks and the
206
+ vocabulary: `references/promotion.md`, *The preflight*.
@@ -0,0 +1,203 @@
1
+ # The dashboard: watching a search
2
+
3
+ A live dashboard over an `autooptimize/` directory, mounted in a JupyterLab
4
+ notebook output. It needs nothing instrumented and works against a finished
5
+ search or one this session did not start. It writes only its notebook
6
+ (`$WORK/dashboard.ipynb`, beside `autooptimize/`), its payload directory
7
+ (`autooptimize/monitor/` by default, else
8
+ `~/autoopt-monitor/<project>-<8 hex of the search's path>/`), an index entry
9
+ under `~/.cache/autoopt-monitor/`, and the GPU sample its publishers share and
10
+ the writer lock in `/dev/shm/dashboard-monitor-<uid>/` (the temporary
11
+ directory where `/dev/shm` is not writable); it never touches iterations,
12
+ records or code.
13
+
14
+ ```bash
15
+ DASH=$AO/dashboard
16
+ ```
17
+
18
+ ## The publisher starts with the first iteration, always
19
+
20
+ ```bash
21
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --start
22
+ ```
23
+
24
+ `--start` writes `$WORK/dashboard.ipynb` *and* starts the publisher
25
+ behind it, so the page has data before anyone opens it. Run it as soon as
26
+ round 1's first iteration is spawned, on the machine running the search. It returns
27
+ after the first scan and one hardware sample, so a slow `nvidia-smi` delays it
28
+ by that call. Report the pid it prints and how to see the page:
29
+
30
+ | The user has | Tell them |
31
+ |---|---|
32
+ | JupyterLab serving the search's directory | open the notebook path it printed and run its one cell; right-click the output → **Create New View for Output** gives it a panel of its own |
33
+ | JupyterLab, but the search is outside the directory it serves | re-run with `-o` under the served root (below); the publisher is not disturbed |
34
+ | no JupyterLab | `autoopt.py status $WORK` in a terminal, and `--export` for a static HTML file of the page (*Managing publishers*) |
35
+
36
+ Re-running `--start` is safe, so re-run it whenever unsure: on the same
37
+ interval it prints `already running` and the existing pid, in whatever
38
+ directory the search's publisher writes; on another, it restarts the
39
+ publisher on that one.
40
+
41
+ ```bash
42
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --start \
43
+ -o <a directory Jupyter serves>/dashboard-<search name>.ipynb
44
+ ```
45
+
46
+ ## Opening it by hand
47
+
48
+ The cell `--start` writes is this, for a search a previous session started or
49
+ a finished one:
50
+
51
+ ```python
52
+ import sys, importlib
53
+ sys.path.insert(0, '<absolute path of the skill>/scripts/dashboard')
54
+ import autoopt_monitor as am
55
+ am = importlib.reload(am)
56
+
57
+ am.show('<work>/autooptimize')
58
+ ```
59
+
60
+ `show()` copies the front end and plotly into `autooptimize/monitor/`
61
+ (falling back to `~/autoopt-monitor/<project>-<8 hex of the search's path>/`
62
+ when the search is outside the tree Jupyter serves, or not writable), starts or
63
+ reuses the publisher, and renders the page. Paths with spaces, `#` or `?`
64
+ work.
65
+
66
+ | Argument (CLI flag) | Default | |
67
+ |---|---|---|
68
+ | `out_dir` (`--out`) | `autooptimize/monitor` | must be under the directory Jupyter serves; `show()` raises otherwise, `--start` warns |
69
+ | `base` (none) | `~/autoopt-monitor` | where the fallback out directory goes |
70
+ | `interval` (`--interval`) | 20 s | full scan. Raise it for a search whose runs take an hour, or past a few hundred iterations, when the payload is megabytes on every poll over a remote Jupyter connection. A publisher on another interval is restarted on this one |
71
+ | `resource_interval` (none) | 3 s | GPU and host sample; the GPUs card's Live toggle makes it 1 s for as long as the tab asks |
72
+ | `writer` (none) | `True` | `False` renders against a publisher someone else runs |
73
+ | `path` (`-o`), `make_notebook()` only | `$WORK/dashboard.ipynb` | |
74
+ | `overwrite` (`--no-overwrite`), `make_notebook()` only | `True` | keep a notebook the user edited |
75
+
76
+ The rest are `show()`'s. `make_notebook()` writes a cell that calls `show()`
77
+ with its other keyword arguments; the CLI passes `--out` and `--interval`.
78
+
79
+ GPU cards name each device's lease holder when `GPU_LEASE_DIR` names a lease
80
+ tool's directory of `gpu<index>.json` files, each a JSON object with any of
81
+ `gpu`, `user`, `note` (or `cmd`), `pid`, `acquired_at`, `expires_at` (epoch
82
+ seconds). A lease counts while its pid lives and it has not expired; a
83
+ malformed file is skipped. Unset, the cards show no holder.
84
+
85
+ ## What to look at
86
+
87
+ Panels, marks and interactions are specified in `scripts/dashboard/README.md`,
88
+ *The page*.
89
+
90
+ | Question | Where |
91
+ |---|---|
92
+ | Is the publisher alive? | the topbar pulse, below |
93
+ | Best so far, and by how much | the summary band and the sidebar's Frontier card |
94
+ | Which ideas worked | the objective chart: the dotted staircase is the frontier; ✕ failed a gate and a hollow square has fewer runs than `runs_per_iteration`, and neither is ever on it |
95
+ | Is it noise? | *Confidence intervals* and *All runs* on the objective chart |
96
+ | What is running now | hollow diamonds on the chart's floor; ringed points are measured iterations whose subagent is still writing its README |
97
+ | Why an iteration scored what it did | click its tree node (the whole README) or log entry (the README, whole after SHOW MORE): every number, where the time went |
98
+ | How much code an iteration changed | hover its point or open its log entry: lines added and deleted, files modified, added and deleted, against its parent |
99
+ | What an iteration changed, line by line | click its point on the objective chart: its diff against its parent opens under the chart, old file left and new right; a second click or *close* shuts it |
100
+ | Whether a fresh batch of ideas helped | the objective chart's stage boundaries: one dashed line where the idea miner's stage changes |
101
+ | A gate or observer moving | *Every run* (a broken gate is red) and the observer charts |
102
+ | External validation | its own section (`references/external-validation.md`) |
103
+ | GPUs idle or contended | the GPU cards and the process table |
104
+ | Whether it ended, and how | the topbar's `ended <date> · A<id> <median> vs A0 <median> · <reason>` line; its tooltip has the paired timing from `final.json` |
105
+ | Which stages are done | the strip under the category chips: `interview complete · setup complete · … · ship not started · finish not started`, in `stages.py`'s own words (`complete`, `running`, `not started`) |
106
+ | An iteration's toolchain answer | `toolchain` in its open log entry (`no` or `specific`); `specific` carries the tooltip *not promotable* |
107
+
108
+ The ended line and the stage strip read `ended.json`, `final.json` and
109
+ `stages.py` through `scan.py`'s `after()`. The line is hidden until the search
110
+ ends, and a part that fails to read is blank and named in
111
+ `snapshot['after']['errors']`; the rest of the page still draws.
112
+
113
+ The pulse ages `state.json` against the larger of the scan interval and the
114
+ writer's measured scan cadence (the footer prints both): green under 2.5 of
115
+ those, orange under 10, and red beyond, with **publisher stopped · see
116
+ <writer.log>**. A failing scan turns it orange at once. What each message
117
+ beside it means: *When it looks wrong*, below.
118
+
119
+ ## Managing publishers
120
+
121
+ ```bash
122
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --start --interval 120
123
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --start --out <dir under the served root>
124
+ python3 $DASH/autoopt_monitor.py --status [$WORK/autooptimize] # pid, search, out dir; tab-separated
125
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --stop # every publisher of this search
126
+ python3 $DASH/autoopt_monitor.py $WORK/autooptimize --export out.html
127
+ ```
128
+
129
+ A publisher outlives the notebook kernel. `autoopt.py end` writes
130
+ `final/dashboard.html` with `--export` (`references/step4-final.md`) and
131
+ leaves the publisher running, so the ended line and the stage strip stay
132
+ current; `end --reopen` finds it still running. Stop it with `--stop` once the
133
+ search is finished (step 6), or by hand for a search that is over some other
134
+ way.
135
+ The export is meant to be passed around, so it leaves out the hostname, the
136
+ GPUs' serial numbers and who holds a GPU lease, and writes the home directory
137
+ as `~`. The live page shows all of them.
138
+ One writer publishes into a directory, and a search has one writer: a second
139
+ writer into a directory refuses, and `--start` or `show()` stops any writer
140
+ into it that the pidfile does not name and any writer of the search into
141
+ another directory, so `--out` moves the publisher. Those checks see one host.
142
+ Writers on two hosts that share the directory (a notebook on one machine,
143
+ the search on another) coordinate through the heartbeat `writer.host`: the
144
+ writer publishing keeps the directory unless the other sees the search's
145
+ processes and it does not. The other pauses, writing nothing, until that
146
+ heartbeat is 10 s old.
147
+ `--status` without a search lists other sessions' publishers too. Stop only
148
+ your own, always naming the search: a bare `--stop` stops every session's
149
+ publishers, so never run it. `--stop` returns once the process has exited, so
150
+ `--start` can follow at once. A wrong directory prints one `error:` line and
151
+ exits 1.
152
+
153
+ `--export` scans once and writes one self-contained, read-only HTML file that
154
+ opens from disk anywhere and reads `snapshot of <time>` where the pulse was.
155
+ Use it to share a finished search, or as the page for a user without
156
+ JupyterLab.
157
+
158
+ `show()` and `--start` replace a publisher started before the current
159
+ `scan.py`, `gpu_scan.py`, `monitor_writer.py` or `autoopt.py`, and a running
160
+ writer re-copies the front end when it changes, so an edit reaches the page on
161
+ the next poll plus a re-run of the cell.
162
+
163
+ ## When it looks wrong
164
+
165
+ | Symptom | Cause |
166
+ |---|---|
167
+ | `RuntimeError: the writer exited; see <out>/writer.log` | the writer died before its first `state.json`, usually an unwritable out directory. Read the end of `writer.log` |
168
+ | **scan failing · <reason> · last good scan N ago · see <writer.log>** | the scanner raises on this search (a bad `config.json`, a corrupt `state.json`); the writer keeps running and recovers on the next good scan. Fix the file it names; `python3 $DASH/scan.py $WORK/autooptimize` reproduces it |
169
+ | `N unreadable: …` beside the pulse | those iterations' records raise in the scanner (a malformed `result.json`) and their rows have status `unreadable`; the rest of the page is current |
170
+ | **the dashboard has been updated — re-run the cell** | the open page runs an older script than the one published; re-running the cell is the only fix |
171
+ | stuck on `Loading the dashboard…` | `dashboard.js` loaded but did not reach `startAutoopt`; the browser console names the error |
172
+ | `could not load …/dashboard.css` (or `.js`) | the out directory is outside the root of the server the notebook runs on; `--status` shows where it publishes |
173
+ | `connecting…` never clears | no `state.json` was read: the writer is not running or has not written yet. `--status`, then `writer.log` |
174
+ | `could not reload <module>: …` above the output | the reload chain hit an error in that module, and the old copy stays loaded. Fix it and re-run the cell |
175
+ | `TypeError: show() got an unexpected keyword argument` | the cell passes an argument `show()` does not take; `--start` rewrites the cell |
176
+ | `has no config.json` | pointed at something other than a search's `autooptimize/` or the directory holding it |
177
+ | Empty, but the directory is right | no iteration has a `result.json` yet; in-flight ones are the hollow diamonds on the floor |
178
+ | Numbers from another search | a publisher of another search held that output directory. `show()` replaces it and says so; `--status` shows which search each watches |
179
+ | Charts replaced by "Plotly failed to load" | plotly is not installed where the publisher runs: `pip install plotly` |
180
+ | `error: --export inlines plotly.min.js …` | the same, for `--export` |
181
+ | Host summary or process table says psutil is not installed | `pip install psutil`. Without `/proc` (macOS), psutil is also the only way `--status` finds publishers |
182
+ | GPU cards dimmed, **GPU reading N old: nvidia-smi is slow or failing** | the GPU query (NVML, or nvidia-smi where NVML will not load) has not answered for that long; the cards are its last answer. `time nvidia-smi` on the host. Publishers share one query, so many searches do not slow it |
183
+ | A timed GPU call is sometimes 0.2-2 s slower, the delay in its first allocations after `torch.cuda.empty_cache()` | each new nvidia-smi process stalls cudaMalloc in every CUDA process on the host while it starts. The publishers read through NVML and share one sample, so they start none; look for anything else on the host that runs nvidia-smi on a timer or on every command |
184
+ | GPU cards vanish and return, the notebook jumps, `--status` lists several pids for one search | several publishers write one search's payload. Re-run the cell or `--start`: it stops the extra writers |
185
+ | GPU cards flip between two sets of readings, the host summary's host name changes | publishers on two hosts write one payload directory on a shared filesystem. Re-run the cell, and `--start` on the other host: one of the two pauses |
186
+ | Red pulse, **publisher stopped** | the writer died; read its `writer.log`, then `--start` |
187
+ | A banner naming missing ids | a saved notebook restored old markup under a newer script; re-run the cell |
188
+ | `warning: <notebook> is outside the directory Jupyter serves` | the notebook cannot be opened from Lab; re-run with `-o` under the served root. The publisher is fine |
189
+ | `ValueError: <dir> is outside the directory Jupyter serves` | the output directory must be under the Jupyter root; pass `out_dir=` there |
190
+ | External validation section with no chart | configured but no round validated yet (`validate` refuses until `--approve`), or no measure reported a number; the sidebar card says which |
191
+
192
+ ## Without a browser
193
+
194
+ `autoopt.py table` prints a row per iteration, as the charts plot them, and
195
+ `scan.py` prints the whole payload:
196
+
197
+ ```bash
198
+ python3 $AO/autoopt.py table $WORK
199
+ python3 $DASH/scan.py $WORK/autooptimize | head -40
200
+ ```
201
+
202
+ Answering a question about a search without a dashboard:
203
+ `references/reading-a-search.md`.
@@ -0,0 +1,55 @@
1
+ # The GitHub documents: what every one carries
2
+
3
+ Step 5 (`references/step5-ship.md`) can open three documents on the
4
+ original's GitHub repository, each from its own folder under `$WORK/ship/`:
5
+
6
+ | Document | Folder | Rendered by | Opened by | Reference |
7
+ |---|---|---|---|---|
8
+ | the optimization PR | `pr-optimization/` | `opt_pr_body.py` | `autoopt.py pr` | `references/pr-optimization.md` |
9
+ | the unit-test PR | `pr-tests/` | `tests_pr_body.py` | `tests_pr_push.py` | `references/pr-tests.md` |
10
+ | the bug report | `issue-bugs/` | `issue_body.py` | `issue_body.py file` | `references/issue-bugs.md` |
11
+
12
+ `ship.py rehearse` and `ship.py post` run each opener; none is run on its
13
+ own except to repair one post.
14
+
15
+ ## What every document holds
16
+
17
+ - **Only what the search recorded.** Every number comes from a table a script
18
+ wrote from the search's records: medians and ranges of runs, the paired
19
+ timing at the end, each output check's worst value, the test counts, the
20
+ coverage step 1 measured. No document mentions a measurement the search did
21
+ not make.
22
+ - **A title** of at most 72 characters, starting with a capital letter, with
23
+ no closing period, stored beside the body as `body.title`. Nothing is put in
24
+ front of it.
25
+ - **A body that is rendered, never edited.** A script writes the tables, the
26
+ document writer writes `prose.md` (fields that each start with `=== <field>`), and
27
+ the renderer joins them; the same inputs give the same bytes. A change goes
28
+ to the tables or the prose and is rendered again. Prose writes a
29
+ `{{token}}` where it needs a number a table gives; the optimization PR's
30
+ renderer refuses the number typed.
31
+ - **Nothing about how it was written.** No renderer adds a line naming the
32
+ tool, the model or the lab; the document writer adds none either.
33
+
34
+ ## What no document says
35
+
36
+ `lint_text.py` refuses these in every title, body, commit message and comment
37
+ a branch adds, and so does every renderer:
38
+
39
+ - the tool or the lab: no document names auto-optimize or the laboratory that
40
+ made it;
41
+ - the search's own words: winner, winning or kept iteration, baseline, gate,
42
+ round N, "the search", "the base" for the original branch, and iteration
43
+ labels such as A12. Say what the change does, name the target branch
44
+ (`main`), and say what a check compares;
45
+ - a path on this machine (`~/`, `/home/`, `/tmp/`, `$WORK`).
46
+
47
+ ## Numbers that do not exist yet
48
+
49
+ The bug report is posted first and the unit-test PR next, so a document
50
+ drafted before them holds the stand-in `#<bug issue>` or `#<tests PR>`. A
51
+ renderer fills each from `issue-bugs/filed.json` or `pr-tests/pr.json` once
52
+ it exists, and `ship.py post` renders each document again just before posting
53
+ it. A preview accepts a stand-in; a post refuses one. A document that was not
54
+ chosen (`after.ship_documents`) is never named: a renderer leaves out the
55
+ sentence that would name it and refuses a stand-in for it.
@@ -0,0 +1,87 @@
1
+ # Changing what the skill does
2
+
3
+ Most changes a user wants are settings a search already reads; a few need
4
+ the code edited. This file lists both, each with the file that explains it.
5
+ A setting changed while a search runs is recorded with the user's words
6
+ (`config --set … --reason`), and some change how later iterations are judged
7
+ (`references/changes.md`).
8
+
9
+ ## Settings a search reads
10
+
11
+ Every one is a `config.json` key, set at `init` or with `autoopt.py config
12
+ $WORK --set KEY=VALUE --reason "<the user's words>"`; `references/layout.md`,
13
+ *config.json*, defines each. `config --set` creates the `checks`, `after` and
14
+ `keep` blocks when they are absent; the `tests` and `external_validation`
15
+ blocks are added only with `init --force`, and `config --set` then edits
16
+ them. When it refuses a key, it lists every key it accepts.
17
+
18
+ | To change | Set | Read |
19
+ |---|---|---|
20
+ | The run plan: runs, the time limit, the GPUs, the floor, the worker count, a gate's threshold, the build's variables, the task | `runs_per_iteration`, `confirm_runs`, `staged`, `timeout_seconds`, `gpu`, `gpus_per_agent`, `floor`, `workers`, `gates.<name>.threshold` (`.op`, `.tol`), `build_env.<VAR>`, `task` | `references/layout.md`, *config.json*; a gate: `references/changes.md`, *Changing a gate in place* |
21
+ | What one run measures and how it is launched | the benchmark, which writes `metrics.json` (any objective, gates and observers); `command` until the baseline has run | `references/layout.md`, *metrics.json — the contract every benchmark meets* |
22
+ | A number recorded from now on, never optimized | `config --add-observer NAME`; it gets its own dashboard chart | `references/changes.md` |
23
+ | How outputs are compared, the timing probe, the first call, the build, the profile | `checks.compare`, `checks.time`, `checks.first_call`, `checks.build`, `checks.profile`, `checks.threads` | `references/step2-baseline.md`, *Write the checks* |
24
+ | The package's tests as a gate, a subset first | `tests`, with `{selected}` | `references/repo-mode.md`, *The unit-test gate* |
25
+ | A wider margin, or a least gain, for keeping a change | `keep.band_k` (noise bands, default 1), `keep.min_gain_pct` (percent of the parent's median, default 0); the runner still promotes | `references/promotion.md` |
26
+ | Any other keep rule (a tie rule, a second measure that must not regress) | `promote: orchestrator`, and the rule in `spec.md` | `references/promotion.md` |
27
+ | The machine's GPU allocator | `gpu_command`, the words before a command that set `CUDA_VISIBLE_DEVICES` | `references/step2-baseline.md`, *GPU leases* |
28
+ | When another process counts as busy | `busy_percent` (default 110, percent of one core) | `references/step2-baseline.md`, *Check the machine is quiet* |
29
+ | A check on inputs the search never measures | `external_validation`, run only after the user approves | `references/external-validation.md` |
30
+ | How long an orchestrator phase runs before it hands back | `loop_handback` (settled iterations, default 16) | `references/step3-rounds.md`, *The orchestrator subagent* |
31
+ | The model the iteration and setup subagents run on | `subagent_model` | `references/step0-interview.md`, *The questions* |
32
+ | Build files, binaries or vendored code as fair game | `allow_build_changes` | `references/subagent.md`, *Portability* |
33
+ | When to stop, the budget, the disk, the paired timing's cap, the commit trailer | `after.stop`, `after.budget_iterations`, `after.budget_hours`, `after.budget_stages`, `after.disk`, `after.pair_cap_hours`, `after.commit_trailer`, … | `references/step0-interview.md`, *The questions* |
34
+ | How the winner ships, and the branch names | `after.ship`, `after.ship_documents`, `after.branch_prefix`, `after.pr_remote`, `after.pr_head_owner`; `--branch DOC=NAME` on `ship.py rehearse` and `post` | `references/step5-ship.md` |
35
+
36
+ ## Code a search shares
37
+
38
+ `autooptimize/tools/` holds helpers later iterations reuse, and
39
+ `tools/checkers/` the checkers; each is listed in its folder's `README.md`
40
+ (`references/shared-knowledge.md`). A benchmark reads the baseline's saved
41
+ outputs from `AUTOOPT_REF`, which its command sets
42
+ (`references/step2-baseline.md`).
43
+
44
+ ## Environment variables
45
+
46
+ | Variable | Does |
47
+ |---|---|
48
+ | `AUTOOPT_TMPDIR` | the folder the scripts put temporary files in |
49
+ | `AUTOOPT_BUSY_PERCENT` | overrides `busy_percent` |
50
+ | `AUTOOPT_SKIP_QUIET_CHECK=1` | skips the busy check before A0, in `width` and in `busy`; the way past it on a machine without `/proc` |
51
+ | `AUTOOPT_SKIP_SPEC_CHECK=1` | skips the refusals while `spec.md` has a TODO line, for tests and scripted searches |
52
+ | `CUDA_VISIBLE_DEVICES` | when set, taken as the GPUs this process already holds under a lease, so `gpu_command` is not run |
53
+ | `CLAUDE_CODE_SESSION_ID` | recorded by `init` as `origin.session`; `tokens` adds the project folder holding that session's transcript to the folders it reads |
54
+ | `GPU_LEASE_DIR` | a folder of GPU lease files the dashboard reads lease holders from (`references/dashboard.md`) |
55
+ | `GPU_SCAN_NVML` | the NVML library file the dashboard loads in place of `libnvidia-ml.so.1` |
56
+ | `JUPYTER_RUNTIME_DIR` | one more folder the dashboard looks in for running Jupyter servers |
57
+
58
+ `AUTOOPT_LEASE_MARK`, `AUTOOPT_DETACHED` and `AUTOOPT_WRITE_REFERENCE` are set
59
+ by the scripts for their own children; do not set them.
60
+
61
+ ## Hooks for a skill built on this one
62
+
63
+ A skill that writes the same layout under other rules (`auto-optimize-ml`)
64
+ imports `autoopt` and adds to it, rather than copying it:
65
+
66
+ | Hook | Does |
67
+ |---|---|
68
+ | `config.json` `skill.name` | the skill a search belongs to; every script refuses a search another skill made (`references/layout.md`, *Version fields*) |
69
+ | `autoopt.register_after(defaults, kinds, choices, whole, nonneg, checks)` | adds that skill's `after.*` answers, which `config --set` then accepts and checks |
70
+ | `autoopt.EXTRA_PARSERS` | a list of `add(subparsers)` functions run when `autoopt.main()` builds its parser: subcommands of that skill's own |
71
+
72
+ ## When no setting fits: where to edit
73
+
74
+ In a clone of the repository, edit the file, then run the suites named
75
+ (`python3 tests/code/run_tests.py <suite>`; the dashboard's are
76
+ `tests/code/dashboard/test_frontend.py` and `test_notebook.py`).
77
+
78
+ | To change | Edit | Suites |
79
+ |---|---|---|
80
+ | The idea categories | `CATEGORIES` and `SHORT` in `scripts/autoopt.py`, the list in `references/idea-miner.md`, `CATEGORY_ORDER` and `SHORT` in `scripts/dashboard/static/dashboard.js` | `test_runner`, `test_frontend` |
81
+ | The words a shipped document may not use | `WORDS`, `STRICT` and `PATHS` in `scripts/lint_text.py` | `test_lint_text` |
82
+ | The optimization PR's sections | `scripts/opt_pr_body.py`, and `references/pr-optimization.md` | `test_ship` |
83
+ | A ship route | `AFTER_CHOICES['ship']` in `scripts/autoopt.py`, `SHIP_NEXT` in `scripts/stages.py`, `scripts/ship.py`, and `references/step5-ship.md` | `test_ship`, `test_stages` |
84
+ | The dashboard's colors | the tokens on `:root` in `scripts/dashboard/static/dashboard.css` | `test_frontend` |
85
+
86
+ A changed rule goes in the reference file that states it, in the same
87
+ commit, and a new term in `references/glossary.md`.