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
omega-mv / core / sovereign-core / om / qwen-native / flash / profile.om
| 1 | note Fixed architecture of the Qwen3.8-Flash-Next-FP8 text checkpoint. Every text tensor is bound before first use. |
| 2 | note Layer roles: 2-10 linear attention, 11-16 full attention, 20-24 router and shared expert, |
| 3 | note 25-28 attention hyper-connection, 29-32 expert hyper-connection, 33-35 indexer, 36-45 lexical layer, |
| 4 | note 64+3e gate, up and down of routed expert e. |
| 5 | global qcfg ulong 12 |
| 6 | global qrole uint 76800 |
| 7 | global qscale uint 196608 |
| 8 | global qbound uchar 196608 |
| 9 | global qglob uint 8 |
| 10 | global qngram uint 128 |
| 11 | text qlayerprefix "model.language_model.layers." |
| 12 | text qexpertprefix "mlp.experts." |
| 13 | text qsep "." |
| 14 | text qscalesuffix "_scale_inv" |
| 15 | text qembed "model.language_model.embed_tokens.weight" |
| 16 | text qlm "lm_head.weight" |
| 17 | text qmixn "model.language_model.hyper_connection_mixer.hc_norm.weight" |
| 18 | text qmixd "model.language_model.hyper_connection_mixer.input_mix_weight_down.weight" |
| 19 | text qmixu "model.language_model.hyper_connection_mixer.input_mix_weight_up.weight" |
| 20 | fn qappend buf edit uchar * pos ulong frag view uchar * to ulong |
| 21 | for i ulong len frag |
| 22 | put buf add pos i get frag i |
| 23 | end |
| 24 | ret add pos len frag |
| 25 | end |
| 26 | |
| 27 | fn qdecimal buf edit uchar * pos ulong x ulong to ulong |
| 28 | p = pos |
| 29 | if ge x 100 |
| 30 | put buf p uchar add 48 div x 100 |
| 31 | p = add p 1 |
| 32 | end |
| 33 | if ge x 10 |
| 34 | put buf p uchar add 48 rem div x 10 10 |
| 35 | p = add p 1 |
| 36 | end |
| 37 | put buf p uchar add 48 rem x 10 |
| 38 | ret add p 1 |
| 39 | end |
| 40 | |
| 41 | fn qresolven frag view uchar * n ulong to ulong |
| 42 | buf = new uchar 256 0 |
| 43 | p = ulong 0 |
| 44 | l = get qcfg 7 |
| 45 | if lt l 64 |
| 46 | p = qappend buf p qlayerprefix |
| 47 | p = qdecimal buf p l |
| 48 | p = qappend buf p qsep |
| 49 | e = get qcfg 8 |
| 50 | if gt e 0 |
| 51 | p = qappend buf p qexpertprefix |
| 52 | p = qdecimal buf p sub e 1 |
| 53 | p = qappend buf p qsep |
| 54 | end |
| 55 | end |
| 56 | for i ulong n |
| 57 | put buf add p i get frag i |
| 58 | end |
| 59 | ret qwid buf add p n |
| 60 | end |
| 61 | |
| 62 | fn qresolve frag view uchar * to ulong |
| 63 | ret qresolven frag len frag |
| 64 | end |
| 65 | |
| 66 | fn qbindid id ulong dtype ulong to void |
| 67 | if or ne ulong get qwdtype id dtype ne get qbound id 0 |
| 68 | qwfail 40 |
| 69 | end |
| 70 | put qbound id 1 |
| 71 | end |
| 72 | |
| 73 | fn qbind slot ulong frag view uchar * dtype ulong to ulong |
| 74 | id = qresolve frag |
| 75 | qbindid id dtype |
| 76 | put qrole add get qcfg 9 slot uint id |
| 77 | ret id |
| 78 | end |
| 79 | |
| 80 | fn qrank2 id ulong rows ulong cols ulong to void |
| 81 | if ne get qwrank id 2 |
| 82 | qwfail 41 |
| 83 | end |
| 84 | base = mul id 4 |
| 85 | if or ne get qwshape base rows ne get qwshape add base 1 cols |
| 86 | qwfail 41 |
| 87 | end |
| 88 | end |
| 89 | |
| 90 | fn qlinkscale id ulong rows ulong cols ulong to void |
| 91 | buf = new uchar 256 0 |
| 92 | p = ulong get qwnpos id |
| 93 | n = ulong get qwnlen id |
| 94 | for j ulong n |
| 95 | put buf j get qwname add p j |
| 96 | end |
| 97 | n = qappend buf n qscalesuffix |
| 98 | s = qwid buf n |
| 99 | qbindid s 2 |
| 100 | qrank2 s div add rows 127 128 div add cols 127 128 |
| 101 | put qscale id uint s |
| 102 | end |
| 103 | |
| 104 | fn qmatrix slot ulong frag view uchar * rows ulong cols ulong dtype ulong to void |
| 105 | id = qbind slot frag dtype |
| 106 | qrank2 id rows cols |
| 107 | if eq dtype 1 |
| 108 | qlinkscale id rows cols |
| 109 | end |
| 110 | end |
| 111 | |
| 112 | fn qvecshape id ulong size ulong to void |
| 113 | if or ne get qwrank id 1 ne get qwshape mul id 4 size |
| 114 | qwfail 43 |
| 115 | end |
| 116 | end |
| 117 | |
| 118 | fn qvector slot ulong frag view uchar * size ulong to void |
| 119 | id = qbind slot frag 2 |
| 120 | qvecshape id size |
| 121 | end |
| 122 | |
| 123 | fn qvector64 slot ulong frag view uchar * size ulong to void |
| 124 | id = qbind slot frag 8 |
| 125 | qvecshape id size |
| 126 | end |
| 127 | |
| 128 | fn qconv slot ulong frag view uchar * to void |
| 129 | id = qbind slot frag 2 |
| 130 | a = mul id 4 |
| 131 | if or ne get qwrank id 3 ne get qwshape a 10240 |
| 132 | qwfail 44 |
| 133 | end |
| 134 | if or ne get qwshape add a 1 1 ne get qwshape add a 2 4 |
| 135 | qwfail 44 |
| 136 | end |
| 137 | end |
| 138 | |
| 139 | text qp2 "linear_attn.A_log" |
| 140 | text qp3 "linear_attn.dt_bias" |
| 141 | text qp4 "linear_attn.in_proj_a.weight" |
| 142 | text qp5 "linear_attn.in_proj_b.weight" |
| 143 | text qp6 "linear_attn.in_proj_qkv.weight" |
| 144 | text qp7 "linear_attn.in_proj_z.weight" |
| 145 | text qp8 "linear_attn.norm.weight" |
| 146 | text qp9 "linear_attn.out_proj.weight" |
| 147 | text qp10 "linear_attn.conv1d.weight" |
| 148 | fn qgdnweights to void |
| 149 | qvector 2 qp2 48 |
| 150 | qvector 3 qp3 48 |
| 151 | qmatrix 4 qp4 48 2560 2 |
| 152 | qmatrix 5 qp5 48 2560 2 |
| 153 | qmatrix 6 qp6 10240 2560 2 |
| 154 | qmatrix 7 qp7 6144 2560 2 |
| 155 | qvector 8 qp8 128 |
| 156 | qmatrix 9 qp9 2560 6144 2 |
| 157 | qconv 10 qp10 |
| 158 | end |
| 159 | |
| 160 | text qp11 "self_attn.q_norm.weight" |
| 161 | text qp12 "self_attn.k_norm.weight" |
| 162 | text qp13 "self_attn.q_proj.weight" |
| 163 | text qp14 "self_attn.k_proj.weight" |
| 164 | text qp15 "self_attn.v_proj.weight" |
| 165 | text qp16 "self_attn.o_proj.weight" |
| 166 | text qp33 "self_attn.indexer.index_qk_proj.weight" |
| 167 | text qp34 "self_attn.indexer.k_layernorm.weight" |
| 168 | text qp35 "self_attn.indexer.q_layernorm.weight" |
| 169 | fn qattnweights to void |
| 170 | qvector 11 qp11 256 |
| 171 | qvector 12 qp12 256 |
| 172 | qmatrix 13 qp13 12288 2560 2 |
| 173 | qmatrix 14 qp14 512 2560 2 |
| 174 | qmatrix 15 qp15 512 2560 2 |
| 175 | qmatrix 16 qp16 2560 6144 2 |
| 176 | qmatrix 33 qp33 640 2560 2 |
| 177 | qvector 34 qp34 128 |
| 178 | qvector 35 qp35 128 |
| 179 | end |
| 180 | |
| 181 | text qp20 "mlp.gate.weight" |
| 182 | text qp21 "mlp.shared_expert_gate.weight" |
| 183 | text qp22 "mlp.shared_expert.gate_proj.weight" |
| 184 | text qp23 "mlp.shared_expert.up_proj.weight" |
| 185 | text qp24 "mlp.shared_expert.down_proj.weight" |
| 186 | fn qrouterweights to void |
| 187 | qmatrix 20 qp20 512 2560 2 |
| 188 | qmatrix 21 qp21 1 2560 2 |
| 189 | qmatrix 22 qp22 640 2560 2 |
| 190 | qmatrix 23 qp23 640 2560 2 |
| 191 | qmatrix 24 qp24 2560 640 2 |
| 192 | end |
| 193 | |
| 194 | text qp25 "attn_hyper_connection.hc_norm.weight" |
| 195 | text qp26 "attn_hyper_connection.input_mix_weight_down.weight" |
| 196 | text qp27 "attn_hyper_connection.input_mix_weight_up.weight" |
| 197 | text qp28 "attn_hyper_connection.block_inject_weight.weight" |
| 198 | text qp29 "mlp_hyper_connection.hc_norm.weight" |
| 199 | text qp30 "mlp_hyper_connection.input_mix_weight_down.weight" |
| 200 | text qp31 "mlp_hyper_connection.input_mix_weight_up.weight" |
| 201 | text qp32 "mlp_hyper_connection.block_inject_weight.weight" |
| 202 | fn qhyperweights to void |
| 203 | qvector 25 qp25 10240 |
| 204 | qmatrix 26 qp26 320 10240 2 |
| 205 | qmatrix 27 qp27 10240 320 2 |
| 206 | qmatrix 28 qp28 4 10240 2 |
| 207 | qvector 29 qp29 10240 |
| 208 | qmatrix 30 qp30 320 10240 2 |
| 209 | qmatrix 31 qp31 10240 320 2 |
| 210 | qmatrix 32 qp32 4 10240 2 |
| 211 | end |
| 212 | |
| 213 | text qp36 "ple.conv1d.weight" |
| 214 | text qp37 "ple.key_proj.weight" |
| 215 | text qp38 "ple.norm_conv.weight" |
| 216 | text qp39 "ple.norm_key.weight" |
| 217 | text qp40 "ple.norm_query.weight" |
| 218 | text qp41 "ple.value_proj.weight" |
| 219 | text qp42 "ple.ple_embedding.layer_multipliers" |
| 220 | text qp43 "ple.ple_embedding.ngram_heads_offsets" |
| 221 | text qp44 "ple.ple_embedding.ngram_heads_vocab_sizes" |
| 222 | text qp45 "ple.ple_embedding.ngram_embedding.weight_scale" |
| 223 | text qngpre "ple.ple_embedding.ngram_embedding.shard_" |
| 224 | text qngsuf ".weight" |
| 225 | fn qlexicalweights to void |
| 226 | qconv 36 qp36 |
| 227 | qmatrix 37 qp37 10240 2560 2 |
| 228 | qvector 38 qp38 10240 |
| 229 | qvector 39 qp39 10240 |
| 230 | qvector 40 qp40 10240 |
| 231 | qmatrix 41 qp41 2560 2560 2 |
| 232 | qvector64 42 qp42 3 |
| 233 | qvector64 43 qp43 16 |
| 234 | qvector64 44 qp44 16 |
| 235 | qvector 45 qp45 1 |
| 236 | frag = new uchar 64 0 |
| 237 | for s ulong 128 |
| 238 | n = qappend frag 0 qngpre |
| 239 | n = qdecimal frag n s |
| 240 | n = qappend frag n qngsuf |
| 241 | id = qresolven frag n |
| 242 | qbindid id 1 |
| 243 | qrank2 id 2500012 160 |
| 244 | put qngram s uint id |
| 245 | end |
| 246 | end |
| 247 | |
| 248 | text qeg "gate_proj.weight" |
| 249 | text qeu "up_proj.weight" |
| 250 | text qed "down_proj.weight" |
| 251 | fn qlayerweights layer ulong to void |
| 252 | put qcfg 7 layer |
| 253 | put qcfg 8 0 |
| 254 | put qcfg 9 mul layer 1600 |
| 255 | if eq rem layer 4 3 |
| 256 | qattnweights |
| 257 | else |
| 258 | qgdnweights |
| 259 | end |
| 260 | qrouterweights |
| 261 | qhyperweights |
| 262 | if eq layer 1 |
| 263 | qlexicalweights |
| 264 | end |
| 265 | for e ulong 512 |
| 266 | put qcfg 8 add e 1 |
| 267 | slot = add 64 mul e 3 |
| 268 | qmatrix slot qeg 640 2560 1 |
| 269 | qmatrix add slot 1 qeu 640 2560 1 |
| 270 | qmatrix add slot 2 qed 2560 640 1 |
| 271 | end |
| 272 | end |
| 273 | |
| 274 | fn qglobal slot ulong name view uchar * dtype ulong to ulong |
| 275 | id = qwid name len name |
| 276 | qbindid id dtype |
| 277 | put qglob slot uint id |
| 278 | ret id |
| 279 | end |
| 280 | |
| 281 | fn qprofile layers ulong to void |
| 282 | if ne layers 48 |
| 283 | qwfail 45 |
| 284 | end |
| 285 | put qcfg 0 layers |
| 286 | put qcfg 1 2560 |
| 287 | put qcfg 2 2048 |
| 288 | put qcfg 3 6144 |
| 289 | put qcfg 4 6144 |
| 290 | put qcfg 5 512 |
| 291 | put qcfg 6 640 |
| 292 | for l ulong layers |
| 293 | qlayerweights l |
| 294 | end |
| 295 | put qcfg 7 64 |
| 296 | put qcfg 8 0 |
| 297 | put qcfg 9 0 |
| 298 | qrank2 qglobal 0 qembed 2 248320 2560 |
| 299 | qrank2 qglobal 1 qlm 2 248320 2560 |
| 300 | id = qglobal 2 qmixn 2 |
| 301 | if or ne get qwrank id 1 ne get qwshape mul id 4 10240 |
| 302 | qwfail 43 |
| 303 | end |
| 304 | qrank2 qglobal 3 qmixd 2 320 10240 |
| 305 | qrank2 qglobal 4 qmixu 2 10240 320 |
| 306 | for i ulong get qwstate 1 |
| 307 | if eq get qbound add i 1 0 |
| 308 | qwfail 46 |
| 309 | end |
| 310 | end |
| 311 | end |