interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / tools / omegallm / ctlsamp / README.md

121 lines · 7025 bytes Raw Blame History Rendered
1# ctlsamp: controller telemetry sampler (seeded Omega)
2
3`ctlsamp.om` is the telemetry instrument for the wsp controller study (Linear DRA-187,
4`docs/omegallm/WSP-CONTROLLER.md` section 5). It is the instrument going forward. It replaces the
5old `sampler.py` and `ups-sampler.sh`, which produced the traces already filed in
6`evidence/OMEGALLM/wsp-ctl-traces-20261107/` and were deleted when this port landed.
7
8It is a measurement tool, not product code. It needs no root, does no GPU work and changes no
9setting. Each sample it:
10
11- reads `/proc/stat`, `/proc/loadavg`, `/proc/pressure/{cpu,memory,io}`,
12 `/sys/class/thermal/thermal_zone*/temp` and `/proc/meminfo`;
13- runs `nvidia-smi --query-gpu=utilization.gpu,utilization.memory,power.draw,temperature.gpu,clocks.sm,pstate --format=csv,noheader,nounits`
14 once, through `fork`, `pipefds`, `dupfd` and `execprog`, with stdout on a pipe and stderr on
15 `/dev/null`;
16- runs `upsc spark` once the same way;
17- appends one JSON object per line to OUT. A row longer than the 64 KiB output buffer (only possible
18 when command output is full of escaped control bytes) is written in more than one write, uncut.
19
20Timing uses `monons` (schedule and `sample_cost_us`) and `realns` (`ts_unix`, `ts_utc`). Each sample
21starts one interval after the previous sample started, or at once if the previous sample took longer
22than the interval; there are no catch-up samples. Just before each `nvidia-smi` launch the sampler
23also waits until `interval_s` has passed since the previous launch, so launches are never closer than
24`interval_s` on its own clock, whatever the `/proc` reads before them cost (the child's own start
25adds a few milliseconds of spread: 4.996 to 5.003 s measured at a stand-in). A slow sample (a child at
26its 4 s deadline) delays later rows instead of bunching them.
27
28## Build
29
30With the pinned compiler (omega-mv `e5b32567`, omc sha256
31`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`):
32
33```
34taskset -c 0 nice -n 19 omc < ctlsamp.om > ctlsamp && chmod +x ctlsamp
35```
36
37omc exits with the error code on a refused compile. Do not run the output of a refused compile.
38
39## Usage
40
41```
42taskset -c 0 nice -n 19 ./ctlsamp OUT [interval_s] [count] [nvsmi_path] [upsc_path] [raw_log]
43```
44
45| Argument | Default | Rule |
46|---|---|---|
47| `OUT` | required | opened for append, created mode 0644 |
48| `interval_s` | 5 | whole seconds, 5 to 86400. 5 is the floor because of the machine rule of at most one `nvidia-smi` read every 5 s |
49| `count` | 360 | 0 to 999999 rows (999999 is the largest `while` bound this omc accepts) |
50| `nvsmi_path` | `/usr/bin/nvidia-smi` | full path, no PATH search; an empty argument means the default |
51| `upsc_path` | `/usr/bin/upsc` | full path, no PATH search; an empty argument means the default |
52| `raw_log` | none | if given, every raw byte read is appended here (see below) |
53
54The child processes get an empty environment. Run it on core 0 at nice 19, as above.
55
56## Exit codes
57
58| Code | Meaning |
59|---|---|
60| 0 | all rows written |
61| 2 | usage error, or OUT or raw_log could not be opened |
62| 3 | a kernel file (`/proc/...`) could not be read; the old Python sampler crashed here too |
63| 4 | a write to OUT or raw_log failed or came back short (for example a full disk); rows before the failing one are complete, the failing row may be partial |
64
65A failing `nvidia-smi` or `upsc` is not an exit: it is recorded in the row (next section).
66
67## Row format
68
69Keys are sorted and separated the way Python `json.dumps(row, sort_keys=True)` does (", " and
70": "), so rows match `trace-001.jsonl` byte for byte in layout. Keys:
71
72- `core_busy_pct` (`c0`..`c19`): busy share of each core since the previous sample, from
73 `/proc/stat` (first 8 counters; idle is idle plus iowait), rounded half up to 2 decimals, or
74 `null` when the core's counters did not move.
75- `loadavg` (3 numbers) and `runnable` (string, for example `"6/3867"`) from `/proc/loadavg`.
76- `psi_cpu`, `psi_mem`, `psi_io`: `some_` and `full_` `avg10`, `avg60`, `avg300` (numbers) and
77 `total` (integer).
78- `thermal_c` (`tz0`.. until the first missing zone): degrees C, millidegrees divided by 1000.
79- `mem`: `MemTotal_kb`, `MemAvailable_kb`, `SwapTotal_kb`, `SwapFree_kb` (integers).
80- `gpu_util_pct`, `gpu_mem_util_pct`, `gpu_power_w`, `gpu_temp_c`, `gpu_sm_mhz`: numbers printed
81 the way Python prints a float (`93.0`, `44.64`); a field that is not a number (for example
82 `[N/A]`) is kept as a string. `gpu_pstate` is a string.
83- `battery_runtime_s`, `input_voltage`, `ups_load_pct`, `ups_realpower_nominal_w`: numbers in the
84 awk `$2+0` style of the old shell sampler (`121.0` prints as `121`); `ups_status` is a string.
85- `seq` (from 0), `ts_unix` (seconds, rounded to 3 decimals, trailing zeros dropped), `ts_utc`
86 (`YYYY-MM-DDTHH:MM:SSZ` from the same clock read), `sample_cost_us` (integer).
87
88These are the keys of `trace-001.jsonl` plus the UPS keys of `ups-001.jsonl`, now in one row.
89
90Errors:
91
92- `"gpu_error": "rc=N"` when `nvidia-smi` exits with code N (a path that cannot be executed gives
93 `rc=127`), `"rc=-S"` when it dies on signal S, `"rc=-1001"` when the pipe or fork failed, and
94 `"timeout"` when it has not finished in 4 s (it is then killed with signal 9). The six GPU keys
95 are absent in that row, as in the old sampler.
96- `"truncated"` when the command wrote more than 8192 bytes. The sampler keeps the first 8192
97 bytes, reads the rest until the command ends and drops it, so a command with a large or endless
98 output can never block on a full pipe. Both labels are joined when both apply, for example
99 `"timeout,truncated"` for a command that writes without end and is killed at 4 s, or
100 `"rc=1,truncated"`. The keys of that command are absent in that row.
101- `"ups_error"` with the same forms when `upsc` fails. The five UPS keys are absent in that row.
102 This differs from the old shell sampler, which wrote zeros when `upsc` failed.
103
104## raw_log
105
106With `raw_log`, each read is appended as a header line `== <seq> <source> <nbytes>`, then the exact
107bytes, then a newline. Sources are the kernel file paths, `gpu` (the `nvidia-smi` stdout) and `ups`
108(the `upsc` stdout). `/proc/stat` appears once before row 0 (the baseline) and once per row, so the
109busy shares of row k come from the `/proc/stat` record of row k and the one before it. This is the
110same-moment reading of the original commands used by the port gate.
111
112## Gate checks and ORACLE label
113
114The port gate (`evidence/OMEGALLM/wsp-ctl-traces-20261107/gate-om-20261107/`) compares the rows with
115the raw log and with the independent sensors log; `gate-om-drain-20261107/` next to it holds the
116large and endless output controls and a 30 s rerun of the same checks. The comparators are ORACLE
117only and are not shipped:
118
119- ORACLE: `/usr/bin/jq` (it reports `jaq 3.1.1`) for the key and type signature;
120- ORACLE: Wolfram Language through the Wolfram MCP evaluator for the paired value checks. The
121 Wolfram programs that ran are filed next to their outputs (`oracle-*.wl`, `oracle-*.out`).