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 / native / ecosystem6 / affine.om

165 lines · 2842 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Bounded host FP32 consumer. Uses external pinned L720 add32/mul32 and M20 emcheck.
3note Eight independent tensors X,W,b,T,Y,dX,dW,db in 16-cell slots.
4note Values are IEEE binary32 bits in ulong carriers, not integer fixed-point values.
5note AD/AS are trusted local descriptor and allocator snapshots, not wire records.
6global AD ulong 192
7global AS ulong 64
8global AP ulong 128
9global AQ ulong 128
10global AL ulong 1
11
12fn afcount t ulong to ulong
13if or eq t 2 eq t 7
14ret 2
15end
16if or eq t 3 eq t 4
17ret 4
18end
19ret 6
20end
21
22fn afget t ulong i ulong to ulong
23ret get AP add mul t 16 i
24end
25
26fn afq t ulong i ulong to ulong
27ret get AQ add mul t 16 i
28end
29
30fn afput t ulong i ulong v ulong to void
31put AQ add mul t 16 i v
32end
33
34fn affinite x ulong to bool
35if gt x 4294967295
36ret false
37end
38ret lt and x 2147483647 2139095040
39end
40
41fn afvalidate to int
42for t ulong 8
43for i ulong 24
44put ED i get AD add mul t 24 i
45end
46for i ulong 8
47put ES i get AS add mul t 8 i
48end
49status = emcheck
50if ne status 0
51ret status
52end
53note Contiguous owned local carriers only. This does not claim strided numeric kernels.
54if or ne get ED 1 1 ne get ED 4 0
55ret -20
56end
57if or ne get ED 5 add t 1 ne get ES 5 afcount t
58ret -20
59end
60rank = ulong 2
61rows = ulong 2
62cols = ulong 3
63if or eq t 1 eq t 6
64rows = 3
65cols = 2
66end
67if or eq t 3 eq t 4
68cols = 2
69end
70if or eq t 2 eq t 7
71rank = 1
72cols = 1
73end
74if or ne get ED 2 rank ne get ED 8 rows
75ret -21
76end
77if ne get ED 16 cols
78ret -21
79end
80if eq rank 2
81if or ne get ED 9 cols ne get ED 17 1
82ret -21
83end
84end
85end
86ret 0
87end
88
89fn afstep lr ulong to int
90status = afvalidate
91if ne status 0
92ret status
93end
94if not affinite lr
95ret -22
96end
97if ne and lr 2147483648 0
98ret -22
99end
100for t ulong 4
101for i ulong afcount t
102if not affinite afget t i
103ret -22
104end
105end
106end
107for i ulong 128
108put AQ i 0
109end
110loss = ulong 0
111for row ulong 2
112for col ulong 2
113v = afget 2 col
114for k ulong 3
115x = afget 0 add mul row 3 k
116w = afget 1 add mul k 2 col
117v = add32 v mul32 x w
118end
119pos = add mul row 2 col
120afput 4 pos v
121r = add32 v xor afget 3 pos 2147483648
122loss = add32 loss mul32 r r
123g = mul32 1073741824 r
124afput 7 col add32 afq 7 col g
125for k ulong 3
126xp = add mul row 3 k
127wp = add mul k 2 col
128gx = mul32 g afget 1 wp
129gw = mul32 g afget 0 xp
130afput 5 xp add32 afq 5 xp gx
131afput 6 wp add32 afq 6 wp gw
132end
133end
134end
135note Commit only after all finite-result checks; rejected steps preserve AP and AL.
136for i ulong 6
137delta = mul32 lr afq 6 i
138afput 1 i add32 afget 1 i xor delta 2147483648
139end
140for i ulong 2
141delta = mul32 lr afq 7 i
142afput 2 i add32 afget 2 i xor delta 2147483648
143end
144if not affinite loss
145ret -23
146end
147for t ulong 8
148if and ne t 0 ne t 3
149for i ulong afcount t
150if not affinite afq t i
151ret -23
152end
153end
154end
155end
156for t ulong 8
157if and ne t 0 ne t 3
158for i ulong afcount t
159put AP add mul t 16 i afq t i
160end
161end
162end
163put AL 0 loss
164ret 0
165end