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 / core / sovereign-core / om / qwen-native / model / profile.om

239 lines · 5521 bytes Raw Blame History
1note Fixed architectures of the two text checkpoints. All active parameters are bound before first use.
2global qcfg ulong 12
3global qrole uint 102400
4global qscale uint 65536
5global qbound uchar 65536
6text qlayerprefix "model.language_model.layers."
7text qexpertprefix "mlp.experts."
8text qsep "."
9text qscalesuffix "_scale_inv"
10text qembed "model.language_model.embed_tokens.weight"
11text qfinal "model.language_model.norm.weight"
12text qlm "lm_head.weight"
13fn qappend buf edit uchar * pos ulong frag view uchar * to ulong
14for i ulong len frag
15put buf add pos i get frag i
16end
17ret add pos len frag
18end
19
20fn qdecimal buf edit uchar * pos ulong x ulong to ulong
21p = pos
22if ge x 100
23put buf p uchar add 48 div x 100
24p = add p 1
25end
26if ge x 10
27put buf p uchar add 48 rem div x 10 10
28p = add p 1
29end
30put buf p uchar add 48 rem x 10
31ret add p 1
32end
33
34fn qresolve frag view uchar * to ulong
35buf = new uchar 256 0
36p = ulong 0
37l = get qcfg 7
38if lt l 64
39p = qappend buf p qlayerprefix
40p = qdecimal buf p l
41p = qappend buf p qsep
42e = get qcfg 8
43if gt e 0
44p = qappend buf p qexpertprefix
45p = qdecimal buf p sub e 1
46p = qappend buf p qsep
47end
48end
49p = qappend buf p frag
50ret qwid buf p
51end
52
53fn qbind slot ulong frag view uchar * dtype ulong to ulong
54id = qresolve frag
55if or ne ulong get qwdtype id dtype ne get qbound id 0
56qwfail 40
57end
58put qbound id 1
59put qrole add get qcfg 9 slot uint id
60ret id
61end
62
63fn qrank2 id ulong rows ulong cols ulong to void
64if ne get qwrank id 2
65qwfail 41
66end
67base = mul id 4
68if or ne get qwshape base rows ne get qwshape add base 1 cols
69qwfail 41
70end
71end
72
73fn qlinkscale id ulong rows ulong cols ulong to void
74buf = new uchar 256 0
75p = ulong get qwnpos id
76n = ulong get qwnlen id
77for j ulong n
78put buf j get qwname add p j
79end
80n = qappend buf n qscalesuffix
81s = qwid buf n
82if or ne get qwdtype s 2 ne get qbound s 0
83qwfail 42
84end
85put qbound s 1
86qrank2 s div add rows 127 128 div add cols 127 128
87put qscale id uint s
88end
89
90fn qmatrix slot ulong frag view uchar * rows ulong cols ulong dtype ulong to void
91id = qbind slot frag dtype
92qrank2 id rows cols
93if eq dtype 1
94qlinkscale id rows cols
95end
96end
97
98fn qvector slot ulong frag view uchar * size ulong to void
99id = qbind slot frag 2
100if or ne get qwrank id 1 ne get qwshape mul id 4 size
101qwfail 43
102end
103end
104text qp0 "input_layernorm.weight"
105text qp1 "post_attention_layernorm.weight"
106fn qnorms to void
107qvector 0 qp0 get qcfg 1
108qvector 1 qp1 get qcfg 1
109end
110text qp2 "linear_attn.A_log"
111text qp3 "linear_attn.dt_bias"
112text qp4 "linear_attn.in_proj_a.weight"
113text qp5 "linear_attn.in_proj_b.weight"
114text qp6 "linear_attn.in_proj_qkv.weight"
115text qp7 "linear_attn.in_proj_z.weight"
116text qp8 "linear_attn.norm.weight"
117text qp9 "linear_attn.out_proj.weight"
118fn qgdnweights to void
119qvector 2 qp2 div get qcfg 3 128
120qvector 3 qp3 div get qcfg 3 128
121qmatrix 4 qp4 div get qcfg 3 128 get qcfg 1 2
122qmatrix 5 qp5 div get qcfg 3 128 get qcfg 1 2
123qmatrix 6 qp6 add mul 2 get qcfg 2 get qcfg 3 get qcfg 1 1
124qmatrix 7 qp7 get qcfg 3 get qcfg 1 1
125qvector 8 qp8 128
126qmatrix 9 qp9 get qcfg 1 get qcfg 3 1
127end
128text qp11 "self_attn.q_norm.weight"
129text qp12 "self_attn.k_norm.weight"
130text qp13 "self_attn.q_proj.weight"
131text qp14 "self_attn.k_proj.weight"
132text qp15 "self_attn.v_proj.weight"
133text qp16 "self_attn.o_proj.weight"
134fn qattnweights to void
135qvector 11 qp11 256
136qvector 12 qp12 256
137qmatrix 13 qp13 mul 2 get qcfg 4 get qcfg 1 1
138qmatrix 14 qp14 get qcfg 5 get qcfg 1 1
139qmatrix 15 qp15 get qcfg 5 get qcfg 1 1
140qmatrix 16 qp16 get qcfg 1 get qcfg 4 1
141end
142text qp17 "mlp.gate_proj.weight"
143text qp18 "mlp.up_proj.weight"
144text qp19 "mlp.down_proj.weight"
145fn qdenseweights to void
146qmatrix 17 qp17 get qcfg 6 get qcfg 1 1
147qmatrix 18 qp18 get qcfg 6 get qcfg 1 1
148qmatrix 19 qp19 get qcfg 1 get qcfg 6 1
149end
150text qp20 "mlp.gate.weight"
151text qp21 "mlp.shared_expert_gate.weight"
152text qp22 "mlp.shared_expert.gate_proj.weight"
153text qp23 "mlp.shared_expert.up_proj.weight"
154text qp24 "mlp.shared_expert.down_proj.weight"
155fn qrouterweights to void
156qmatrix 20 qp20 256 get qcfg 1 2
157qmatrix 21 qp21 1 get qcfg 1 2
158qmatrix 22 qp22 512 get qcfg 1 1
159qmatrix 23 qp23 512 get qcfg 1 1
160qmatrix 24 qp24 get qcfg 1 512 1
161end
162
163text qp10 "linear_attn.conv1d.weight"
164text qeg "gate_proj.weight"
165text qeu "up_proj.weight"
166text qed "down_proj.weight"
167fn qconvweight to void
168id = qbind 10 qp10 2
169a = mul id 4
170width = add mul 2 get qcfg 2 get qcfg 3
171if or ne get qwrank id 3 ne get qwshape a width
172qwfail 44
173end
174if or ne get qwshape add a 1 1 ne get qwshape add a 2 4
175qwfail 44
176end
177end
178
179fn qlayerweights layer ulong to void
180put qcfg 7 layer
181put qcfg 8 0
182put qcfg 9 mul layer 1600
183qnorms
184if eq rem layer 4 3
185qattnweights
186else
187qconvweight
188qgdnweights
189end
190if eq get qcfg 0 64
191qdenseweights
192ret
193end
194qrouterweights
195for e ulong 256
196put qcfg 8 add e 1
197slot = add 32 mul e 3
198qmatrix slot qeg 512 2048 1
199qmatrix add slot 1 qeu 512 2048 1
200qmatrix add slot 2 qed 2048 512 1
201end
202end
203
204fn qprofile layers ulong to void
205put qcfg 0 layers
206if eq layers 64
207put qcfg 1 5120
208put qcfg 2 2048
209put qcfg 3 6144
210put qcfg 4 6144
211put qcfg 5 1024
212put qcfg 6 17408
213else
214if ne layers 40
215qwfail 45
216end
217put qcfg 1 2048
218put qcfg 2 2048
219put qcfg 3 4096
220put qcfg 4 4096
221put qcfg 5 512
222put qcfg 6 512
223end
224for l ulong layers
225qlayerweights l
226end
227put qcfg 7 64
228put qcfg 8 0
229put qcfg 9 0
230note Extra roles in layer zero are separate from the layer and expert slots.
231qmatrix 1020 qembed 248320 get qcfg 1 2
232qmatrix 1021 qlm 248320 get qcfg 1 2
233qvector 1022 qfinal get qcfg 1
234for i ulong get qwstate 1
235if eq get qbound add i 1 0
236qwfail 46
237end
238end
239end