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