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/om/gpu/dsv41/decoder/payload-index.om # 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 / om / gpu / dsv41 / decoder / payload-index.om` 314 lines ยท 6497 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Per checkpoint shard, build one fixed record per routed expert or 3 note Engram row. Only run against the digest-verified tensor directory 4 note and its immutable verified source shards. Weights precede scales. 5 global dxExpert ulong 2304 6 global dxEngram ulong 3 7 text dxRouted ".ffn.experts." 8 text dxEmbedding ".engram.embed." 9 text dxWeight "weight" 10 text dxScale "scale" 11 text dxTensorPin "`aeffef21b0840b05d82f525da3f72546b8ffbb5ee876b926518b486f0198cb9f`" 12 13 fn dxAt row view uchar 160 p ulong name view uchar * to bool 14 if gt add p len name 160 15 ret false 16 end 17 for i ulong len name 18 if ne get row add p i get name i 19 ret false 20 end 21 end 22 ret true 23 end 24 25 fn dxSuffix row view uchar 160 p ulong to ulong 26 if dxAt row p dxWeight 27 if eq get row add p 6 0 28 ret 0 29 end 30 end 31 if dxAt row p dxScale 32 if eq get row add p 5 0 33 ret 1 34 end 35 end 36 ret 2 37 end 38 39 fn dxExpertSize plane ulong to ulong 40 if lt plane 3 41 ret `5898240` 42 end 43 ret 368640 44 end 45 46 fn dxExpertKey row view uchar 160 pos ulong to ulong 47 id = ulong 0 48 while ge get row pos 48 49 c = get row pos 50 if gt c 57 51 break 52 end 53 id = add mul id 10 ulong sub c 48 54 pos = add pos 1 55 end 56 if or ge id 384 ne get row pos 46 57 ret 2304 58 end 59 if or ne get row add pos 1 119 ne get row add pos 3 46 60 ret 2304 61 end 62 projection = ulong get row add pos 2 63 if or lt projection 49 gt projection 51 64 ret 2304 65 end 66 kind = dxSuffix row add pos 4 67 if ge kind 2 68 ret 2304 69 end 70 ret add mul id 6 add mul kind 3 sub projection 49 71 end 72 73 fn dxCollect row view uchar 160 shard ulong to bool 74 if ne ulong get row 0 shard 75 ret true 76 end 77 pos = ulong 63 78 while and ge get row pos 48 le get row pos 57 79 pos = add pos 1 80 end 81 if dxAt row pos dxRouted 82 key = dxExpertKey row add pos len dxRouted 83 if ge key 2304 84 ret false 85 end 86 if ne diGet row 16 8 dxExpertSize rem key 6 87 ret false 88 end 89 if ne get dxExpert key 0 90 ret false 91 end 92 put dxExpert key diGet row 8 8 93 end 94 if dxAt row pos dxEmbedding 95 kind = dxSuffix row add pos len dxEmbedding 96 if ge kind 2 97 ret false 98 end 99 put dxEngram kind diGet row 8 8 100 put dxEngram 2 diGet row 24 4 101 end 102 ret true 103 end 104 105 fn dxDirectory fd int shard ulong to bool 106 size = fseek fd 0 2 107 if ne size `15373600` 108 ret false 109 end 110 row = new uchar 160 0 111 ctx = new uchar 104 0 112 digest = new uchar 32 0 113 sha256_init ctx 114 for i ulong 96085 115 if not diRead fd row mul i 160 160 116 ret false 117 end 118 sha256_update ctx row 119 if not dxCollect row shard 120 ret false 121 end 122 end 123 sha256_final ctx digest 124 for i ulong 32 125 v = uint get digest i 126 if ne sh_hexd shr v 4 get dxTensorPin mul i 2 127 ret false 128 end 129 if ne sh_hexd and v 15 get dxTensorPin add mul i 2 1 130 ret false 131 end 132 end 133 ret true 134 end 135 136 fn dxHashExtent fd int ctx edit shactx start ulong size ulong to bool 137 buf = new uchar 262144 0 138 off = ulong 0 139 while lt off size 140 chunk = sub size off 141 if gt chunk len buf 142 chunk = len buf 143 end 144 if not diRead fd buf add start off chunk 145 ret false 146 end 147 sha256_update ctx part buf 0 chunk 148 off = add off chunk 149 end 150 ret true 151 end 152 153 fn dxWrite data view uchar * to bool 154 off = ulong 0 155 while lt off len data 156 n = write 1 data off sub len data off 157 if eq n -4 158 continue 159 end 160 if le n 0 161 ret false 162 end 163 off = add off ulong n 164 end 165 ret true 166 end 167 168 fn dxExpertRecord fd int shard ulong expert ulong to bool 169 record = new uchar 64 0 170 ctx = new uchar 104 0 171 digest = new uchar 32 0 172 put record 0 uchar shard 173 put record 1 uchar sub shard 3 174 diPut record 4 4 expert 175 sha256_init ctx 176 for plane ulong 6 177 off = get dxExpert add mul expert 6 plane 178 if eq off 0 179 ret false 180 end 181 diPut record add 16 mul plane 8 8 off 182 if not dxHashExtent fd ctx off dxExpertSize plane 183 ret false 184 end 185 end 186 sha256_final ctx digest 187 for i ulong 8 188 put record add 8 i get digest i 189 end 190 ret dxWrite record 191 end 192 193 fn dxHashRow weights view uchar 262144 scales view uchar 8192 outbuf edit uchar 8192 i ulong to void 194 row = new uchar 264 0 195 digest = new uchar 32 0 196 for j ulong 256 197 put row j get weights add mul i 256 j 198 end 199 for j ulong 8 200 put row add 256 j get scales add mul i 8 j 201 end 202 sha256_hash row digest 203 for j ulong 8 204 put outbuf add mul i 8 j get digest j 205 end 206 end 207 208 fn dxEngramBlock fd int base ulong count ulong to bool 209 weights = new uchar 262144 0 210 scales = new uchar 8192 0 211 hashes = new uchar 8192 0 212 if not diRead fd weights add get dxEngram 0 mul base 256 mul count 256 213 ret false 214 end 215 if not diRead fd scales add get dxEngram 1 mul base 8 mul count 8 216 ret false 217 end 218 for i ulong count bound 1024 219 dxHashRow weights scales hashes i 220 end 221 ret dxWrite part hashes 0 mul count 8 222 end 223 224 fn dxEmit fd int shard ulong to bool 225 if and ge shard 3 le shard 42 226 for id ulong 384 227 if not dxExpertRecord fd shard id 228 ret false 229 end 230 end 231 ret true 232 end 233 if or lt shard 47 gt shard 48 234 ret false 235 end 236 if or eq get dxEngram 0 0 eq get dxEngram 1 0 237 ret false 238 end 239 count = get dxEngram 2 240 header = new uchar 32 0 241 put header 0 uchar shard 242 put header 1 1 243 if eq shard 48 244 put header 1 14 245 end 246 diPut header 8 8 count 247 diPut header 16 8 get dxEngram 0 248 diPut header 24 8 get dxEngram 1 249 if not dxWrite header 250 ret false 251 end 252 pos = ulong 0 253 while lt pos count 254 chunk = sub count pos 255 if gt chunk 1024 256 chunk = 1024 257 end 258 if not dxEngramBlock fd pos chunk 259 ret false 260 end 261 pos = add pos chunk 262 end 263 ret true 264 end 265 266 fn dxOpen arg ulong to int 267 path = new uchar 4096 0 268 n = argread arg path 0 4096 269 if le n 0 270 ret int -1 271 end 272 ret int fopen path 0 ulong n 524288 0 273 end 274 275 fn main to int 276 if ne argcnt 4 277 ret 64 278 end 279 digits = new uchar 2 0 280 if ne argread 2 digits 0 2 2 281 ret 64 282 end 283 for i ulong 2 284 if or lt get digits i 48 gt get digits i 57 285 ret 64 286 end 287 end 288 shard = add mul sub ulong get digits 0 48 10 sub ulong get digits 1 48 289 fd = dxOpen 1 290 if lt fd 0 291 ret 66 292 end 293 ok = dxDirectory fd shard 294 if ne fclose fd 0 295 ret 74 296 end 297 if not ok 298 ret 65 299 end 300 fd = dxOpen 3 301 if lt fd 0 302 ret 66 303 end 304 rc = int 65 305 if eq fseek fd 0 2 long dsFileBytes shard 306 if dxEmit fd shard 307 rc = 0 308 end 309 end 310 if ne fclose fd 0 311 ret 74 312 end 313 ret rc 314 end