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/omega-mv/blob/main/calibration/docs/MODEL_DESCRIPTION_ENCODING.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / calibration / docs / MODEL_DESCRIPTION_ENCODING.md` 137 lines ยท 7770 bytes Raw Blame History Rendered 1 # TYM0 model description encoding (Turing-profile-v1.0) 2 3 This document is sufficient to write a TYM0 decoder and scorer without reading omega source. The reference 4 implementation is `src/turing/ty_model.c` (`ty_model_encode`, `ty_model_decode`, `ty_model_score`); where this 5 document and the code disagree, the code is wrong: before the freeze the code is fixed; after sealed scoring 6 has started it is a terminal FAIL of the criterion that used the value (S8 when the independent scorer, written 7 from this document, disagrees; FAILURE_REPORTING.md section 2), never a void. The trace and bundle formats the 8 scorer also needs are in DATA_FORMAT.md. 9 10 L(M), the model cost under Turing-profile-v1.0, is the exact bit length of the TYM0 code defined here. 11 12 ## 1. Bit order 13 14 The code is a bitstream written most significant bit first. A field of width w holding value v contributes its w 15 bits from bit w-1 down to bit 0. Bit i of the stream is bit (7 - i mod 8) of byte floor(i / 8). After the last 16 field the stream is padded with 0 bits to a whole byte. The file (`.tym`) is exactly these bytes, nothing before or 17 after. 18 19 ## 2. Layout 20 21 | field | width (bits) | value / rule | 22 |---|---|---| 23 | magic | 32 | 0x54594D30 (ASCII `TYM0`) | 24 | version | 8 | 0 (only admissible value) | 25 | K | 8 | alphabet size; 9 under this profile (decoder accepts 2..16, the scorer requires 9) | 26 | mask | 8 | feature mask, bits defined in section 3; bits outside 0..7 refused | 27 | qbits | 8 | 16 (only admissible value) | 28 | keybits | 8 | must equal ceil(log2(S)) where S = key space of the mask (section 3); 0 when S = 1 | 29 | nrows | 32 | number of stored context rows | 30 | default row | 16 x (K-1) | entries q[0..K-2], each 1..65535 | 31 | row i, i = 0..nrows-1 | keybits + 16 x (K-1) | key (keybits bits), then entries q[0..K-2] | 32 | padding | 0..7 | zero bits | 33 34 The header (magic through nrows) is exactly **104 bits**. For every row (and the default row) the K-th entry is 35 not stored: q[K-1] = 65536 - (q[0] + ... + q[K-2]). 36 37 **L(M) = 104 + 16(K-1) + nrows x (keybits + 16(K-1)) bits.** With K = 9: L(M) = 232 + nrows x (keybits + 128). 38 Padding is not part of L(M). 39 40 ## 3. Context key 41 42 Features are combined into one mixed-radix key, **in this fixed order, lowest digit first** (the order of the 43 code, not of the mask bit values): 44 45 | order | feature | mask bit | radix | digit value for event t | 46 |---|---|---|---|---| 47 | 1 | op | 1 | 16 | op feature: op_index 0..14 for EXPAND, 15 for SUBMIT | 48 | 2 | depth | 2 | 8 | min(depth, 7) | 49 | 3 | prev1 | 4 | K+1 | outcome of the previous event in the same crumb, or K at crumb start | 50 | 4 | prev2 | 8 | K+1 | outcome two events back in the crumb, or K | 51 | 5 | prev3 | 16 | K+1 | three back, or K | 52 | 6 | prev4 | 64 | K+1 | four back, or K | 53 | 7 | prev5 | 128 | K+1 | five back, or K | 54 | 8 | pos | 32 | 2^36 | (crumb ordinal << 20) OR min(event_index, 2^20 - 1) | 55 56 key = d1 + r1 x (d2 + r2 x (d3 + ...)) over the features present in the mask, in the order above. S = product of 57 the radices of present features; S > 2^62 is refused. keybits = 0 if S <= 1, else the bit length of S - 1. 58 59 - "Previous outcome" digits are kept per file and all reset to K when an event opens a crumb (the CTR1 crumb-start record), 60 before the key of that event is computed. After the event is scored the history shifts: prev5 <- prev4 <- ... <- 61 prev1 <- x_t. 62 - Crumb ordinal = index of the crumb that contains the event, counting crumbs in file order from 0 (the file's first record opens crumb 0), saturating at 65535 (DATA_FORMAT.md G10; not reached at this design). 63 - The outcome symbol x_t, op feature and depth come from each 247-byte CTR1 record exactly as in 64 TURING_YIELD_PROFILE_V0.md sections 2-3 (reader `src/turing/ty_ctr1.c`, byte offsets in `ty_ctr1.h`). 65 66 ## 4. Prediction 67 68 For event t with key k: if a stored row has key k, P(x) = row.q[x] / 65536; otherwise P(x) = default.q[x] / 65536. 69 Ideal code length of the event = -log2(q[x_t] / 65536) bits, computed in micro-bits exactly as `ty_ubits_q16` 70 (profile `ideal_codelength_method`). 71 72 ## 5. Decoder refusals (all fail closed) 73 74 A conforming decoder refuses, and the scorer never scores, a code with any of: 75 76 1. magic != 0x54594D30, or fewer than 104 header bits; 77 2. version != 0; 78 3. qbits != 16; 79 4. mask with bits outside 0..7, K outside 2..16, S > 2^62, or keybits != ceil(log2(S)); 80 5. file length in bytes != ceil(L(M) / 8) where L(M) is computed from the header; 81 6. any stored entry equal to 0, or stored entries of a row summing to >= 65536 (implied last entry < 1); 82 7. a row key >= S, or keys not strictly increasing; 83 8. any nonzero padding bit. 84 85 Turing-profile-v1.0 admits only K = 9: a code declaring another K is not a valid candidate under this profile, even though the generic decoder accepts it. 86 87 ## 6. Why the fixed 104-bit header closes the metadata-hiding channel 88 89 A memorizer would like to store data somewhere it is not charged for. In TYM0 there is no such place: 90 91 - Every header field has a fixed width and is part of L(M). magic, version and qbits have exactly one admissible 92 value; keybits is determined by the mask; K is fixed at 9 by the profile. The only free choices are the mask (8 93 bits, one of 256 values) and nrows (32 bits), and both are paid for in L(M). 94 - nrows fixes the total length exactly: the decoder computes L(M) from the header and refuses a file whose byte 95 count differs from ceil(L(M) / 8). Trailing bytes, a length field that lies, or an extra section cannot exist. 96 - Padding is at most 7 bits and must be zero, so it carries no information. 97 - Keys must be strictly increasing and inside the key space, so row order carries no information and a row cannot 98 appear twice. 99 - There is no comment, name, version string, timestamp or extension field. The model's identity is its digest 100 SHA-256('turing.ymodel.v0' || 0x00 || bytes), computed, not stored. 101 - The scorer runs only on the decoded table. Anything that did not survive decoding cannot influence a 102 probability, and everything that survives decoding was counted in L(M). 103 - Coded data files follow the same rule in the other direction: every byte of every coded file counts 104 (profile `coder_header_accounting`), so a coder cannot move data into an uncounted header either. 105 106 Consequence: the information content a model can carry is bounded by L(M), bit for bit. The position memorizers of 107 EXP-001 (mask 32) pay 164 bits per stored event, more than the 3.17 bits a uniform code spends on that event. 108 109 ## 7. Test vectors 110 111 B0 (uniform, K = 9, mask 0, nrows 0), 29 bytes, L(M) = 232 bits: 112 113 ``` 114 54 59 4d 30 00 09 00 10 00 00 00 00 00 1c 72 1c 72 1c 72 1c 72 1c 72 1c 72 1c 72 1c 71 115 ``` 116 117 magic `TYM0`, version 0, K 9, mask 0, qbits 16, keybits 0, nrows 0, default row 7282 x 7, 7281 (symbol 7); 118 symbol 8 implied = 65536 - 7 x 7282 - 7281 = 7281. Model digest 119 ``83c04bdfc10614febd634092355ef03997ed255fde5bdec9a80fe2d8964998ce``. 120 121 B3 (fixed heuristic, mask 1, keybits 4, nrows 16), 293 bytes, L(M) = 2344 bits, first 32 bytes: 122 123 ``` 124 54 59 4d 30 00 09 01 10 04 00 00 00 10 1c 72 1c 72 1c 72 1c 72 1c 72 1c 72 1c 72 1c 71 02 49 22 125 ``` 126 127 After the default row: key 0 in 4 bits (0000), then 9362 = 0x2492 seven times, then 1; the bytes `02 49 22 49 ...` 128 are that bit sequence shifted by 4. Model digest ``e729818b8289263e6819b21fc55f944f9d5113e7cfc4419d0badcc27f589f2ae``. 129 130 Every EXP-001 candidate's file SHA-256, model digest, rows, keybits and L(M) are in 131 `calibration/experiments/EXP-001/candidate_manifest.json`. 132 133 ## 8. Fit-time procedures are not part of the code 134 135 How rows were produced (KT add-1/2 smoothing, largest-remainder quantization `ty_quantize_kt`, MDL pruning, hand 136 setting, sharpening) is free and not scored. Only the table in the code is scored and paid for. A reimplementation 137 needs sections 1-5 only.