interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / device-window / README.md

132 lines · 7288 bytes Raw Blame History Rendered
1# Device-window controls (CPU only)
2
3Two programs run the GB10 device window: `tools/run-device-window.sh` and its
4Omega successor `tools/run-device-window.om` (Linear DRA-441). The shell script
5stays until one device window under a queen-scheduled lease, run by the Omega
6program, matches the shell script's rows (`evidence/device-window/L939-w3`);
7it is removed in the same change that files that window's evidence. Both
8controls below run on the CPU, open no GPU, never call the real `spark-window`
9and need no lease.
10
11## Compiler
12
13The Omega programs here (`race.om`, `tools/run-device-window.om`) are built
14with omega-mv `main` `seed/out/omc`, sha256
15`34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3` (omega-mv
16`50feb135`; unchanged through `e8fcdc01`, 2026-11-16).
17
18```sh
19printf '%s %s\n' 34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3 "$OMC" | sha256sum --check --strict
20mkdir -p build
21"$OMC" < tools/run-device-window.om > build/run-device-window && chmod +x build/run-device-window
22"$OMC" < tests/device-window/race.om > build/race && chmod +x build/race
23```
24
25`build/run-device-window` finds the repository as the parent of its own
26directory, so keep it in `build/`.
27
28## compare.py: the successor against the shell script
29
30```sh
31python3 tests/device-window/compare.py tools/run-device-window.sh build/run-device-window build/cmp
32# COMPARE PASS cases=N, exit 0
33```
34
35`build/cmp` must not exist; remove it afterwards. The cases are listed in
36`main()` of `compare.py`; the first eight are the refusal controls:
37`refuse-no-ledger` (no `--ledger`), `refuse-ledger-needs-id` (`--ledger`
38without an id), `refuse-ledger-chars` (`a/b`), `refuse-unknown-arg`
39(`--bogus`), `refuse-pairs-not-integer` (`5x`), `refuse-pairs-lt-5` (`4`),
40`refuse-dry-cvd-unset` (a dry-run with `CUDA_VISIBLE_DEVICES` unset) and
41`refuse-dry-in-window` (a dry-run inside `SPARK_WINDOW`). Then come the other
42refusals (`CUDA_VISIBLE_DEVICES=0` among them), complete and incomplete dry-run
43plans, and device mode against a fake `spark-window` that runs every row on
44the CPU: a passing window, failing rows, an existing evidence directory, a
45failed open, a missing cubin directory and missing inputs. Each of these
46compares exit status, stdout, stderr and the whole evidence directory. The
47fake tree root is a git repository with a modified tracked file, and one
48conformance result file is over 64 KiB.
49
50Four cases kill a run while a window is held on the fake chip:
51`device-signal-closes` sends SIGTERM to the whole process group (both programs
52close the window by its id); `device-parent-term` and `device-parent-kill`
53kill only the driver (SIGTERM, then kill -9) while the row keeps running. The
54window must not be closed before the row exits: on SIGTERM both programs close
55after the row; on kill -9 the shell script never closes (the lease runs out)
56and the successor closes after the row. `device-kill-in-open` kills only the
57driver (kill -9) while `spark-window open` is still running: the shell script
58never closes that window; the successor's closer reads the id from the open
59itself and closes the window after the open exits, and no row runs.
60`om-closer-gone` runs the successor only and kills its closer (kill -9) while
61a row runs: nothing can close the window then, and the successor must say so,
62naming the window, on stderr and in `window.txt`, and close nothing.
63
64`refuse-dry-cvd-huge` and `refuse-dry-in-window-huge` give the dry-run
65refusals a 5000-byte value, which both programs quote whole. `om-refuse-env-*`
66run the successor only: an environment entry over 65535 bytes, or an
67environment too large for the execprog packet, is refused with exit 3 before
68anything is printed, opened or created.
69
70Negative controls (`evidence/device-window/DRA-441/gates.sh` runs them and
71expects exit 1): a mutant of the successor that ignores the result of the
72evidence-directory `mkdir` gives `COMPARE FAIL`; a mutant whose rows do not
73hold the closer's hold pipe fails `device-parent-kill` (the window is closed
74while the row still runs); a mutant whose closer takes a lost driver as
75"nothing to close" fails `device-parent-term` and `device-parent-kill`
76(`device-kill-in-open` still passes under it: there the closer takes the id
77from the open's own output, not from the driver).
78
79Deliberate differences, listed in the header of `tools/run-device-window.om`:
80`script_sha256` is the hash of the binary; children run as
81`/usr/bin/env -i -- <environment> CMD` because `execenv` takes at most 64
82entries and 4096 bytes (the environment on spark-b87b had 78 entries and 4796
83bytes on 2026-11-16); a closer process replaces the shell's `trap`, so a
84signal ends the program by that signal where the shell exited 130, a kill -9
85of the driver still closes the window once its rows have exited, and a row's
86standard input is the closer's hold pipe; `NN-*.out.sha256` is in bytewise
87order; `--pairs` without a value, a value above 2^63-1, an unset `HOME`, a
88window id that is not 1..4095 bytes of `[A-Za-z0-9._-]` and a value output over
8964 KiB are refused with their own lines.
90
91## race.om: the evidence directory is created once
92
93`race.om` checks the evidence-directory step (DRA-105, finding F5 of the
94DRA-106 audit refresh). Evidence is additions only: a run under a ledger id
95that already has a directory must refuse, and two runs started at the same
96moment with the same new ledger id must not both get past that step. Both
97programs create `evidence/device-window/<ledger>` with one `mkdir` (no `-p`),
98which either creates the directory or fails, so exactly one of two concurrent
99runs gets it.
100
101Each trial, in a scratch tree holding a copy of the program:
102
1031. Two device-mode runs with the same new ledger id start together (both block
104 on one pipe until the driver writes to it). Pass: one exits 2 with a
105 `REFUSE:` line, the other exits 1 without one.
1062. The directory holds an empty `rc.txt`, a `window.txt` and no row log.
1073. A third device-mode run on the same id exits 2 with `REFUSE:` and leaves
108 `rc.txt` and `window.txt` the same size.
1094. A dry-run on the same id prints `EXISTS` and exits 1.
110
111No run reaches a window call. `SPARK_WINDOW=NEGCTL-none` skips the open,
112`CUBIN_DIR` names a missing directory so the run that got the directory stops
113at the cubin copy (exit 1) before the first row, and the runs get only
114`PATH=/usr/bin:/bin`, where there is no `spark-window`.
115
116A program whose name ends in `.sh` is run with `/bin/sh`; anything else is
117copied to `tools/run-device-window` in the scratch tree and run directly.
118
119```sh
120build/race build/run-device-window build/race-om 100 # RACE PASS, exit 0
121build/race tools/run-device-window.sh build/race-sh 100 # RACE PASS, exit 0
122```
123
124`SCRATCH` must not exist; remove it afterwards. Usage errors exit 2.
125
126Negative controls: the script at `07f276fc` checked `[ ! -e "$out" ]` and then
127ran `mkdir -p "$out"`. Both runs of a pair passed the check in 69 of 100
128trials of the logged fresh-clone run on spark-b87b (97 of 100 in an earlier
129working-tree run): `RACE FAIL`, exit 1. A mutant of the shell fix that uses
130`mkdir -p` fails every trial, and its sequential check too. Log:
131`evidence/device-window/race-F5.log`. A mutant of the successor that ignores
132the result of its `mkdir` fails every trial in the same way.