Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/tools/omegallm/wpatch/README.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / tools / omegallm / wpatch / README.md` 196 lines ยท 10634 bytes Raw Blame History Rendered 1 # wpatch 2 3 CPU-only checked patches for Drake's OLLMCK02 checkpoints. The product, its build 4 driver and its test driver are Omega. It does not import model weights, run 5 inference, open a GPU, or claim a quality improvement. One small Python file is a 6 labeled ORACLE (a digest calculator); it is not part of the product or the build. 7 8 ## Files 9 10 | File | Role | 11 | --- | --- | 12 | `wpatch.om` | The product: inspect, diff, show, validate, apply, verify, revert, bind, checkbind. | 13 | `wpbuild.om` | Omega build driver. Builds `wpatch` and `wpcheck`. | 14 | `wpcheck.om` | Omega test driver. Runs every case, owns all exit codes, files, refusals and PASS/FAIL. | 15 | `wporacle.py` | ORACLE only. Answers digest requests from wpcheck; never decides PASS or FAIL. | 16 17 ## Build 18 19 From the repository root, with the pinned omega-mv checkout beside it, compile 20 the build driver once with the pinned compiler and run it: 21 22 ```sh 23 OMC=../omega-mv/seed/out/omc 24 taskset -c 0 nice -n 19 "$OMC" < tools/omegallm/wpatch/wpbuild.om > /tmp/wpbuild && chmod +x /tmp/wpbuild 25 taskset -c 0 nice -n 19 /tmp/wpbuild . "$HOME/work/wsp/wpatch-build" "$OMC" ../omega-mv 0 26 ``` 27 28 Arguments are `REPO OUT OMC OMEGA_MV CORE`; all five are required. OUT is created 29 when absent. The driver: 30 31 1. requires the compiler's SHA-256 to equal the pin below; 32 2. extracts `om/sha256/sha256-om2.om` at the omega-mv pin with git and requires 33 its SHA-256 to equal the pin below; 34 3. vendors it in Omega: the SHA layout goes before every function, `export fn` 35 becomes `fn`, and SHA private symbols receive a `ws` prefix. The exact source 36 transformation is written to `OUT/sha256.diff` as a review record; 37 4. composes `OUT/wpcheck-all.om` (SHA layout, SHA functions, `wpcheck.om`) and 38 compiles it to `OUT/wpcheck`; 39 5. checks the three vendored net sources with `OUT/wpcheck sum`, the Omega 40 SHA-256, against their pins (below); 41 6. composes `OUT/ollm.om` in Omega exactly as the aarch64 ollm build does: the 42 line `om2`, then these files from `native/omegallm/` concatenated in order: 43 `net/http.om net/json.om net/jsonw.om math.om data.om lpool.om model.om 44 adam.om ckpt.om bpe.om cli.om lio.om serve.om nogpu.om`; compiles it to 45 `OUT/ollm`; 46 7. composes `OUT/wpatch-all.om` (SHA layout, ollm with its entry point renamed 47 `wpollm`, SHA functions, `wpatch.om`) and compiles it to `OUT/wpatch`; 48 8. prints the SHA-256 of the compiler, the SHA source, `ollm.om`, ollm, both 49 other compositions and both other binaries, and ends with `WPBUILD PASS`. 50 51 Every compile runs on CORE. Exit codes: 0 PASS, 2 usage, 3 a pinned digest 52 differs (compiler, SHA source or a net source; the line names which), 4 the 53 ollm source does not hold exactly one `fn main to int`, 5 I/O or capacity, 6 a 54 host tool failed (its status is printed), otherwise the compiler's own status. 55 `native/omegallm` is never changed. The `ollm`, `ollm.om`, `wpatch` and 56 `wpatch-all.om` outputs are byte-identical to the earlier shell build (SHA-256 57 below). 58 59 Compiler: omega-mv ``e5b32567a7aff3ce594e3254a622a846a6cd190b``, omc SHA-256 60 ``2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f``. 61 SHA source: `om/sha256/sha256-om2.om` at that revision, SHA-256 62 ``dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb``. 63 Net source pins (SHA-256): `net/http.om` 64 ``aff258ecd3858454056811a5e6fe1f660f9d650a7207d6c41885105110e046a7``, 65 `net/json.om` ``456254fc754ea35103ced480407b24fc1a3896d094b90ae0e9623e7b6594e2d2``, 66 `net/jsonw.om` ``464f649e8207495f5d67fe8795d31e42ea3ccebd9ed547274dab802d4f7c5f21``. 67 ollm: SHA-256 ``819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea``, 68 from `ollm.om` SHA-256 ``2d13b609945a97ad95dba8626e67588d87c6aec64043affbaf4c107af246eb96``. 69 wpatch: SHA-256 ``bf993a780c7421cc2cd23d42fef5692135e9bd339f19a90059d4ef7f17be0847``, 70 from `wpatch-all.om` SHA-256 ``7e8b3ca2cf378af25029ce42ca6c760c880fa3612691216e2f2339c369c22591``. 71 72 Host tools the build driver runs (pinned build tools, not product code): the 73 compiler, git, sha256sum (for the compiler and SHA source pins, which cannot be 74 checked by the SHA they are about to build), diff, taskset and nice. 75 76 ## Commands 77 78 ```text 79 wpatch inspect CK 80 wpatch inspect CK KIND LAYER R0 R1 C0 C1 81 wpatch diff BASE EDITED POLICY PARAMS_FILE RATIONALE_FILE OUTDIR 82 wpatch show PATCH 83 wpatch validate PATCH BASE 84 wpatch apply PATCH BASE OUT 85 wpatch verify PATCH CK 86 wpatch revert PATCH EDITED OUT 87 wpatch bind PATCH CK RUNTIME_BIN OUT 88 wpatch checkbind BINDING CK RUNTIME_BIN 89 ``` 90 91 Indices are zero-based. Slice ends are exclusive. Tensor kinds are `wte`, `wpe`, 92 `g1`, `wq`, `wk`, `wv`, `wo`, `g2`, `w1`, `w2`, `gf`. Use layer zero for the three 93 nonlayer tensors. `w1` is D by F and `w2` is F by D, in checkpoint row-major order. 94 Offsets printed by inspect are flat weight indices, not byte offsets. Decimal 95 values are diagnostic; the adjacent 16-digit hexadecimal word is authoritative. 96 Inspect prints all header fields and per-tensor SHA, RMS, maximum absolute finite 97 value, and nonfinite count. The scaled RMS accumulates finite values, treating 98 nonfinite values as zero in its full-tensor denominator. Check the nonfinite 99 count before interpreting either statistic. 100 101 `diff` requires matching headers apart from FNV and bit-identical m/v arrays. 102 It records the changed weight words and applies the requested optimizer policy 103 to its expected output, not to either input. Policy 0 keeps m/v; policy 1 clears 104 changed m; policy 2 clears changed m and v. Policies 1 and 2 save old m/v words 105 for exact rollback. Changes that disappear in f32 remain in the manifest. 106 Params and rationale are exact UTF-8 file contents, each at most 16 MiB. They may 107 be empty. Params need not be JSON. OUTDIR must exist. The result path is printed. 108 109 `show` emits JSON with identities, policy, total changed count, the first twenty 110 entries, params and rationale. `validate` checks the base, all entries and tensor 111 records, and the complete simulated output including its f32 identity. `apply` 112 writes a new file only after this check and rechecks the written bytes. `verify` 113 checks an applied checkpoint and reports total edits and edits surviving f32. 114 `revert` restores the exact old weight and optimizer words and requires the base 115 SHA to match. All checkpoint-writing commands refresh the payload FNV. 116 117 `bind` first verifies the applied checkpoint, then binds checkpoint SHA, f32 118 weight SHA, runtime executable SHA and manifest SHA in a checksummed record. 119 `checkbind` checks that record and the checkpoint/runtime identities. It takes no 120 manifest argument, never rereads the manifest, and cannot detect a replaced 121 manifest. It also does not load a model or invalidate an existing runtime cache. 122 A serving caller must retain the intended manifest identity, run checkbind, 123 discard cached weights and KV state, and load the exact bound files before 124 claiming a repaired run. Merely creating a binding is not deployment. 125 126 No output is overwritten, including a symlink or an output equal to BASE. Patches 127 and bindings are created read-only. Checkpoints are mode 0600. Inputs are mapped 128 privately, never written. Keep all inputs and the output directory stable while 129 a command runs. These are integrity checks, not cryptographic signatures or 130 protection against a malicious concurrent writer. A crash or forced termination 131 can leave a partial newly created output; do not use it without verification. 132 133 The full binary format, limits and refusal codes are in 134 [`docs/omegallm/WSP-PATCH.md`](../../../docs/omegallm/WSP-PATCH.md). 135 136 ## Acceptance: wpcheck 137 138 `wpcheck` is built by wpbuild into the same OUT directory. WORK must not exist; 139 wpcheck creates it. ORACLE is the path of `wporacle.py`. 140 141 ```sh 142 B="$HOME/work/wsp/wpatch-build" 143 taskset -c 0 nice -n 19 "$B/wpcheck" small "$B" "$HOME/work/wsp/ck/wpatch-small-new" \ 144 tools/omegallm/wpatch/wporacle.py 145 ``` 146 147 Exit codes: 0 PASS, 1 FAIL (the first failed check is printed and the run stops), 148 2 usage. Output is plain text: a header with the Omega SHA-256 of the wpatch under 149 test; for each child process its argument list, its stdout as `| ` lines, and 150 `EXIT got=X want=Y elapsed_ns=T`; one `PASS label` line per check; and a last line 151 `WPCHECK PASS checks=N commands=M` or `WPCHECK FAIL ...`. Children run through 152 fork, execprog and waitpid with an empty environment and stdout captured through 153 a pipe. 154 155 `wpcheck sum FILE` prints the Omega SHA-256 of FILE (the vendored SHA, not the 156 ORACLE) as 64 hex digits and a newline. wpbuild uses it for the net source pins. 157 An unreadable FILE is a FAIL with exit 1; an empty FILE gives the digest of no 158 bytes. 159 160 The small mode trains an own-model small checkpoint, runs every command and all 161 three optimizer policies, parses every manifest, tensor record, entry and binding 162 field, checks f32 cast boundaries, and exercises each corruption with its exact 163 refusal code and no output left behind. It builds the expected output bytes 164 directly from BASE and the requested edits, including optimizer resets, without 165 taking expected values from a manifest. A fully rehashed manifest for a different 166 finite value passes product verify but is rejected by this independent byte 167 comparison; that in-run negative control must be rejected for the run to PASS. 168 169 The real mode takes the pinned round40 checkpoint as a fifth argument. It 170 requires the pinned base SHA-256, changes ten layer-3 w2 entries in a copy, 171 performs diff/validate/apply/verify/revert, compares every output byte against the 172 independently built expectation, and checks the restored SHA and expected f32 SHA. 173 It never writes into the source model directory. Queue behind other authorized 174 core-19 work: 175 176 ```sh 177 flock -w 3600 -o "$HOME/handoffs/hive/queen/pool-19.lock" \ 178 taskset -c 19 nice -n 10 "$B/wpcheck" real "$B" "$HOME/work/wsp/ck/wpatch-real-new" \ 179 tools/omegallm/wpatch/wporacle.py "$HOME/.local/share/omega-tool-model/round40/model.ck" 180 ``` 181 182 Do not run on reserved cores 3, 7 or 15. 183 184 ## ORACLE 185 186 `wporacle.py` (Python 3.12.3 standard library: hashlib, struct, mmap) is the only 187 Python. It is an ORACLE: wpcheck writes a request file, runs 188 `/usr/bin/python3 wporacle.py REQUEST`, and compares each answer line itself. It 189 answers three requests: SHA-256 of a byte range, SHA-256 of the IEEE f32 casts of 190 the checkpoint weights, and a count of entries whose old and new values differ 191 after the f32 cast. It shares no code with wpatch or wpcheck, and nothing in the 192 product or the build calls it. Any malformed request makes it exit nonzero, which 193 wpcheck reports as FAIL. 194 195 Evidence: `evidence/OMEGALLM/wsp-patch-`20261107`/pure-omega/`. Host CPU execution is 196 not GPU qualification, a model-quality result, a merge, or a deployment.