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/CUDApp/blob/main/om/tools/own30b_prof.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. 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 `CUDApp / om / tools / own30b_prof.om` 314 lines · 6446 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note own30b_prof: OWN-30B decode profile recorder decisions and dump text (tools/own30b_decode_profile.c). 3 note The C wrap stays C: it reads the clock, calls the real launch and writes stderr. This unit owns the 4 note launch classifier, the 48 x 6 + head sequence check, the token table and the dump lines. 5 note State st (ulong 155712): 0 used, 1 dropped, 2 armed, 3 invalid, 4 last_end, 5 classify bytes out. 6 note pending token at 8, tokens t at 64 + 38 t; in a token, row s field f at 5 s + f (f 0 calls, 1 bytes, 7 note 2 session_ns, 3 submit_wait_ns, 4 gap_before_ns), 35 end_ns, 36 start_ns, 37 pos. 8 note Stages: 0 qkv, 1 attention, 2 o, 3 router, 4 gate_up, 5 down, 6 lm_head, 7 other. 9 note op 0 classify a = has_args n_args args8 grid_y num_elements args18 fp8w dattnw routerw bf16w: 10 note returns the stage, bytes in st 5. op 1 record a = s bytes begin end elapsed rc_nonzero. 11 note op 2 dump header, op 3 dump token a 0: bytes written to o, returned. op 4 reads st word a 0. 12 const OWTOK ulong 38 13 const OWTOK0 ulong 64 14 const OWNTOK ulong 4096 15 const OWHEAD ulong 6 16 const OWOTHER ulong 7 17 fn ow_s o edit uchar 2048 p ulong w ulong n ulong to ulong 18 i = ulong 0 19 while lt i n bound 9 20 b = and shr w mul i 8 255 21 put o add p i uchar b 22 i = add i 1 23 end 24 ret add p n 25 end 26 fn ow_u o edit uchar 2048 p ulong v ulong to ulong 27 t = new uchar 20 0 28 n = ulong 0 29 x = v 30 while true bound 21 31 put t n uchar add 48 rem x 10 32 n = add n 1 33 x = div x 10 34 if eq x 0 35 break 36 end 37 end 38 q = p 39 while gt n 0 bound 21 40 n = sub n 1 41 put o q get t n 42 q = add q 1 43 end 44 ret q 45 end 46 fn ow_name o edit uchar 2048 p ulong s ulong to ulong 47 if eq s 0 48 note s "qkv" 49 p = ow_s o p `7760753` 3 50 ret p 51 end 52 if eq s 1 53 note s "attention" 54 p = ow_s o p `8028075828261975137` 8 55 p = ow_s o p 110 1 56 ret p 57 end 58 if eq s 2 59 note s "o" 60 p = ow_s o p 111 1 61 ret p 62 end 63 if eq s 3 64 note s "router" 65 p = ow_s o p `125780071116658` 6 66 ret p 67 end 68 if eq s 4 69 note s "gate_up" 70 p = ow_s o p `31654249976062311` 7 71 ret p 72 end 73 if eq s 5 74 note s "down" 75 p = ow_s o p `1853321060` 4 76 ret p 77 end 78 note s "lm_head" 79 p = ow_s o p `28254585841741164` 7 80 ret p 81 end 82 fn ow_fp8 st edit ulong 155712 a view ulong 16 to ulong 83 n = div get a 2 4 84 g = get a 3 85 s = OWOTHER 86 k = ulong 0 87 if eq g 1 88 if eq n 5120 89 s = 0 90 k = 2048 91 end 92 if eq n 2048 93 s = 2 94 k = 4096 95 end 96 end 97 if eq g 8 98 if eq n 1536 99 s = 4 100 k = 2048 101 end 102 if eq n 2048 103 s = 5 104 k = 768 105 end 106 end 107 if ne s OWOTHER 108 put st 5 mul mul g n k 109 end 110 ret s 111 end 112 fn ow_class st edit ulong 155712 a view ulong 16 to ulong 113 put st 5 0 114 if eq get a 0 0 115 ret OWOTHER 116 end 117 na = get a 1 118 if eq na get a 6 119 ret ow_fp8 st a 120 end 121 nel = get a 4 122 if eq na get a 7 123 if eq nel 4096 124 put st 5 mul 2048 add get a 5 1 125 ret 1 126 end 127 end 128 if eq na get a 8 129 if eq nel 2048 130 put st 5 524288 131 ret 3 132 end 133 end 134 if eq na get a 9 135 if eq nel 151936 136 put st 5 `622329856` 137 ret OWHEAD 138 end 139 end 140 ret OWOTHER 141 end 142 fn ow_row st edit ulong 155712 a view ulong 16 to void 143 s = get a 0 144 r = add 8 mul s 5 145 beg = get a 2 146 fin = get a 3 147 put st r add get st r 1 148 r = add r 1 149 put st r add get st r get a 1 150 r = add r 1 151 put st r add get st r sub fin beg 152 r = add r 1 153 put st r add get st r get a 4 154 r = add r 1 155 put st r add get st r sub beg get st 4 156 put st 45 add get st 45 1 157 end 158 fn ow_keep st edit ulong 155712 fin ulong to void 159 put st 43 fin 160 used = get st 0 161 if lt used OWNTOK 162 d = add OWTOK0 mul used OWTOK 163 for i ulong OWTOK 164 put st add d i get st add 8 i 165 end 166 put st 0 add used 1 167 else 168 put st 1 add get st 1 1 169 end 170 end 171 fn ow_rec st edit ulong 155712 a view ulong 16 to void 172 s = get a 0 173 fin = get a 3 174 rc = get a 5 175 pos = get st 45 176 if ne get st 2 0 177 ex = OWHEAD 178 if lt pos 288 179 ex = rem pos 6 180 end 181 if ne rc 0 182 put st 3 1 183 end 184 if ne s ex 185 put st 3 1 186 end 187 if gt pos 288 188 put st 3 1 189 end 190 if eq get st 3 0 191 ow_row st a 192 end 193 end 194 if eq s OWHEAD 195 if ne get st 2 0 196 if eq get st 3 0 197 if eq get st 45 289 198 ow_keep st fin 199 end 200 end 201 end 202 for i ulong OWTOK 203 put st add 8 i 0 204 end 205 put st 44 fin 206 put st 2 0 207 if eq rc 0 208 put st 2 1 209 end 210 put st 3 0 211 end 212 put st 4 fin 213 end 214 fn ow_head st edit ulong 155712 o edit uchar 2048 to ulong 215 p = ulong 0 216 note s "DECODE_PROFILE semantics=host_session_and_submit_wait weight_bytes_exclude_scales pure_gpu_time=UNKNOWN tokens=" 217 p = ow_s o p `5791423805511648580` 8 218 p = ow_s o p `8295706707565629266` 8 219 p = ow_s o p `8314605285845069157` 8 220 p = ow_s o p `7310291573909973053` 8 221 p = ow_s o p `7953743344833229683` 8 222 p = ow_s o p `8388356050598977380` 8 223 p = ow_s o p `7311348204415579999` 8 224 p = ow_s o p `8392847542696044393` 8 225 p = ow_s o p `8461247168670298981` 8 226 p = ow_s o p `7308323375080760676` 8 227 p = ow_s o p `7448783850965049459` 8 228 p = ow_s o p `4424062508652787056` 8 229 p = ow_s o p `2327894055524716117` 8 230 p = ow_s o p `17296891564486516` 7 231 p = ow_u o p get st 0 232 note s " dropped=" 233 p = ow_s o p `7234312004648985632` 8 234 p = ow_s o p 61 1 235 p = ow_u o p get st 1 236 note s "\n" 237 p = ow_s o p 10 1 238 ret p 239 end 240 fn ow_stage st edit ulong 155712 o edit uchar 2048 p ulong t ulong s ulong to ulong 241 note s "DECODE_STAGE token=" 242 p = ow_s o p `6007596587625432388` 8 243 p = ow_s o p `7741533966423245140` 8 244 p = ow_s o p `4025957` 3 245 p = ow_u o p t 246 note s " stage=" 247 p = ow_s o p `17281468270408480` 7 248 p = ow_name o p s 249 r = add add OWTOK0 mul t OWTOK mul s 5 250 note s " calls=" 251 p = ow_s o p `17296883091333920` 7 252 p = ow_u o p get st r 253 note s " bytes=" 254 p = ow_s o p `17296853162353184` 7 255 p = ow_u o p get st add r 1 256 note s " session_ns=" 257 p = ow_s o p `7957695011165139744` 8 258 p = ow_s o p `1030975071` 4 259 p = ow_u o p get st add r 2 260 note s " submit_wait_ns=" 261 p = ow_s o p `6878238449425806112` 8 262 p = ow_s o p `4428004214889341303` 8 263 p = ow_u o p get st add r 3 264 note s " gap_before_ns=" 265 p = ow_s o p `7378411726563272480` 8 266 p = ow_s o p `17296891463430767` 7 267 p = ow_u o p get st add r 4 268 note s "\n" 269 p = ow_s o p 10 1 270 ret p 271 end 272 fn ow_tok st edit ulong 155712 o edit uchar 2048 t ulong to ulong 273 p = ulong 0 274 d = add OWTOK0 mul t OWTOK 275 note s "DECODE_TOKEN token=" 276 p = ow_s o p `6079654181663360324` 8 277 p = ow_s o p `7741533966574111567` 8 278 p = ow_s o p `4025957` 3 279 p = ow_u o p t 280 note s " wall_ns=" 281 p = ow_s o p `8317690481079318304` 8 282 p = ow_s o p 61 1 283 p = ow_u o p sub get st add d 35 get st add d 36 284 note s " launches=" 285 p = ow_s o p `7307199721475501088` 8 286 p = ow_s o p 15731 2 287 p = ow_u o p get st add d 37 288 note s "\n" 289 p = ow_s o p 10 1 290 for s ulong 7 291 p = ow_stage st o p t s 292 end 293 ret p 294 end 295 fn own30b_prof op ulong st edit ulong 155712 a view ulong 16 o edit uchar 2048 to ulong 296 if eq op 0 297 ret ow_class st a 298 end 299 if eq op 1 300 ow_rec st a 301 ret 0 302 end 303 if eq op 2 304 ret ow_head st o 305 end 306 if eq op 3 307 t = get a 0 308 if lt t get st 0 309 ret ow_tok st o t 310 end 311 ret 0 312 end 313 ret get st get a 0 314 end