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 / omegallm / gpu / batch.om

181 lines · 4398 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Compose context.om, vector.om, launch.om, batch.om. No alternate driver or queue.
3note Bodies are produced by gbbody, or an equivalent INLINE/DMA body WITHOUT gbtail.
4note Every body has a WFI release and full shader invalidation before the next body.
5note QMD/bank updates are inline DMA, never CPU overwrites while the GPU reads them.
6note Source: class/clc96f.h:75-87 RELEASE_WFI_EN; om/streams/streams.om INVALL.
7note All gbmem allocations and code/data operands stay live and immutable until completion.
8note No reset, append, free or retry after uncertain completion: nvfault remains latched.
9global gbst ulong 8
10note gbst: expected, recorded, bytes, phase(0 idle,1 recording,2 in-flight,3 poison),
11note bad index(count means final tail), bad caller id, kicks, waits.
12global gbids ulong 512
13global gbpkt long 1
14fn gbberr idx ulong id ulong err long to bool
15put gbst 4 idx
16put gbst 5 id
17put gbst 3 3
18put nverr 0 err
19ret false
20end
21note Allocate once after opening the context. GPU-uncached packet storage.
22fn gbbopen to bool
23if ne get nvfault 0 0
24ret false
25end
26if gt get gbpkt 0 0
27ret true
28end
29m = nvalloc 1048576 false
30if le m 0
31ret false
32end
33put gbpkt 0 m
34ret true
35end
36note Count admission precedes body recording or any send. A bad append poisons the whole batch.
37fn gbbegin count ulong to bool
38if or ne get nvfault 0 0 eq get gbst 3 2
39ret false
40end
41if or eq count 0 gt count 512
42ret gbberr 0 0 -75
43end
44if le get gbpkt 0 0
45ret gbberr 0 0 -22
46end
47put gbst 0 count
48put gbst 1 0
49put gbst 2 0
50put gbst 3 1
51put gbst 4 18446744073709551615
52put gbst 5 0
53put gbst 6 0
54put gbst 7 0
55ret true
56end
57note Copy directly into the persistent submit mapping, not through a second megabyte buffer.
58fn gbbcopy to bool
59n = get gbused 0
60base = get gbst 2
61r = mapwrite get gbpkt 0 base gbcmd 0 n
62if ne r long n
63ret gbberr get gbst 1 0 -5
64end
65put gbst 2 add base n
66ret true
67end
68note dep = zero for none, or producer index+1. Only already-recorded producers are admissible.
69fn gbappend id ulong dep ulong to bool
70idx = get gbst 1
71if or ne get gbst 3 1 ne get nvfault 0 0
72ret false
73end
74if ge idx get gbst 0
75ret gbberr idx id -75
76end
77if gt dep idx
78ret gbberr idx id -22
79end
80n = get gbused 0
81if or or eq n 0 gt n 65536 ne rem n 4 0
82ret gbberr idx id -22
83end
84note Reserve seam release/invalidate (32 bytes) and unchanged tail (68 bytes) before copying.
85if gt n sub ulong 1048476 get gbst 2
86ret gbberr idx id -75
87end
88if not gbbcopy
89ret false
90end
91put gbids idx id
92if gt get gbst 0 1
93put gbused 0 0
94va = add mapaddr get gbmem 3 add ulong 32 mul idx 4
95gbrel va 6
96note Full shader invalidation after the WFI release has drained this grid.
97gbmth 1 540 1
98gbemit 4113
99if not gbbcopy
100ret false
101end
102end
103put gbst 1 add idx 1
104ret true
105end
106note Scan seals without waiting. Blame FIRST uncompleted index and the caller's kernel id.
107note Tail timeout with all seals complete is count, not a fabricated kernel failure.
108fn gbbcheck to bool
109n = get gbst 0
110if gt n 1
111for i ulong n
112if ne mapget get gbmem 3 add ulong 32 mul i 4 4 6
113put gbst 4 i
114put gbst 5 get gbids i
115ret false
116end
117end
118else
119if ne mapget get gbmem 2 8192 4 6
120put gbst 4 0
121put gbst 5 get gbids 0
122ret false
123end
124end
125put gbst 4 n
126put gbst 5 0
127ret true
128end
129note Existing nvwait is sleep-polling: never spin or inherit a process spin window.
130note One nvsend and one nvwait. The second marker follows the unchanged C3 L2 flush.
131fn gbbsubmit budget ulong to bool
132if or ne get gbst 3 1 ne get nvfault 0 0
133ret false
134end
135if ne get gbst 1 get gbst 0
136ret gbberr get gbst 1 0 -22
137end
138if or eq budget 0 gt budget 30000000000
139ret gbberr get gbst 1 0 -22
140end
141put gbused 0 0
142gbtail
143if not gbbcopy
144ret false
145end
146r = mapset get gbmem 2 8192 4 0
147r = mapset get gbmem 3 0 4 0
148r = mapset get gbmem 3 16 4 0
149for i ulong get gbst 0
150r = mapset get gbmem 3 add ulong 32 mul i 4 4 0
151end
152n = get gbst 2
153put gbst 3 2
154put nvstage 0 41
155if not nvsend get gbpkt 0 0 uint div n 4
156note Conservative fail-stop even if the driver refused before its doorbell.
157put nvfault 0 1
158put gbst 3 3
159ret false
160end
161put gbst 6 1
162put gbst 7 1
163put nvstage 0 42
164if not nvwait get gbmem 3 16 1179010630 budget
165ok = gbbcheck
166put nvfault 0 1
167put gbst 3 3
168ret false
169end
170ok = gbbcheck
171if or not ok ne mapget get gbmem 3 0 4 1145324612
172put nvfault 0 1
173put gbst 3 3
174put nverr 0 -5
175ret false
176end
177put gbst 3 0
178put gbst 4 18446744073709551615
179put nvstage 0 43
180ret true
181end