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
aien-train / docs / omegallm / WSP-PATCH.md
| 1 | # Checked weight-space patches |
| 2 | |
| 3 | `tools/omegallm/wpatch` implements inspect, diff, show, validate, apply, verify, |
| 4 | revert, bind and checkbind in seeded Omega. This format describes an exact edit, |
| 5 | not a training algorithm or a claim that the edit improves the model. |
| 6 | |
| 7 | Base implementation revision: aien-train `0518c915dea370b3bffbb90d579b1daa5ba8b8f5`. |
| 8 | Compiler and SHA implementation: omega-mv |
| 9 | `e5b32567a7aff3ce594e3254a622a846a6cd190b`. |
| 10 | The tool README gives build instructions, commands, source hashes and cache rules. |
| 11 | |
| 12 | ## Checkpoint convention |
| 13 | |
| 14 | OLLMCK02 has fifteen little-endian u64 header words: magic, V, T, D, H, F, L, B, |
| 15 | seed, step, total, learning-rate word, P, G and payload FNV-1a-64. The payload is |
| 16 | P f64 weight words followed by P m words and P v words. This tool preserves all |
| 17 | header words except the refreshed payload FNV. Diff requires BASE and EDITED to |
| 18 | have the same first fourteen header words and identical m/v bytes. It rejects a |
| 19 | no-op diff. It does not change training step or learning rate. |
| 20 | |
| 21 | The tied embedding/head `wte[V,D]` comes first, then `wpe[T,D]`. Each layer has |
| 22 | `g1[1,D]`, `wq[D,D]`, `wk[D,D]`, `wv[D,D]`, `wo[D,D]`, `g2[1,D]`, `w1[D,F]`, |
| 23 | `w2[F,D]`. The final tensor is `gf[1,D]`. All are row-major. Flat offsets are |
| 24 | weight-element indices; checkpoint byte offsets are 120 + 8 times that index. |
| 25 | The existing `ogeom` validator is reused, rather than duplicating its limits. |
| 26 | |
| 27 | ## OLLMWP01 manifest |
| 28 | |
| 29 | All integers and f64 bit patterns are little-endian u64. Hashes are raw 32-byte |
| 30 | SHA-256 digests in their normal byte order, never integer words. There is no |
| 31 | padding between the tables or text. A manifest is named `<sha256>.wp` using its |
| 32 | whole-file SHA-256 in lowercase hexadecimal. Every patch-consuming command |
| 33 | recomputes that digest. A filename of 64 hex digits plus `.wp` must match it; |
| 34 | uppercase hex names are recognized but refused as noncanonical. Other filenames |
| 35 | are permitted for transport and corruption diagnostics, without a filename |
| 36 | identity assertion. The digest remains visible through show and bind. |
| 37 | |
| 38 | Fixed header, 376 bytes: |
| 39 | |
| 40 | | Byte offset | Field | |
| 41 | | --- | --- | |
| 42 | | 0 | ASCII `OLLMWP01` | |
| 43 | | 8 | Total file bytes | |
| 44 | | 16 | Optimizer policy: 0 keep, 1 zero changed m, 2 zero changed m/v | |
| 45 | | 24 | Tensor count, exactly 3 + 8L | |
| 46 | | 32 | Number of changed weight words, nonzero | |
| 47 | | 40 | P | |
| 48 | | 48,56,64,72,80,88 | V,T,D,H,F,L | |
| 49 | | 96 | SHA-256 of complete BASE checkpoint | |
| 50 | | 128 | SHA-256 of expected applied checkpoint, including selected m/v policy | |
| 51 | | 160 | SHA-256 of all expected weights cast to contiguous little-endian f32 | |
| 52 | | 192 | SHA-256 of the exact entry-table bytes | |
| 53 | | 224,232 | Params and rationale byte lengths | |
| 54 | | 240 | Saved checkpoint header length, exactly 120 | |
| 55 | | 248 | Reserved, zero | |
| 56 | | 256 | Exact original 120-byte checkpoint header | |
| 57 | |
| 58 | Immediately after the header are tensor records, each 128 bytes, in the canonical |
| 59 | checkpoint order. Kind codes: wte=0, wpe=1, g1=2, wq=3, wk=4, wv=5, wo=6, g2=7, |
| 60 | w1=8, w2=9, gf=10. Every tensor is recorded, including unchanged tensors. |
| 61 | |
| 62 | | Record byte offset | Field | |
| 63 | | --- | --- | |
| 64 | | 0,8 | Kind code, layer (zero for nonlayer tensors) | |
| 65 | | 16,24 | Rows, columns | |
| 66 | | 32 | Dtype code, exactly 64 for f64 | |
| 67 | | 40 | Flat weight offset | |
| 68 | | 48 | Changed-entry count in this tensor | |
| 69 | | 56 | Reserved, zero | |
| 70 | | 64,96 | Base and expected output raw tensor-byte SHA-256 | |
| 71 | |
| 72 | The entry table follows. Policy 0 entries are 24 bytes: flat index, old f64 bits, |
| 73 | new f64 bits. Policies 1 and 2 entries are 40 bytes: those three words, old m bits, |
| 74 | old v bits. Both saved moment words are present even when only m is reset. |
| 75 | Indices must be strictly ascending and unique. Every index belongs to its |
| 76 | canonical tensor interval, and each tensor's count must agree with the scan. |
| 77 | Old and new words must differ. New values must be finite with absolute magnitude |
| 78 | at most 1e6. Old words may encode any f64, so a broken weight can be repaired and |
| 79 | reverted exactly. New signed-zero changes are valid and retain their exact bits. |
| 80 | |
| 81 | Params bytes follow the entry table, then rationale bytes. Both are strict UTF-8; |
| 82 | overlong encodings, surrogates, invalid continuations and incomplete sequences |
| 83 | are refused. NUL is permitted in metadata and escaped by show. Each field is at |
| 84 | most 16 MiB. The length sum must equal the exact file length. The tool's mapped |
| 85 | input ceiling is 2,400,000,000 bytes and entry ceiling is 29,995,392, further |
| 86 | limited by the actual checkpoint geometry. Length checks precede table reads. |
| 87 | |
| 88 | ## Validation and output behavior |
| 89 | |
| 90 | Validate checks checkpoint format, exact size and FNV, manifest geometry, every |
| 91 | tensor shape/dtype/offset, ordered entry membership and count, entries hash, |
| 92 | exact saved base header, full base SHA, tensor hashes, old weight bits and saved |
| 93 | optimizer bits. It applies the entries in a private copy and checks the resulting |
| 94 | full SHA, per-tensor SHA and f32 SHA before reporting PASS. Apply repeats this |
| 95 | path, creates OUT with exclusive creation, writes it, then reopens and hashes it. |
| 96 | A postwrite hash mismatch unlinks the newly created output. No output is silently |
| 97 | reused or overwritten. Revert verifies the edited checkpoint, restores saved |
| 98 | words, refreshes FNV and requires the exact base SHA before and after writing. |
| 99 | |
| 100 | F32 identity is SHA-256 over P contiguous little-endian IEEE-754 binary32 values |
| 101 | cast from checkpoint f64 weights with the pinned CPU's round-to-nearest conversion. |
| 102 | It excludes header, m and v. Verify compares f64 checkpoint and f32 identities and |
| 103 | reports how many entries have different old/new f32 bits. Those counts distinguish |
| 104 | an encoded edit from one that survives the deployed weight representation. This |
| 105 | is not evidence that a serving process actually reloaded those weights. |
| 106 | |
| 107 | Inputs use private file mappings and must remain stable for the command's entire |
| 108 | lifetime. There is no lock against an external writer. Forced termination can |
| 109 | leave a partial new output, and writes are not an atomic deployment transaction. |
| 110 | Run verify before consuming a checkpoint. Content addressing detects accidental |
| 111 | corruption and binds exact content; it does not authenticate an author. |
| 112 | |
| 113 | ## OLLMWB01 binding |
| 114 | |
| 115 | The 168-byte binding record contains ASCII `OLLMWB01` at offset 0; complete |
| 116 | checkpoint SHA at 8; f32 weight SHA at 40; runtime executable SHA at 72; manifest |
| 117 | SHA at 104; SHA of the preceding 136 bytes at 136. Bind verifies PATCH against CK |
| 118 | before creating the record. Checkbind validates record magic/length/checksum and |
| 119 | CK/runtime identities. It takes no manifest argument and never rereads a manifest, |
| 120 | so it cannot detect a replaced manifest. The stored manifest digest identifies |
| 121 | what bind checked earlier, not what a manifest path contains now. Checkbind also |
| 122 | does not prove that the recorded patch is trusted. Preserve the canonical |
| 123 | manifest alongside the binding and check its intended identity separately. |
| 124 | |
| 125 | A consumer must fail closed on checkbind failure, discard previously loaded |
| 126 | weight and KV caches, and load the bound checkpoint with the bound executable. |
| 127 | Changing a manifest, checkpoint or runtime requires a fresh checked binding. |
| 128 | No server, loader or live model is changed by this tool. |
| 129 | |
| 130 | ## Refusal exit codes |
| 131 | |
| 132 | Exit 0 means command success. There is no automatic fallback. |
| 133 | |
| 134 | | Exit | Refusal | |
| 135 | | --- | --- | |
| 136 | | 2 | Invalid command, arity or numeric argument | |
| 137 | | 20 | Empty input or checkpoint shorter than header | |
| 138 | | 21 | Input exceeds mapped size ceiling | |
| 139 | | 22 | Checkpoint magic | |
| 140 | | 23 | Unsupported/invalid checkpoint geometry, G or total | |
| 141 | | 24 | Checkpoint P disagrees with geometry | |
| 142 | | 25 | Checkpoint exact payload length | |
| 143 | | 26 | Checkpoint payload FNV | |
| 144 | | 27 | Unknown tensor/layer or invalid slice bounds | |
| 145 | | 30 | Content-addressed manifest filename does not match bytes | |
| 146 | | 31 | Metadata is not strict UTF-8 | |
| 147 | | 32 | Manifest truncated, length mismatch or table bounds | |
| 148 | | 33 | Manifest magic, fixed header length or reserved header word | |
| 149 | | 34 | Unsupported optimizer policy | |
| 150 | | 35 | Zero or excessive manifest edit count | |
| 151 | | 36 | Manifest/base geometry or checkpoint-header mismatch | |
| 152 | | 37 | Tensor order, shape, dtype, offset or reserved word | |
| 153 | | 38 | Flat entry index is out of bounds | |
| 154 | | 39 | Entry indices descend | |
| 155 | | 40 | New weight is NaN | |
| 156 | | 41 | New weight is infinite | |
| 157 | | 42 | New weight magnitude exceeds 1e6 | |
| 158 | | 43 | Duplicate entry index | |
| 159 | | 44 | Entry old bits equal new bits | |
| 160 | | 45 | Tensor changed count disagrees with entries | |
| 161 | | 46 | Entry-table SHA mismatch | |
| 162 | | 47 | Expected old/new weight bits mismatch | |
| 163 | | 48 | Saved or policy-applied optimizer bits mismatch | |
| 164 | | 49 | Tensor SHA mismatch | |
| 165 | | 50 | Input base/applied full checkpoint SHA mismatch | |
| 166 | | 52 | OUT already exists, including symlinks | |
| 167 | | 53 | Generated or written output checkpoint SHA mismatch | |
| 168 | | 54 | F32 weight SHA mismatch | |
| 169 | | 55 | Diff has no changed weight words | |
| 170 | | 56 | Diff EDITED changed m or v | |
| 171 | | 57 | Metadata field exceeds limit | |
| 172 | | 58 | Binding magic or length | |
| 173 | | 59 | Binding checksum | |
| 174 | | 60 | Bound checkpoint SHA mismatch | |
| 175 | | 61 | Bound f32 SHA mismatch | |
| 176 | | 62 | Bound runtime executable SHA mismatch | |
| 177 | | 70 | Open, map, read, write, permission or close I/O failure | |
| 178 | | 71 | Failed to unlink a newly created rejected output | |
| 179 | |
| 180 | When an input violates multiple rules, the first check determines the code. For |
| 181 | example, a truncated canonical-name patch can fail filename identity before a |
| 182 | later field check. Noncanonical corruption fixtures in wpcheck isolate the |
| 183 | individual refusal paths. Omega runtime traps remain nonzero compiler/runtime |
| 184 | errors, not successful refusals; no trap is counted as an expected test result. |
| 185 | |
| 186 | ## Evidence and dependency boundary |
| 187 | |
| 188 | `evidence/OMEGALLM/wsp-patch-20261107/` records host CPU execution, the source |
| 189 | composition diff, exact identities, small acceptance and round40 rollback; its |
| 190 | `pure-omega/` directory holds the receipts for the Omega build and test drivers. |
| 191 | All product transformations and hashing are Omega, and so are the build driver |
| 192 | `wpbuild.om` and the test driver `wpcheck.om` (see the wpatch README for how to |
| 193 | run them). The build driver composes the aarch64 ollm source itself and checks |
| 194 | the three vendored net sources with the vendored Omega SHA-256, so it no longer |
| 195 | runs `tests/omegallm/build.sh` or a shell. It runs these pinned host build tools: |
| 196 | the compiler, git 2.43.0, GNU sha256sum 9.4 (only for the compiler and SHA source |
| 197 | pins), GNU diffutils 3.10, taskset util-linux 2.39.3 and GNU nice 9.4. None of |
| 198 | them edits checkpoints or composes source; source composition and SHA vendoring |
| 199 | are done in Omega. Python 3.12.3 with hashlib/struct/mmap appears only as the |
| 200 | ORACLE `wporacle.py`, a digest calculator called by wpcheck; it never decides a |
| 201 | result. No new host library enters the product runtime. |
| 202 | |
| 203 | WolframLanguageEvaluator checks used during implementation: |
| 204 | |
| 205 | ```text |
| 206 | FromDigits[Reverse[ToCharacterCode["OLLMWP01"]],256] -> 3544421242629803087 |
| 207 | FromDigits[Reverse[ToCharacterCode["OLLMWB01"]],256] -> 3544405849467014223 |
| 208 | With[{v=256,t=8,d=16,f=32,l=2},v*d+t*d+l*(4*d*d+2*d*f+2*d)+d] -> 8400 |
| 209 | With[{v=4096,t=256,d=384,f=1536,l=8}, |
| 210 | {v*d+t*d+l*(4*d*d+2*d*f+2*d)+d, |
| 211 | v*d+t*d+3*(4*d*d+2*d*f+2*d)+2*d+4*d*d+d*f}] |
| 212 | -> {15833472,8162304} |
| 213 | FullSimplify[(m^2*s+a^2)/a^2,Assumptions->{a>m>0,s>=0}] |
| 214 | -> 1 + (m^2*s)/a^2 |
| 215 | FullSimplify[Sqrt[m^2*s/n],Assumptions->{m>=0,s>=0,n>0}] |
| 216 | -> m*Sqrt[s/n] |
| 217 | ``` |
| 218 | |
| 219 | The last two identities justify the scaled RMS accumulator, which avoids |
| 220 | squaring the largest finite f64. Evidence labels remain separate: this tool is |
| 221 | IMPLEMENTED and host-CPU EXERCISED. GPU qualification, model-quality improvement, |
| 222 | merge and deployment are not established by these receipts. |