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 / evidence / ECOSYSTEM6 / ref32-review / mul-corpus.om

150 lines · 2544 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Native IEEE binary32 multiplication represented as bits; no host floating runtime.
3note Round-to-nearest ties-to-even, gradual underflow, signed zeros and infinities.
4note Canonical positive quiet NaN for every NaN result. Inputs are low32 bits.
5fn mround x ulong shift ulong to ulong
6if eq shift 0
7ret x
8end
9if gt shift 63
10ret 0
11end
12q = shr x shift
13mask = sub shl 1 shift 1
14r = and x mask
15half = shl 1 sub shift 1
16if or gt r half and eq r half ne and q 1 0
17q = add q 1
18end
19ret q
20end
21fn mul32 aa ulong bb ulong to ulong
22a = and aa 4294967295
23b = and bb 4294967295
24sign = and xor a b 2147483648
25ea = long and shr a 23 255
26eb = long and shr b 23 255
27ma = and a 8388607
28mb = and b 8388607
29if or and eq ea 255 ne ma 0 and eq eb 255 ne mb 0
30ret 2143289344
31end
32if or eq ea 255 eq eb 255
33if or eq and a 2147483647 0 eq and b 2147483647 0
34ret 2143289344
35end
36ret or sign 2139095040
37end
38if or eq and a 2147483647 0 eq and b 2147483647 0
39ret sign
40end
41if eq ea 0
42ea = 1
43while lt ma 8388608
44ma = shl ma 1
45ea = sub ea 1
46end
47else
48ma = or ma 8388608
49end
50if eq eb 0
51eb = 1
52while lt mb 8388608
53mb = shl mb 1
54eb = sub eb 1
55end
56else
57mb = or mb 8388608
58end
59product = mul ma mb
60e = sub add ea eb 127
61shift = long 23
62if ge product 140737488355328
63shift = 24
64e = add e 1
65end
66if lt e 1
67shift = add shift sub 1 e
68e = 0
69end
70q = mround product ulong shift
71if eq e 0
72if ge q 8388608
73e = 1
74end
75else
76if ge q 16777216
77q = shr q 1
78e = add e 1
79end
80end
81if ge e 255
82ret or sign 2139095040
83end
84q = and q 8388607
85e = shl e 23
86q = or q ulong e
87ret or sign q
88end
89note SPDX-License-Identifier: AGPL-3.0-only
90global failed ulong 1
91global tested ulong 1
92global line uchar 48
93fn report ok bool to void
94id = add get tested 0 1
95put tested 0 id
96put line 0 48
97put line 1 uchar add 48 rem div id 100 10
98put line 2 uchar add 48 rem div id 10 10
99put line 3 uchar add 48 rem id 10
100put line 4 32
101put line 5 48
102if not ok
103put line 5 49
104put failed 0 add get failed 0 1
105end
106put line 6 10
107w = write 1 line 0 7
108if ne w 7
109exit 74
110end
111end
112note Native corpus runner. Each record is a,b,expected IEEE binary32 LE bits.
113global record uchar 12
114fn mword p ulong to ulong
115v = ulong 0
116for i ulong 4
117v = or v shl ulong get record add p i mul i 8
118end
119ret v
120end
121fn main to int
122while true
123p = ulong 0
124while lt p 12
125n = read 0 record p sub 12 p
126if eq n 0
127if ne p 0
128ret 74
129end
130if ne get failed 0 0
131ret 1
132end
133ret 0
134end
135if eq n -4
136n = 0
137else
138if lt n 0
139ret 74
140end
141end
142p = add p ulong n
143end
144a = mword 0
145b = mword 4
146wanted = mword 8
147report eq mul32 a b wanted
148end
149ret 0
150end