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/head/weights.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 / head / weights.om` 155 lines ยท 3287 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Safetensors head shard. Offsets are relative to the end of its JSON header. 3 global stLayout ulong 3 4 global stReadError uint 1 5 text headName "head.weight" 6 text normName "norm.weight" 7 text dtypeName "dtype" 8 text shapeName "shape" 9 text offsetsName "data_offsets" 10 text bfName "BF16" 11 12 fn stMember stSource view uchar 65536 stTape view uint 4096 obj ulong name view uchar * to ulong 13 if ne js_type stTape obj jsobj 14 ret jsnone 15 end 16 k = js_first stTape obj 17 v = jsnone 18 while ne k jsnone 19 if js_streq stSource js_off stTape k name 20 if ne v jsnone 21 ret jsnone 22 end 23 v = add k 1 24 end 25 k = js_mnext stTape k 26 end 27 ret v 28 end 29 fn stUInt stSource view uchar 65536 stTape view uint 4096 token ulong to ulong 30 if ne js_type stTape token jsnum 31 ret `18446744073709551615` 32 end 33 off = js_off stTape token 34 if not js_isu stSource off 35 ret `18446744073709551615` 36 end 37 ret js_imag stSource off 38 end 39 fn stTensor stSource view uchar 65536 stTape view uint 4096 obj ulong matrix bool to bool 40 if eq obj jsnone 41 ret false 42 end 43 t = stMember stSource stTape obj dtypeName 44 if ne js_type stTape t jsstr 45 ret false 46 end 47 if not js_streq stSource js_off stTape t bfName 48 ret false 49 end 50 t = stMember stSource stTape obj shapeName 51 if ne js_type stTape t jsarr 52 ret false 53 end 54 i = js_first stTape t 55 size = ulong 10240 56 if matrix 57 if ne stUInt stSource stTape i 129280 58 ret false 59 end 60 i = js_enext stTape i 61 size = mul size 129280 62 end 63 if or ne stUInt stSource stTape i 5120 ne js_enext stTape i jsnone 64 ret false 65 end 66 t = stMember stSource stTape obj offsetsName 67 if or ne js_type stTape t jsarr ne js_nkids stTape t 2 68 ret false 69 end 70 i = js_first stTape t 71 begin = stUInt stSource stTape i 72 stop = stUInt stSource stTape js_enext stTape i 73 if or or gt begin stop gt stop `1323837440` ne sub stop begin size 74 ret false 75 end 76 slot = ulong 1 77 if matrix 78 slot = ulong 0 79 end 80 put stLayout slot begin 81 ret true 82 end 83 fn fileAt fd int buf edit uchar * n ulong pos ulong to bool 84 i = ulong 0 85 while lt i n 86 r = pread fd buf i sub n i long add pos i 87 if lt r 0 88 put stReadError 0 1 89 end 90 if le r 0 91 ret false 92 end 93 i = add i ulong r 94 end 95 ret true 96 end 97 fn headShard fd int to bool 98 size = fseek fd 0 2 99 if lt size 0 100 put stReadError 0 1 101 end 102 if lt size 8 103 ret false 104 end 105 prefix = new uchar 8 0 106 if not fileAt fd prefix 8 0 107 ret false 108 end 109 n = ulong 0 110 for j ulong 8 111 n = or n shl ulong get prefix j mul j 8 112 end 113 note The published head shard has exactly two tensors, with fixed payload sizes. 114 payload = ulong `1323837440` 115 if le ulong size add payload 8 116 ret false 117 end 118 if ne n sub sub ulong size payload 8 119 ret false 120 end 121 note Seeded Omega's JSON API takes array views. The checkpoint's two descriptors use 176 bytes. 122 stSource = new uchar 65536 0 123 stTape = new uint 4096 0 124 if or eq n 0 gt n len stSource 125 ret false 126 end 127 if not fileAt fd stSource n 8 128 ret false 129 end 130 if ne get stSource 0 123 131 ret false 132 end 133 if ne js_init stTape n 64 0 134 ret false 135 end 136 if lt js_parse stSource stTape n 0 137 ret false 138 end 139 if ne js_nkids stTape 0 2 140 ret false 141 end 142 if not stTensor stSource stTape stMember stSource stTape 0 headName true 143 ret false 144 end 145 if not stTensor stSource stTape stMember stSource stTape 0 normName false 146 ret false 147 end 148 put stLayout 2 add n 8 149 ret adjacentHead 150 end 151 fn adjacentHead to bool 152 w = get stLayout 0 153 g = get stLayout 1 154 ret or and eq w 0 eq g `1323827200` and eq w 10240 eq g 0 155 end