interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / om / gpu / dsv41 / decoder / layer-map.om

270 lines · 5761 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Map every resident Zone 1 tensor in tensors.bin into fixed per-layer slots
3note for O(1) GPU binding during the 40-layer forward pass.
4const lmStride ulong 41
5const lmMissing ulong 18446744073709551615
6global lmGlobal ulong 3
7global lmLayer ulong 1640
8
9text lmTNorm "norm.weight"
10text lmTHead "head.weight"
11text lmTAttnNorm "attn_norm.weight"
12text lmTFfnNorm "ffn_norm.weight"
13text lmTHcAttnBase "hc_attn_base"
14text lmTHcAttnFn "hc_attn_fn"
15text lmTHcAttnScale "hc_attn_scale"
16text lmTHcFfnBase "hc_ffn_base"
17text lmTHcFfnFn "hc_ffn_fn"
18text lmTHcFfnScale "hc_ffn_scale"
19text lmTAttnSink "attn.attn_sink"
20text lmTQNorm "attn.q_norm.weight"
21text lmTKvNorm "attn.kv_norm.weight"
22text lmTWqAW "attn.wq_a.weight"
23text lmTWqAS "attn.wq_a.scale"
24text lmTWqBW "attn.wq_b.weight"
25text lmTWqBS "attn.wq_b.scale"
26text lmTWkvW "attn.wkv.weight"
27text lmTWkvS "attn.wkv.scale"
28text lmTWoAW "attn.wo_a.weight"
29text lmTWoAS "attn.wo_a.scale"
30text lmTWoBW "attn.wo_b.weight"
31text lmTWoBS "attn.wo_b.scale"
32text lmTGateW "ffn.gate.weight"
33text lmTGateB "ffn.gate.bias"
34text lmTShW1W "ffn.shared_experts.w1.weight"
35text lmTShW1S "ffn.shared_experts.w1.scale"
36text lmTShW2W "ffn.shared_experts.w2.weight"
37text lmTShW2S "ffn.shared_experts.w2.scale"
38text lmTShW3W "ffn.shared_experts.w3.weight"
39text lmTShW3S "ffn.shared_experts.w3.scale"
40text lmTCmpNorm "attn.compressor.norm.weight"
41text lmTCmpWkv "attn.compressor.wkv.weight"
42text lmTCmpWgate "attn.compressor.wgate.weight"
43text lmTIdxWqbW "attn.indexer.wq_b.weight"
44text lmTIdxWqbS "attn.indexer.wq_b.scale"
45text lmTIdxWproj "attn.indexer.weights_proj.weight"
46text lmTIdxWk "attn.indexer.wk.weight"
47text lmTIdxKnorm "attn.indexer.k_norm.weight"
48text lmTEngWkvW "engram.wkv.weight"
49text lmTEngWkvS "engram.wkv.scale"
50text lmTEngQW "engram.q_weight"
51text lmTEngKW "engram.k_weight"
52
53fn lmExact row view uchar 160 pos ulong needle view uchar * to bool
54 if not dcMatch row pos needle
55 ret false
56 end
57 endp = add pos len needle
58 if ge endp 160
59 ret true
60 end
61 ret eq get row endp 0
62end
63
64fn lmSlotCore row view uchar 160 pos ulong to long
65 if lmExact row pos lmTAttnNorm
66 ret 0
67 end
68 if lmExact row pos lmTFfnNorm
69 ret 1
70 end
71 if lmExact row pos lmTHcAttnBase
72 ret 2
73 end
74 if lmExact row pos lmTHcAttnFn
75 ret 3
76 end
77 if lmExact row pos lmTHcAttnScale
78 ret 4
79 end
80 if lmExact row pos lmTHcFfnBase
81 ret 5
82 end
83 if lmExact row pos lmTHcFfnFn
84 ret 6
85 end
86 if lmExact row pos lmTHcFfnScale
87 ret 7
88 end
89 if lmExact row pos lmTAttnSink
90 ret 8
91 end
92 if lmExact row pos lmTQNorm
93 ret 9
94 end
95 if lmExact row pos lmTKvNorm
96 ret 10
97 end
98 if lmExact row pos lmTWqAW
99 ret 11
100 end
101 if lmExact row pos lmTWqAS
102 ret 12
103 end
104 if lmExact row pos lmTWqBW
105 ret 13
106 end
107 if lmExact row pos lmTWqBS
108 ret 14
109 end
110 if lmExact row pos lmTWkvW
111 ret 15
112 end
113 if lmExact row pos lmTWkvS
114 ret 16
115 end
116 if lmExact row pos lmTWoAW
117 ret 17
118 end
119 if lmExact row pos lmTWoAS
120 ret 18
121 end
122 if lmExact row pos lmTWoBW
123 ret 19
124 end
125 if lmExact row pos lmTWoBS
126 ret 20
127 end
128 ret -1
129end
130
131fn lmSlotFfn row view uchar 160 pos ulong to long
132 if lmExact row pos lmTGateW
133 ret 21
134 end
135 if lmExact row pos lmTGateB
136 ret 22
137 end
138 if lmExact row pos lmTShW1W
139 ret 23
140 end
141 if lmExact row pos lmTShW1S
142 ret 24
143 end
144 if lmExact row pos lmTShW2W
145 ret 25
146 end
147 if lmExact row pos lmTShW2S
148 ret 26
149 end
150 if lmExact row pos lmTShW3W
151 ret 27
152 end
153 if lmExact row pos lmTShW3S
154 ret 28
155 end
156 if lmExact row pos lmTCmpNorm
157 ret 29
158 end
159 if lmExact row pos lmTCmpWkv
160 ret 30
161 end
162 if lmExact row pos lmTCmpWgate
163 ret 31
164 end
165 if lmExact row pos lmTIdxWqbW
166 ret 32
167 end
168 if lmExact row pos lmTIdxWqbS
169 ret 33
170 end
171 if lmExact row pos lmTIdxWproj
172 ret 34
173 end
174 if lmExact row pos lmTIdxWk
175 ret 35
176 end
177 if lmExact row pos lmTIdxKnorm
178 ret 36
179 end
180 if lmExact row pos lmTEngWkvW
181 ret 37
182 end
183 if lmExact row pos lmTEngWkvS
184 ret 38
185 end
186 if lmExact row pos lmTEngQW
187 ret 39
188 end
189 if lmExact row pos lmTEngKW
190 ret 40
191 end
192 ret -1
193end
194
195fn lmParseLayer row view uchar 160 to long
196 if or ne get row 56 108 ne get row 62 46
197 ret -1
198 end
199 val = ulong 0
200 pos = ulong 63
201 digits = ulong 0
202 while and ge get row pos 48 le get row pos 57
203 val = add mul val 10 sub ulong get row pos 48
204 pos = add pos 1
205 digits = add digits 1
206 end
207 if or eq digits 0 or ge val 40 ne get row pos 46
208 ret -1
209 end
210 ret long val
211end
212
213fn lmSuffixPos row view uchar 160 to ulong
214 pos = ulong 63
215 while and ge get row pos 48 le get row pos 57
216 pos = add pos 1
217 end
218 ret add pos 1
219end
220
221fn lmIndex fd int to bool
222 row = new uchar 160 0
223 for i ulong 3
224 put lmGlobal i lmMissing
225 end
226 for i ulong 1640
227 put lmLayer i lmMissing
228 end
229 for i ulong 96085
230 if ne get dcLength i 0
231 if not diRead fd row mul i 160 160
232 ret false
233 end
234 off = get dcOffset i
235 if lmExact row 56 dcEmbedding
236 put lmGlobal 0 off
237 end
238 if lmExact row 56 lmTNorm
239 put lmGlobal 1 off
240 end
241 if lmExact row 56 lmTHead
242 put lmGlobal 2 off
243 end
244 layer = lmParseLayer row
245 if ge layer 0
246 spos = lmSuffixPos row
247 slot = lmSlotCore row spos
248 if lt slot 0
249 slot = lmSlotFfn row spos
250 end
251 if ge slot 0
252 put lmLayer add mul ulong layer lmStride ulong slot off
253 end
254 end
255 end
256 end
257 for i ulong 3
258 if eq get lmGlobal i lmMissing
259 ret false
260 end
261 end
262 for l ulong 40
263 for s ulong 29
264 if eq get lmLayer add mul l lmStride s lmMissing
265 ret false
266 end
267 end
268 end
269 ret true
270end