interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-train / tests / adtrain / replay / ckforge.om

141 lines · 2684 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note ckforge: forge one adtrain.ck variant with a VALID FNV-1a 64 checksum, so
3note each structural check of native/adtrain/mlp.om ckcheck is reached on its own
4note (a plain byte flip only ever reaches the checksum check).
5note stdin: one ASCII mode byte, then the 536-byte image. stdout: 536 bytes.
6note Image (docs/adtrain/CONTRACT.md): u64 LE words 0 magic, 1 version, 2 step,
7note 3 count, 4 lr bits, 5 loss bits, 6 data hash, 7 zero, 8..65 params, 66 FNV.
8note Modes, each changing one field and then re-checksumming bytes 0..527:
9note 0 nothing (positive control: must reproduce the input byte for byte)
10note m magic byte 0 xor 1 v version 2 s step 201 S step 200
11note c count 57 l lr bits + 1 p word 7 = 1
12note u param 0 bit 32 set n param 0 = NaN i param 0 = +Inf
13note h data hash xor 1
14note x checksum byte 528 xor 1, NOT re-checksummed (checksum-only image)
15note Exits: 0 done, 74 I/O, 75 bad input or mode.
16note Independent of mlp.om: its own FNV-1a 64 (offset 14695981039346656037,
17note prime 1099511628211) and its own word codec.
18global CB uchar 1024
19global CN ulong 1
20
21fn slurp to void
22p = ulong 0
23reading = true
24while reading bound 1025
25if eq p 1024
26exit 75
27end
28n = read 0 CB p sub 1024 p
29if eq n 0
30reading = false
31else
32if lt n 0
33exit 74
34end
35p = add p ulong n
36end
37end
38put CN 0 p
39end
40
41note word w of the image (the image starts at CB 1, after the mode byte)
42fn wget w ulong to ulong
43v = ulong 0
44b = add 1 mul w 8
45for i ulong 8
46v = or v shl ulong get CB add b i mul i 8
47end
48ret v
49end
50
51fn wput w ulong v ulong to void
52b = add 1 mul w 8
53for i ulong 8
54put CB add b i uchar and shr v mul i 8 255
55end
56end
57
58fn fnv to ulong
59h = ulong 14695981039346656037
60for i ulong 528
61h = mul xor h ulong get CB add 1 i 1099511628211
62end
63ret h
64end
65
66note apply mode m; returns false for an unknown mode
67fn apply m uchar to bool
68if eq m 48
69ret true
70end
71if eq m 109
72put CB 1 xor get CB 1 1
73ret true
74end
75if eq m 118
76wput 1 2
77ret true
78end
79if eq m 115
80wput 2 201
81ret true
82end
83if eq m 83
84wput 2 200
85ret true
86end
87if eq m 99
88wput 3 57
89ret true
90end
91if eq m 108
92wput 4 add wget 4 1
93ret true
94end
95if eq m 112
96wput 7 1
97ret true
98end
99if eq m 117
100wput 8 or wget 8 4294967296
101ret true
102end
103if eq m 110
104wput 8 2143289344
105ret true
106end
107if eq m 105
108wput 8 2139095040
109ret true
110end
111if eq m 104
112wput 6 xor wget 6 1
113ret true
114end
115ret false
116end
117
118fn main to int
119slurp
120if ne get CN 0 537
121ret 75
122end
123m = get CB 0
124if eq m 120
125put CB 529 xor get CB 529 1
126else
127if not apply m
128ret 75
129end
130wput 66 fnv
131end
132o = ulong 0
133while lt o 536 bound 537
134w = write 1 CB add 1 o sub 536 o
135if le w 0
136ret 74
137end
138o = add o ulong w
139end
140ret 0
141end