aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / tests / omegallm / weight-edit.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Experimental inference checkpoint editor. Concatenate after the normal CPU units with |
| 3 | note lio main renamed. Args OLD CURRENT NEW ALPHA_MILLI GAIN_MILLI. NEW must not exist. |
| 4 | note Weights become old + alpha * (current - old); final RMS gain is then scaled by gain. |
| 5 | note Preserve CURRENT metadata and optimizer state for provenance, not for continued training. |
| 6 | note Do not resume these edited checkpoints without a separate optimizer-state decision. |
| 7 | global wesh ulong 9 |
| 8 | |
| 9 | fn weempty to void |
| 10 | n = oargp 3 |
| 11 | fd = int fopen oarg 0 n 0 0 |
| 12 | if ge fd 0 |
| 13 | r = fclose fd |
| 14 | exit 52 |
| 15 | end |
| 16 | if ne fd -2 |
| 17 | exit 70 |
| 18 | end |
| 19 | end |
| 20 | |
| 21 | fn weone i ulong a f64 s f64 to void |
| 22 | v = owg i |
| 23 | v = add v mul sub a 1.0 sub v ogrg i |
| 24 | if ge i get og 33 |
| 25 | v = mul v s |
| 26 | end |
| 27 | if or ne v v gt fabs v 1000000.0 |
| 28 | exit 54 |
| 29 | end |
| 30 | owp i v |
| 31 | end |
| 32 | |
| 33 | fn wemix a f64 s f64 to void |
| 34 | p = get og 8 |
| 35 | nc = div add p 65535 65536 |
| 36 | for c ulong nc |
| 37 | st = mul c 65536 |
| 38 | en = add st 65536 |
| 39 | if gt en p |
| 40 | en = p |
| 41 | end |
| 42 | for j ulong sub en st |
| 43 | weone add st j a s |
| 44 | end |
| 45 | end |
| 46 | end |
| 47 | |
| 48 | fn main to int |
| 49 | if ne oargc 6 |
| 50 | ret 2 |
| 51 | end |
| 52 | aa = oargu 4 |
| 53 | ss = oargu 5 |
| 54 | if or or lt aa 500 gt aa 1200 or lt ss 800 gt ss 1200 |
| 55 | ret 51 |
| 56 | end |
| 57 | weempty |
| 58 | ockload 1 |
| 59 | for i ulong 7 |
| 60 | put wesh i get og i |
| 61 | end |
| 62 | put wesh 7 get og 40 |
| 63 | put wesh 8 get og 41 |
| 64 | p = get og 8 |
| 65 | nc = div add p 65535 65536 |
| 66 | for c ulong nc |
| 67 | st = mul c 65536 |
| 68 | en = add st 65536 |
| 69 | if gt en p |
| 70 | en = p |
| 71 | end |
| 72 | for j ulong sub en st |
| 73 | i = add st j |
| 74 | ogrp i owg i |
| 75 | end |
| 76 | end |
| 77 | ockload 2 |
| 78 | for i ulong 7 |
| 79 | if ne get wesh i get og i |
| 80 | ret 53 |
| 81 | end |
| 82 | end |
| 83 | if ne get wesh 7 get og 40 |
| 84 | ret 53 |
| 85 | end |
| 86 | if gt get wesh 8 get og 41 |
| 87 | ret 53 |
| 88 | end |
| 89 | wemix div f64 aa 1000.0 div f64 ss 1000.0 |
| 90 | ocksave 3 |
| 91 | oputc 87 |
| 92 | oputc 32 |
| 93 | oputu get og 8 |
| 94 | oputc 32 |
| 95 | oputu aa |
| 96 | oputc 32 |
| 97 | oputu ss |
| 98 | oputc 10 |
| 99 | oflush |
| 100 | ret 0 |
| 101 | end |