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 / om / gpu / engine / config.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note om/gpu/engine/config.om: Universal Pure Seeded-OM-2 HuggingFace config.json Parser & ModelSpec. |
| 3 | note Automatically detects architecture, dimensions, layer types (Full-Attention vs Gated DeltaNet), |
| 4 | note MoE vs Dense, RoPE parameters, RMSNorm convention ((1+w) vs w), QK-Norm, and quantization |
| 5 | note from any standard HuggingFace config.json (Llama 3, Qwen 2.5/3/3.5/3.6/3.8/4, Gemma 2/3, |
| 6 | note Mistral, DeepSeek, Phi, or custom checkpoints). |
| 7 | |
| 8 | note ModelSpec field indices (global engSpec ulong 64) |
| 9 | const MS_ARCH ulong 0 |
| 10 | const MS_H ulong 1 |
| 11 | const MS_I ulong 2 |
| 12 | const MS_MOE_I ulong 3 |
| 13 | const MS_LAYERS ulong 4 |
| 14 | const MS_NQ ulong 5 |
| 15 | const MS_NKV ulong 6 |
| 16 | const MS_HD ulong 7 |
| 17 | const MS_VOCAB ulong 8 |
| 18 | const MS_NEXP ulong 9 |
| 19 | const MS_TOPK ulong 10 |
| 20 | const MS_FA_INT ulong 11 |
| 21 | const MS_GDN_NK ulong 12 |
| 22 | const MS_GDN_NV ulong 13 |
| 23 | const MS_GDN_HD ulong 14 |
| 24 | const MS_ROPE_DIMS ulong 15 |
| 25 | const MS_ROPE_THETA ulong 16 |
| 26 | const MS_NORM_ADD1 ulong 17 |
| 27 | const MS_QK_NORM ulong 18 |
| 28 | const MS_ATTN_GATE ulong 19 |
| 29 | const MS_TIE_EMB ulong 20 |
| 30 | const MS_QUANT ulong 21 |
| 31 | const MS_MAX_CTX ulong 22 |
| 32 | const MS_N_FA ulong 23 |
| 33 | const MS_N_GDN ulong 24 |
| 34 | const MS_SH_EXP ulong 25 |
| 35 | const MS_SH_I ulong 26 |
| 36 | const MS_HAS_TEXT_PREFIX ulong 27 |
| 37 | const MS_CONV_K ulong 28 |
| 38 | const MS_EPS_E6 ulong 29 |
| 39 | const MS_HC_COUNT ulong 30 |
| 40 | const MS_HC_LOWRANK ulong 31 |
| 41 | const MS_GDN_SIGMOID ulong 32 |
| 42 | const MS_PLE_LAYER ulong 33 |
| 43 | const MS_PLE_DIM ulong 34 |
| 44 | const MS_PLE_NGRAM ulong 35 |
| 45 | const MS_PLE_HPN ulong 36 |
| 46 | const MS_PLE_CONV_K ulong 37 |
| 47 | const MS_PLE_SPLITS ulong 38 |
| 48 | const MS_IDX_BUDGET ulong 39 |
| 49 | const MS_IDX_COMP ulong 40 |
| 50 | const MS_IDX_NH ulong 41 |
| 51 | const MS_IDX_NKV ulong 42 |
| 52 | const MS_IDX_HD ulong 43 |
| 53 | const MS_EOS_ID ulong 44 |
| 54 | |
| 55 | global engSpec ulong 64 |
| 56 | global engLayerKind uchar 256 |
| 57 | global engCfgBuf uchar 262144 |
| 58 | global engCfgLen ulong 1 |
| 59 | global engModelType uchar 64 |
| 60 | global engModelTypeLen ulong 1 |
| 61 | global engModelDir uchar 512 |
| 62 | global engModelDirLen ulong 1 |
| 63 | global engPathTmp uchar 1024 |
| 64 | |
| 65 | text engCfgSuf "/config.json" |
| 66 | text engKTextCfg "\"text_config\"" |
| 67 | text engKModelType "\"model_type\"" |
| 68 | text engKHid "\"hidden_size\"" |
| 69 | text engKInter "\"intermediate_size\"" |
| 70 | text engKMoeInter "\"moe_intermediate_size\"" |
| 71 | text engKShInter "\"shared_expert_intermediate_size\"" |
| 72 | text engKLayers "\"num_hidden_layers\"" |
| 73 | text engKNq "\"num_attention_heads\"" |
| 74 | text engKNkv "\"num_key_value_heads\"" |
| 75 | text engKHd "\"head_dim\"" |
| 76 | text engKVocab "\"vocab_size\"" |
| 77 | text engKNexp "\"num_experts\"" |
| 78 | text engKNRouted "\"n_routed_experts\"" |
| 79 | text engKTopk "\"num_experts_per_tok\"" |
| 80 | text engKFaInt "\"full_attention_interval\"" |
| 81 | text engKGdnNk "\"linear_num_key_heads\"" |
| 82 | text engKGdnNv "\"linear_num_value_heads\"" |
| 83 | text engKGdnHd "\"linear_key_head_dim\"" |
| 84 | text engKConvK "\"linear_conv_kernel_dim\"" |
| 85 | text engKPartRot "\"partial_rotary_factor\"" |
| 86 | text engKRopeTheta "\"rope_theta\"" |
| 87 | text engKTieEmb "\"tie_word_embeddings\"" |
| 88 | text engKAttnGate "\"attn_output_gate\"" |
| 89 | text engKQuantMeth "\"quant_method\"" |
| 90 | text engKEps "\"rms_norm_eps\"" |
| 91 | text engKHcCount "\"hc_count\"" |
| 92 | text engKHcLowrank "\"hc_lowrank\"" |
| 93 | text engKOutGate "\"output_gate_type\"" |
| 94 | text engKPleLayers "\"ple_layer_ids\"" |
| 95 | text engKPleDim "\"ple_embed_dim\"" |
| 96 | text engKNgramSz "\"ngram_size\"" |
| 97 | text engKHpn "\"heads_per_ngram\"" |
| 98 | text engKPleConvK "\"ple_conv_kernel_size\"" |
| 99 | text engKPleSplits "\"split_ngram_parts\"" |
| 100 | text engKIdxBudget "\"indexer_budget\"" |
| 101 | text engKIdxComp "\"indexer_compress_ratio\"" |
| 102 | text engKIdxNh "\"indexer_n_heads\"" |
| 103 | text engKIdxNkv "\"indexer_kv_heads\"" |
| 104 | text engKIdxHd "\"indexer_head_dim\"" |
| 105 | text engKEosId "\"eos_token_id\"" |
| 106 | text engSubSigmoid "sigmoid" |
| 107 | |
| 108 | fn engJoinPath suf view uchar * to ulong |
| 109 | dlen = get engModelDirLen 0 |
| 110 | for i ulong dlen bound 512 |
| 111 | put engPathTmp i get engModelDir i |
| 112 | end |
| 113 | p = dlen |
| 114 | for i ulong len suf bound 256 |
| 115 | put engPathTmp p get suf i |
| 116 | p = add p 1 |
| 117 | end |
| 118 | put engPathTmp p 0 |
| 119 | ret p |
| 120 | end |
| 121 | |
| 122 | fn engMatchCfg pos ulong pat view uchar * to bool |
| 123 | clen = get engCfgLen 0 |
| 124 | plen = len pat |
| 125 | if gt add pos plen clen |
| 126 | ret false |
| 127 | end |
| 128 | for i ulong plen bound 64 |
| 129 | if ne get engCfgBuf add pos i get pat i |
| 130 | ret false |
| 131 | end |
| 132 | end |
| 133 | ret true |
| 134 | end |
| 135 | |
| 136 | fn engFindKey start ulong endPos ulong key view uchar * to ulong |
| 137 | p = start |
| 138 | klen = len key |
| 139 | while lt add p klen endPos bound 262144 |
| 140 | if engMatchCfg p key |
| 141 | j = add p klen |
| 142 | while and lt j endPos ne get engCfgBuf j 58 bound 64 |
| 143 | j = add j 1 |
| 144 | end |
| 145 | if lt add j 1 endPos |
| 146 | j = add j 1 |
| 147 | while lt j endPos bound 64 |
| 148 | c = get engCfgBuf j |
| 149 | if eq c 32 |
| 150 | j = add j 1 |
| 151 | else |
| 152 | if eq c 9 |
| 153 | j = add j 1 |
| 154 | else |
| 155 | if eq c 10 |
| 156 | j = add j 1 |
| 157 | else |
| 158 | if eq c 13 |
| 159 | j = add j 1 |
| 160 | else |
| 161 | break |
| 162 | end |
| 163 | end |
| 164 | end |
| 165 | end |
| 166 | end |
| 167 | ret j |
| 168 | end |
| 169 | end |
| 170 | p = add p 1 |
| 171 | end |
| 172 | ret 0 |
| 173 | end |
| 174 | |
| 175 | fn engParseU64At pos ulong to ulong |
| 176 | clen = get engCfgLen 0 |
| 177 | v = ulong 0 |
| 178 | p = pos |
| 179 | while lt p clen bound 32 |
| 180 | c = get engCfgBuf p |
| 181 | if and ge c 48 le c 57 |
| 182 | v = add mul v 10 ulong sub c 48 |
| 183 | p = add p 1 |
| 184 | else |
| 185 | break |
| 186 | end |
| 187 | end |
| 188 | ret v |
| 189 | end |
| 190 | |
| 191 | fn engParseBoolAt pos ulong to ulong |
| 192 | clen = get engCfgLen 0 |
| 193 | if lt pos clen |
| 194 | if eq get engCfgBuf pos 116 |
| 195 | ret 1 |
| 196 | end |
| 197 | end |
| 198 | ret 0 |
| 199 | end |
| 200 | |
| 201 | fn engParseFrac100At pos ulong to ulong |
| 202 | note Parses a decimal like 0.25 -> 25, 1.0 -> 100, 0.5 -> 50 |
| 203 | clen = get engCfgLen 0 |
| 204 | if ge pos clen |
| 205 | ret 100 |
| 206 | end |
| 207 | whole = engParseU64At pos |
| 208 | p = pos |
| 209 | while and lt p clen and ge get engCfgBuf p 48 le get engCfgBuf p 57 bound 16 |
| 210 | p = add p 1 |
| 211 | end |
| 212 | frac = ulong 0 |
| 213 | if and lt p clen eq get engCfgBuf p 46 |
| 214 | p = add p 1 |
| 215 | if and lt p clen and ge get engCfgBuf p 48 le get engCfgBuf p 57 |
| 216 | frac = mul ulong sub get engCfgBuf p 48 10 |
| 217 | p = add p 1 |
| 218 | if and lt p clen and ge get engCfgBuf p 48 le get engCfgBuf p 57 |
| 219 | frac = add frac ulong sub get engCfgBuf p 48 |
| 220 | end |
| 221 | end |
| 222 | end |
| 223 | ret add mul whole 100 frac |
| 224 | end |
| 225 | |
| 226 | fn engReadStrAt pos ulong dst edit uchar 64 to ulong |
| 227 | clen = get engCfgLen 0 |
| 228 | if or ge pos clen ne get engCfgBuf pos 34 |
| 229 | ret 0 |
| 230 | end |
| 231 | p = add pos 1 |
| 232 | n = ulong 0 |
| 233 | while and lt p clen lt n 62 bound 64 |
| 234 | c = get engCfgBuf p |
| 235 | if eq c 34 |
| 236 | break |
| 237 | end |
| 238 | put dst n c |
| 239 | n = add n 1 |
| 240 | p = add p 1 |
| 241 | end |
| 242 | put dst n 0 |
| 243 | ret n |
| 244 | end |
| 245 | |
| 246 | fn engStrHas buf view uchar 64 blen ulong pat view uchar * to bool |
| 247 | slen = len pat |
| 248 | if gt slen blen |
| 249 | ret false |
| 250 | end |
| 251 | for i ulong add sub blen slen 1 bound 64 |
| 252 | ok = true |
| 253 | for j ulong slen bound 32 |
| 254 | if ne get buf add i j get pat j |
| 255 | ok = false |
| 256 | break |
| 257 | end |
| 258 | end |
| 259 | if ok |
| 260 | ret true |
| 261 | end |
| 262 | end |
| 263 | ret false |
| 264 | end |
| 265 | |
| 266 | text engSubQwen35 "qwen3_5" |
| 267 | text engSubQwen4 "qwen4" |
| 268 | text engSubMoe "moe" |
| 269 | text engSubDeepseek "deepseek" |
| 270 | text engSubGemma "gemma" |
| 271 | text engSubQwen3 "qwen3" |
| 272 | text engSubFp8 "fp8" |
| 273 | text engSubModelopt "modelopt" |
| 274 | |
| 275 | fn engSkipColonWs j0 ulong endPos ulong to ulong |
| 276 | j = j0 |
| 277 | while lt j endPos bound 64 |
| 278 | if eq get engCfgBuf j 58 |
| 279 | break |
| 280 | end |
| 281 | j = add j 1 |
| 282 | end |
| 283 | if ge add j 1 endPos |
| 284 | ret 0 |
| 285 | end |
| 286 | j = add j 1 |
| 287 | while lt j endPos bound 64 |
| 288 | ch = get engCfgBuf j |
| 289 | if eq ch 32 |
| 290 | j = add j 1 |
| 291 | else |
| 292 | if eq ch 9 |
| 293 | j = add j 1 |
| 294 | else |
| 295 | if eq ch 10 |
| 296 | j = add j 1 |
| 297 | else |
| 298 | if eq ch 13 |
| 299 | j = add j 1 |
| 300 | else |
| 301 | break |
| 302 | end |
| 303 | end |
| 304 | end |
| 305 | end |
| 306 | end |
| 307 | ret j |
| 308 | end |
| 309 | |
| 310 | fn engFindKeyTop start ulong endPos ulong key view uchar * to ulong |
| 311 | note Finds key at top level of the JSON object starting at start (depth == 1), skipping nested {...} like "mtp"! |
| 312 | p = start |
| 313 | klen = len key |
| 314 | depth = ulong 0 |
| 315 | inStr = false |
| 316 | while lt add p klen endPos bound 262144 |
| 317 | c = get engCfgBuf p |
| 318 | if eq c 34 |
| 319 | if not inStr |
| 320 | if eq depth 1 |
| 321 | if engMatchCfg p key |
| 322 | ret engSkipColonWs add p klen endPos |
| 323 | end |
| 324 | end |
| 325 | end |
| 326 | inStr = not inStr |
| 327 | else |
| 328 | if not inStr |
| 329 | if eq c 123 |
| 330 | depth = add depth 1 |
| 331 | else |
| 332 | if eq c 125 |
| 333 | if gt depth 0 |
| 334 | depth = sub depth 1 |
| 335 | end |
| 336 | if eq depth 0 |
| 337 | ret 0 |
| 338 | end |
| 339 | end |
| 340 | end |
| 341 | end |
| 342 | end |
| 343 | p = add p 1 |
| 344 | end |
| 345 | ret 0 |
| 346 | end |
| 347 | |
| 348 | fn engSetIfKey start ulong tot ulong key view uchar * slot ulong to void |
| 349 | p = engFindKeyTop start tot key |
| 350 | if eq p 0 |
| 351 | p = engFindKey start tot key |
| 352 | end |
| 353 | if gt p 0 |
| 354 | put engSpec slot engParseU64At p |
| 355 | end |
| 356 | end |
| 357 | |
| 358 | fn engDetectArch tot ulong tStart ulong to void |
| 359 | mtPos = engFindKey tStart tot engKModelType |
| 360 | if eq mtPos 0 |
| 361 | mtPos = engFindKey 0 tot engKModelType |
| 362 | end |
| 363 | mtLocal = new uchar 64 0 |
| 364 | mtLen = ulong 0 |
| 365 | if gt mtPos 0 |
| 366 | mtLen = engReadStrAt mtPos mtLocal |
| 367 | for i ulong mtLen bound 64 |
| 368 | put engModelType i get mtLocal i |
| 369 | end |
| 370 | end |
| 371 | put engModelTypeLen 0 mtLen |
| 372 | if engStrHas mtLocal mtLen engSubQwen35 |
| 373 | put engSpec MS_NORM_ADD1 1 |
| 374 | put engSpec MS_QK_NORM 1 |
| 375 | put engSpec MS_ATTN_GATE 1 |
| 376 | if or gt get engSpec MS_NEXP 0 engStrHas mtLocal mtLen engSubMoe |
| 377 | put engSpec MS_ARCH 2 |
| 378 | put engSpec MS_SH_EXP 1 |
| 379 | if eq get engSpec MS_SH_I 0 |
| 380 | put engSpec MS_SH_I get engSpec MS_MOE_I |
| 381 | end |
| 382 | else |
| 383 | put engSpec MS_ARCH 1 |
| 384 | end |
| 385 | else |
| 386 | if engStrHas mtLocal mtLen engSubQwen4 |
| 387 | put engSpec MS_ARCH 3 |
| 388 | put engSpec MS_NORM_ADD1 1 |
| 389 | put engSpec MS_QK_NORM 1 |
| 390 | put engSpec MS_ATTN_GATE 1 |
| 391 | put engSpec MS_SH_EXP 1 |
| 392 | else |
| 393 | if engStrHas mtLocal mtLen engSubDeepseek |
| 394 | put engSpec MS_ARCH 4 |
| 395 | else |
| 396 | if engStrHas mtLocal mtLen engSubGemma |
| 397 | put engSpec MS_ARCH 5 |
| 398 | put engSpec MS_NORM_ADD1 1 |
| 399 | put engSpec MS_QK_NORM 1 |
| 400 | else |
| 401 | put engSpec MS_ARCH 0 |
| 402 | if engStrHas mtLocal mtLen engSubQwen3 |
| 403 | put engSpec MS_QK_NORM 1 |
| 404 | end |
| 405 | end |
| 406 | end |
| 407 | end |
| 408 | end |
| 409 | qTmp = new uchar 64 0 |
| 410 | qp = engFindKey 0 tot engKQuantMeth |
| 411 | if gt qp 0 |
| 412 | ql = engReadStrAt qp qTmp |
| 413 | if engStrHas qTmp ql engSubFp8 |
| 414 | put engSpec MS_QUANT 1 |
| 415 | else |
| 416 | if engStrHas qTmp ql engSubModelopt |
| 417 | put engSpec MS_QUANT 2 |
| 418 | end |
| 419 | end |
| 420 | end |
| 421 | end |
| 422 | |
| 423 | fn engComputeLayerKinds to void |
| 424 | nL = get engSpec MS_LAYERS |
| 425 | faInt = get engSpec MS_FA_INT |
| 426 | nFa = ulong 0 |
| 427 | nGdn = ulong 0 |
| 428 | for L ulong nL bound 256 |
| 429 | if eq faInt 1 |
| 430 | put engLayerKind L 0 |
| 431 | nFa = add nFa 1 |
| 432 | else |
| 433 | if eq rem add L 1 faInt 0 |
| 434 | put engLayerKind L 0 |
| 435 | nFa = add nFa 1 |
| 436 | else |
| 437 | put engLayerKind L 1 |
| 438 | nGdn = add nGdn 1 |
| 439 | end |
| 440 | end |
| 441 | end |
| 442 | put engSpec MS_N_FA nFa |
| 443 | put engSpec MS_N_GDN nGdn |
| 444 | end |
| 445 | |
| 446 | fn engParseFirstArrU64At pos ulong to ulong |
| 447 | clen = get engCfgLen 0 |
| 448 | p = pos |
| 449 | while lt p clen bound 64 |
| 450 | c = get engCfgBuf p |
| 451 | if and ge c 48 le c 57 |
| 452 | ret engParseU64At p |
| 453 | end |
| 454 | if eq c 93 |
| 455 | ret 0 |
| 456 | end |
| 457 | p = add p 1 |
| 458 | end |
| 459 | ret 0 |
| 460 | end |
| 461 | |
| 462 | fn engLoadConfig to bool |
| 463 | ogTmp = new uchar 64 0 |
| 464 | plen = engJoinPath engCfgSuf |
| 465 | fd = int fopen engPathTmp 0 plen 0 0 |
| 466 | if lt fd 0 |
| 467 | ret false |
| 468 | end |
| 469 | tot = ulong 0 |
| 470 | while lt tot 262100 bound 64 |
| 471 | got = pread fd engCfgBuf tot sub 262100 tot long tot |
| 472 | if le got 0 |
| 473 | break |
| 474 | end |
| 475 | tot = add tot ulong got |
| 476 | end |
| 477 | c0 = fclose fd |
| 478 | if eq tot 0 |
| 479 | ret false |
| 480 | end |
| 481 | put engCfgLen 0 tot |
| 482 | for i ulong 64 |
| 483 | put engSpec i 0 |
| 484 | end |
| 485 | put engSpec MS_FA_INT 1 |
| 486 | put engSpec MS_ROPE_THETA 1000000 |
| 487 | put engSpec MS_CONV_K 4 |
| 488 | put engSpec MS_EPS_E6 1 |
| 489 | put engSpec MS_MAX_CTX 131072 |
| 490 | put engSpec MS_HC_COUNT 1 |
| 491 | put engSpec MS_EOS_ID 248044 |
| 492 | tStart = ulong 0 |
| 493 | tcPos = engFindKey 0 tot engKTextCfg |
| 494 | if gt tcPos 0 |
| 495 | tStart = tcPos |
| 496 | put engSpec MS_HAS_TEXT_PREFIX 1 |
| 497 | end |
| 498 | engSetIfKey tStart tot engKHid MS_H |
| 499 | engSetIfKey tStart tot engKInter MS_I |
| 500 | engSetIfKey tStart tot engKMoeInter MS_MOE_I |
| 501 | engSetIfKey tStart tot engKShInter MS_SH_I |
| 502 | if gt get engSpec MS_SH_I 0 |
| 503 | put engSpec MS_SH_EXP 1 |
| 504 | end |
| 505 | engSetIfKey tStart tot engKLayers MS_LAYERS |
| 506 | engSetIfKey tStart tot engKNq MS_NQ |
| 507 | engSetIfKey tStart tot engKNkv MS_NKV |
| 508 | engSetIfKey tStart tot engKHd MS_HD |
| 509 | if and eq get engSpec MS_HD 0 gt get engSpec MS_NQ 0 |
| 510 | put engSpec MS_HD div get engSpec MS_H get engSpec MS_NQ |
| 511 | end |
| 512 | if eq get engSpec MS_NKV 0 |
| 513 | put engSpec MS_NKV get engSpec MS_NQ |
| 514 | end |
| 515 | engSetIfKey tStart tot engKVocab MS_VOCAB |
| 516 | engSetIfKey tStart tot engKNexp MS_NEXP |
| 517 | if eq get engSpec MS_NEXP 0 |
| 518 | engSetIfKey tStart tot engKNRouted MS_NEXP |
| 519 | end |
| 520 | engSetIfKey tStart tot engKTopk MS_TOPK |
| 521 | engSetIfKey tStart tot engKFaInt MS_FA_INT |
| 522 | if eq get engSpec MS_FA_INT 0 |
| 523 | put engSpec MS_FA_INT 1 |
| 524 | end |
| 525 | engSetIfKey tStart tot engKGdnNk MS_GDN_NK |
| 526 | engSetIfKey tStart tot engKGdnNv MS_GDN_NV |
| 527 | engSetIfKey tStart tot engKGdnHd MS_GDN_HD |
| 528 | engSetIfKey tStart tot engKConvK MS_CONV_K |
| 529 | engSetIfKey tStart tot engKRopeTheta MS_ROPE_THETA |
| 530 | engSetIfKey tStart tot engKHcCount MS_HC_COUNT |
| 531 | if eq get engSpec MS_HC_COUNT 0 |
| 532 | put engSpec MS_HC_COUNT 1 |
| 533 | end |
| 534 | engSetIfKey tStart tot engKHcLowrank MS_HC_LOWRANK |
| 535 | engSetIfKey tStart tot engKPleDim MS_PLE_DIM |
| 536 | engSetIfKey tStart tot engKNgramSz MS_PLE_NGRAM |
| 537 | engSetIfKey tStart tot engKHpn MS_PLE_HPN |
| 538 | engSetIfKey tStart tot engKPleConvK MS_PLE_CONV_K |
| 539 | engSetIfKey tStart tot engKPleSplits MS_PLE_SPLITS |
| 540 | engSetIfKey tStart tot engKIdxBudget MS_IDX_BUDGET |
| 541 | engSetIfKey tStart tot engKIdxComp MS_IDX_COMP |
| 542 | engSetIfKey tStart tot engKIdxNh MS_IDX_NH |
| 543 | engSetIfKey tStart tot engKIdxNkv MS_IDX_NKV |
| 544 | engSetIfKey tStart tot engKIdxHd MS_IDX_HD |
| 545 | p = engFindKey tStart tot engKEosId |
| 546 | if gt p 0 |
| 547 | if eq get engCfgBuf p 91 |
| 548 | put engSpec MS_EOS_ID engParseFirstArrU64At p |
| 549 | else |
| 550 | put engSpec MS_EOS_ID engParseU64At p |
| 551 | end |
| 552 | end |
| 553 | p = engFindKey tStart tot engKPleLayers |
| 554 | if gt p 0 |
| 555 | put engSpec MS_PLE_LAYER engParseFirstArrU64At p |
| 556 | end |
| 557 | p = engFindKey tStart tot engKOutGate |
| 558 | if gt p 0 |
| 559 | ogl = engReadStrAt p ogTmp |
| 560 | if engStrHas ogTmp ogl engSubSigmoid |
| 561 | put engSpec MS_GDN_SIGMOID 1 |
| 562 | end |
| 563 | end |
| 564 | p = engFindKey tStart tot engKTieEmb |
| 565 | if gt p 0 |
| 566 | put engSpec MS_TIE_EMB engParseBoolAt p |
| 567 | end |
| 568 | p = engFindKey tStart tot engKAttnGate |
| 569 | if gt p 0 |
| 570 | put engSpec MS_ATTN_GATE engParseBoolAt p |
| 571 | end |
| 572 | rotPct = ulong 100 |
| 573 | p = engFindKey tStart tot engKPartRot |
| 574 | if gt p 0 |
| 575 | rotPct = engParseFrac100At p |
| 576 | end |
| 577 | put engSpec MS_ROPE_DIMS div mul get engSpec MS_HD rotPct 100 |
| 578 | engDetectArch tot tStart |
| 579 | engComputeLayerKinds |
| 580 | ret gt get engSpec MS_H 0 |
| 581 | end |