interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / tools / artexp.om

962 lines · 22679 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note artexp: the decisions of tools/artifact_export.c (offline handoff of one CUDApp GPU realization).
3note This unit reads the command line one argument at a time, checks it against the frozen v1
4note contracts, picks the kernel and its launch shape, writes the attention semantic-spec text, the
5note manifest strings and every message, and decides the exit status. The C shell keeps the library
6note calls (spec init, code generation, cbank arguments, SHA-256, register declaration, QMD templates,
7note export) and the writes to stdout and stderr; it calls them when this unit asks.
8note facts f (ulong 8): 0 OMEGA_GPU_MATMUL_MAX_CTAS, 1 OMEGA_ARTIFACT_OK.
9note token t: the shell copies argv[s 1] (NUL included, at most 131072 bytes) when asked (return 1), the
10note 32 hash bytes (returns 6, 9), or after the export the NUL-separated texts (return 14).
11note state s (ulong 128, all 0 at the start; the shell writes 2 and 3 once, 18, 21..24 after calls):
12note 0 phase, 1 argument index, 2 length of argv[s 1], 3 argc, 4 pending flag, 5 mode (1 matmul,
13note 2 attention), 6 --out index, 7 --contract-id index, 8 its length is 64, 9 the frozen id it names
14note (1 matmul-bf16-v1, 2 gqa-causal-v1), 10 --commit index, 11 its length is 40, 12 it is lowercase
15note hex, 13 m, 14 k, 15 n, 16 q-heads, 17 kv-heads, 18 rc of the last call (int64 bits), 19 grid x of
16note the matmul, 20 log2 GQA, 21 heads per CTA, 22 register peak, 23 declared registers, 24 declared ok,
17note 25 exit status; QMD config 32 threads per block, 33 threads x, 34 grid x, 35 grid y,
18note 36 elements, 37 shared bytes, 38 registers; manifest 40 grid x, 41 grid y, 42..44 block x y z,
19note 45 shared bytes, 46 cbank words, 47 parameter count; 64..75 parameters (offset | size << 16 |
20note pointer << 32); 80..83 the semantic spec id (32 bytes, little-endian words).
21note Returns: 1 load argv[s 1] into t and s 2; 2 + 256 * length: o to stderr, exit s 25;
22note 3 omega_matmul_spec_init(m, k, n, BF16); 4 omega_blackwell_codegen_matmul; 5 ..._matmul_tensor_loop
23note with grid s 19; 6 the spec id into t; 7 the matmul cbank arguments; 8 the attention code with
24note log2 GQA s 20; 9 + 256 * length: SHA-256 of o into t; 10 heads per CTA into s 21; 11 cbank word 14 =
25note q-heads; 12 registers into s 22..24; 13 the QMD templates (rc 1 when either refuses); 14 the export
26note with the 13 NUL-separated manifest texts in o; 15 + 256 * length: o to stdout, exit 0; 0 abort.
27fn ae_s o edit uchar 262144 p ulong w ulong n ulong to ulong
28i = ulong 0
29while lt i n bound 9
30put o add p i uchar and shr w mul i 8 255
31i = add i 1
32end
33ret add p n
34end
35fn ae_nd v ulong to ulong
36n = ulong 1
37x = div v 10
38while ne x 0 bound 20
39n = add n 1
40x = div x 10
41end
42ret n
43end
44fn ae_u o edit uchar 262144 p ulong v ulong to ulong
45w = ae_nd v
46k = add p w
47x = v
48for i ulong w
49k = sub k 1
50put o k uchar add 48 rem x 10
51x = div x 10
52end
53ret add p w
54end
55note ae_d: %d of an int held as int64 bits.
56fn ae_d o edit uchar 262144 p ulong v ulong to ulong
57if ne and shr v 63 1 0
58put o p uchar 45
59ret ae_u o add p 1 sub ulong 0 v
60end
61ret ae_u o p v
62end
63note ae_cp: the NUL-terminated text of t at at, appended at p; returns p after it.
64fn ae_cp o edit uchar 262144 p ulong t view uchar 262144 at ulong to ulong
65q = p
66i = at
67while lt i 262144 bound 262144
68c = get t i
69if eq c uchar 0
70break
71end
72put o q c
73q = add q 1
74i = add i 1
75end
76ret q
77end
78note ae_skip: the offset after the NUL-terminated text of t at at.
79fn ae_skip t view uchar 262144 at ulong to ulong
80i = at
81while lt i 262144 bound 262144
82if eq get t i uchar 0
83ret add i 1
84end
85i = add i 1
86end
87ret i
88end
89fn ae_m8 t view uchar 262144 pos ulong w ulong n ulong to ulong
90for i ulong n
91if ne ulong get t add pos i and shr w mul i 8 255
92ret ulong 0
93end
94end
95ret ulong 1
96end
97note ae_hx: the value of a hex digit, 99 for any other byte.
98fn ae_hx c ulong to ulong
99if and ge c 48 le c 57
100ret sub c 48
101end
102if and ge c 97 le c 102
103ret sub c 87
104end
105if and ge c 65 le c 70
106ret sub c 55
107end
108ret ulong 99
109end
110fn ae_sp c ulong to ulong
111if eq c 32
112ret ulong 1
113end
114if and ge c 9 le c 13
115ret ulong 1
116end
117ret ulong 0
118end
119note ae_num: num() of the C, strtoul(s, &e, 0) in the C locale kept when it ends the text and is at most
120note 0xffffffff, else 0: spaces, a sign, 0x/0X hex when a hex digit follows, 0 octal, decimal; an
121note overflow (ULONG_MAX) is 0; a minus sign negates modulo 2^64.
122fn ae_num t view uchar 262144 n ulong to ulong
123i = ulong 0
124while lt i n bound 262144
125if eq ae_sp ulong get t i 0
126break
127end
128i = add i 1
129end
130ng = ulong 0
131if lt i n
132c = ulong get t i
133if eq c 43
134i = add i 1
135end
136if eq c 45
137ng = ulong 1
138i = add i 1
139end
140end
141b = ulong 10
142if lt i n
143if eq get t i uchar 48
144b = ulong 8
145if lt add i 2 n
146c = ulong get t add i 1
147if or eq c 120 eq c 88
148if lt ae_hx ulong get t add i 2 16
149b = ulong 16
150i = add i 2
151end
152end
153end
154end
155end
156st = i
157v = ulong 0
158ov = ulong 0
159while lt i n bound 262144
160d = ae_hx ulong get t i
161if ge d b
162break
163end
164if gt v div sub sub ulong 0 1 d b
165ov = ulong 1
166end
167v = add mul v b d
168i = add i 1
169end
170if or eq i st ne i n
171ret ulong 0
172end
173if ne ov 0
174ret ulong 0
175end
176if ne ng 0
177v = sub ulong 0 v
178end
179if gt v 4294967295
180ret ulong 0
181end
182ret v
183end
184note ae_flag: 1 --out, 2 --contract-id, 3 --commit, 4 --m, 5 --k, 6 --n, 7 --q-heads, 8 --kv-heads, 0 other.
185fn ae_flag t view uchar 262144 n ulong to ulong
186note s "--out"
187e = ulong 0
188if eq n 5
189e = ulong 1
190e = and e ae_m8 t 0 500186426669 5
191end
192if ne e 0
193ret ulong 1
194end
195note s "--contract-id"
196e = ulong 0
197if eq n 13
198e = ulong 1
199e = and e ae_m8 t 0 7021802786688019757 8
200e = and e ae_m8 t 8 431261316195 5
201end
202if ne e 0
203ret ulong 2
204end
205note s "--commit"
206e = ulong 0
207if eq n 8
208e = ulong 1
209e = and e ae_m8 t 0 8388356097741892909 8
210end
211if ne e 0
212ret ulong 3
213end
214note s "--m"
215e = ulong 0
216if eq n 3
217e = ulong 1
218e = and e ae_m8 t 0 7154989 3
219end
220if ne e 0
221ret ulong 4
222end
223note s "--k"
224e = ulong 0
225if eq n 3
226e = ulong 1
227e = and e ae_m8 t 0 7023917 3
228end
229if ne e 0
230ret ulong 5
231end
232note s "--n"
233e = ulong 0
234if eq n 3
235e = ulong 1
236e = and e ae_m8 t 0 7220525 3
237end
238if ne e 0
239ret ulong 6
240end
241note s "--q-heads"
242e = ulong 0
243if eq n 9
244e = ulong 1
245e = and e ae_m8 t 0 7233173974647123245 8
246e = and e ae_m8 t 8 115 1
247end
248if ne e 0
249ret ulong 7
250end
251note s "--kv-heads"
252e = ulong 0
253if eq n 10
254e = ulong 1
255e = and e ae_m8 t 0 7018130138796338477 8
256e = and e ae_m8 t 8 29540 2
257end
258if ne e 0
259ret ulong 8
260end
261ret ulong 0
262end
263fn ae_mode t view uchar 262144 n ulong to ulong
264note s "matmul"
265e = ulong 0
266if eq n 6
267e = ulong 1
268e = and e ae_m8 t 0 119251603317101 6
269end
270if ne e 0
271ret ulong 1
272end
273note s "attention"
274e = ulong 0
275if eq n 9
276e = ulong 1
277e = and e ae_m8 t 0 8028075828261975137 8
278e = and e ae_m8 t 8 110 1
279end
280if ne e 0
281ret ulong 2
282end
283ret ulong 0
284end
285fn ae_cid t view uchar 262144 n ulong to ulong
286note s "647116fc1ba1e1394982fc8ba181ce565293f160a6b56afc0f02b2128a675704"
287e = ulong 0
288if eq n 64
289e = ulong 1
290e = and e ae_m8 t 0 7162471842286351414 8
291e = and e ae_m8 t 8 4121692394664059441 8
292e = and e ae_m8 t 16 7077516104993093940 8
293e = and e ae_m8 t 24 3906139728515707233 8
294e = and e ae_m8 t 32 3474018477578727989 8
295e = and e ae_m8 t 40 7162519142831109729 8
296e = and e ae_m8 t 48 3616727373085435440 8
297e = and e ae_m8 t 56 3760566390553469240 8
298end
299if ne e 0
300ret ulong 1
301end
302note s "003696e422bba7274877ba9e01a61076ea0f862f32760cbaa06c60f85a115359"
303e = ulong 0
304if eq n 64
305e = ulong 1
306e = and e ae_m8 t 0 3775483481970389040 8
307e = and e ae_m8 t 8 3977302312323527218 8
308e = and e ae_m8 t 16 7293968145964283956 8
309e = and e ae_m8 t 24 3906644189691064624 8
310e = and e ae_m8 t 32 7364007956564697445 8
311e = and e ae_m8 t 40 7017280228115821107 8
312e = and e ae_m8 t 48 4063988723899314273 8
313e = and e ae_m8 t 56 4122257337479160117 8
314end
315if ne e 0
316ret ulong 2
317end
318ret ulong 0
319end
320fn ae_lhex t view uchar 262144 n ulong to ulong
321for i ulong n
322c = ulong get t i
323if not or and ge c 48 le c 57 and ge c 97 le c 102
324ret ulong 0
325end
326end
327ret ulong 1
328end
329note ae_val: the value after a flag.
330fn ae_val s edit ulong 128 t view uchar 262144 to ulong
331k = get s 4
332i = get s 1
333n = get s 2
334if eq k 1
335put s 6 i
336end
337if eq k 2
338put s 7 i
339put s 8 ulong 0
340if eq n 64
341put s 8 ulong 1
342end
343put s 9 ae_cid t n
344end
345if eq k 3
346put s 10 i
347put s 11 ulong 0
348if eq n 40
349put s 11 ulong 1
350end
351put s 12 ae_lhex t n
352end
353if ge k 4
354put s add 9 k ae_num t n
355end
356ret ulong 0
357end
358fn ae_usg o edit uchar 262144 p ulong to ulong
359note s "usage: artifact-export matmul --m M --k K --n N --contract-id HEX --out PREFIX --commit HEX\n"
360p = ae_s o p 6998658028134298485 8
361p = ae_s o p 3275352098986357874 8
362p = ae_s o p 7863412984233621605 8
363p = ae_s o p 3255293755857400929 8
364p = ae_s o p 2336010503560437869 8
365p = ae_s o p 2327833714973548619 8
366p = ae_s o p 7021802786688019757 8
367p = ae_s o p 4992275802573599843 8
368p = ae_s o p 2338623226871881816 8
369p = ae_s o p 3251696002696303184 8
370p = ae_s o p 2338610025220498221 8
371p = ae_s o p 173557064 4
372note s " artifact-export attention --q-heads H --kv-heads H --contract-id HEX --out PREFIX --commit HEX\n"
373p = ae_s o p 6998629143283769376 8
374p = ae_s o p 3275352098986357874 8
375p = ae_s o p 6998721855778486373 8
376p = ae_s o p 7957695015376221300 8
377p = ae_s o p 7018130138708389152 8
378p = ae_s o p 7722878552682558308 8
379p = ae_s o p 2338323001011350902 8
380p = ae_s o p 8389765627588190280 8
381p = ae_s o p 2334106150831874418 8
382p = ae_s o p 8462031896691885384 8
383p = ae_s o p 6361693212185206900 8
384p = ae_s o p 7596848471616597280 8
385p = ae_s o p 11374235754612 6
386ret p
387end
388note ae_exit: the text o 0..p - 1 to stderr and exit status e.
389fn ae_exit s edit ulong 128 p ulong e ulong to ulong
390put s 0 99
391put s 25 e
392ret add 2 shl p 8
393end
394fn ae_usage s edit ulong 128 o edit uchar 262144 to ulong
395ret ae_exit s ae_usg o 0 2
396end
397note ae_ctr: the commit and frozen-contract refusals; 0 when the arguments pass them.
398fn ae_ctr s edit ulong 128 o edit uchar 262144 to ulong
399if or or eq get s 6 0 eq get s 7 0 eq get s 8 0
400ret ae_usage s o
401end
402p = ulong 0
403if or eq get s 10 0 eq get s 11 0
404note s "--commit must be a 40-hex source revision\n"
405p = ae_s o p 8388356097741892909 8
406p = ae_s o p 7305437230073736480 8
407p = ae_s o p 7307140080464847136 8
408p = ae_s o p 7305808869231632504 8
409p = ae_s o p 8028074707559739936 8
410p = ae_s o p 2670 2
411ret ae_exit s ae_usg o p 2
412end
413if eq get s 12 0
414note s "--commit must be lowercase 40-hex\n"
415p = ae_s o p 8388356097741892909 8
416p = ae_s o p 7305437230073736480 8
417p = ae_s o p 7017578424494418976 8
418p = ae_s o p 7307140080464848243 8
419p = ae_s o p 2680 2
420ret ae_exit s p 2
421end
422md = get s 5
423if eq md 1
424if ne get s 9 1
425note s "contract id is not matmul-bf16-v1\n"
426p = ae_s o p 8386654075301556067 8
427p = ae_s o p 7935469438779025696 8
428p = ae_s o p 8461547236690523247 8
429p = ae_s o p 8515522056226483564 8
430p = ae_s o p 2609 2
431ret ae_exit s p 3
432end
433b = ulong 0
434if gt get s 13 8192
435b = ulong 1
436end
437if gt get s 14 16384
438b = ulong 1
439end
440if gt get s 15 8192
441b = ulong 1
442end
443if ne b 0
444note s "shape outside matmul-bf16-v1 bounds (m<=8192,k<=16384,n<=8192)\n"
445p = ae_s o p 8462017844901668979 8
446p = ae_s o p 7020303013988889460 8
447p = ae_s o p 3559640502715641204 8
448p = ae_s o p 8462090115260755254 8
449p = ae_s o p 4412521754026796142 8
450p = ae_s o p 4412519572481585464 8
451p = ae_s o p 4354466492506650161 8
452p = ae_s o p 2860045451737149 7
453ret ae_exit s p 3
454end
455end
456if eq md 2
457if ne get s 9 2
458note s "contract id is not gqa-causal-v1\n"
459p = ae_s o p 8386654075301556067 8
460p = ae_s o p 7935469438779025696 8
461p = ae_s o p 7146475323396224111 8
462p = ae_s o p 3564086098625000801 8
463p = ae_s o p 10 1
464ret ae_exit s p 3
465end
466b = ulong 0
467if gt get s 16 64
468b = ulong 1
469end
470if gt get s 17 64
471b = ulong 1
472end
473if ne b 0
474note s "heads outside gqa-causal-v1 bounds (hq<=64,hkv<=64)\n"
475p = ae_s o p 8462017904829883752 8
476p = ae_s o p 8171535668735472500 8
477p = ae_s o p 7809650176819408225 8
478p = ae_s o p 7959390383684810285 8
479p = ae_s o p 4412526427079996260 8
480p = ae_s o p 4412531938597549110 8
481p = ae_s o p 170472502 4
482ret ae_exit s p 3
483end
484end
485ret ulong 0
486end
487note ae_mm: the matmul shape checks; returns the spec-init request.
488fn ae_mm s edit ulong 128 o edit uchar 262144 to ulong
489m = get s 13
490k = get s 14
491n = get s 15
492if or or eq m 0 eq k 0 eq n 0
493ret ae_usage s o
494end
495b = ulong 0
496if ne rem m 16 0
497b = ulong 1
498end
499if ne rem n 8 0
500b = ulong 1
501end
502if ne rem k 16 0
503b = ulong 1
504end
505if ne b 0
506p = ulong 0
507note s "matmul-bf16-v1 export needs m%16 == 0, n%8 == 0, k%16 == 0 (got "
508p = ae_s o p 7074429841272234349 8
509p = ae_s o p 7286878580719890790 8
510p = ae_s o p 7308814929777094776 8
511p = ae_s o p 3904943502533026917 8
512p = ae_s o p 7935391128637750560 8
513p = ae_s o p 3184080383941556261 8
514p = ae_s o p 4412718627017812768 8
515p = ae_s o p 2338616595357642784 8
516p = ae_u o p m
517put o p uchar 120
518p = ae_u o add p 1 k
519put o p uchar 120
520p = ae_u o add p 1 n
521note s ")\n"
522p = ae_s o p 2601 2
523ret ae_exit s p 3
524end
525put s 0 5
526ret ulong 3
527end
528note ae_at: the attention head checks and the GQA ratio; returns the attention code request.
529fn ae_at s edit ulong 128 o edit uchar 262144 to ulong
530hq = get s 16
531hk = get s 17
532if or eq hq 0 eq hk 0
533ret ae_usage s o
534end
535if ne rem hq hk 0
536ret ae_usage s o
537end
538r = div hq hk
539l = ulong 0
540while lt shl ulong 1 l r bound 64
541l = add l 1
542end
543if ne shl ulong 1 l r
544p = ulong 0
545note s "GQA ratio is not a power of two\n"
546p = ae_s o p 7598805614076186951 8
547p = ae_s o p 8390045716468801647 8
548p = ae_s o p 8243126013477806368 8
549p = ae_s o p 751951003437657888 8
550ret ae_exit s p 3
551end
552put s 20 l
553put s 0 8
554ret ulong 8
555end
556note ae_chk: every check after the last argument.
557fn ae_chk s edit ulong 128 o edit uchar 262144 to ulong
558x = ae_ctr s o
559if ne x 0
560ret x
561end
562md = get s 5
563if eq md 1
564ret ae_mm s o
565end
566if eq md 2
567ret ae_at s o
568end
569ret ae_usage s o
570end
571fn ae_msg s edit ulong 128 o edit uchar 262144 w ulong n ulong to ulong
572p = ae_s o 0 w n
573ret ae_exit s p 3
574end
575fn ae_prm s edit ulong 128 i ulong off ulong sz ulong pt ulong to ulong
576put s add 64 i or or off shl sz 16 shl pt 32
577ret ulong 0
578end
579fn ae_cfg s edit ulong 128 tb ulong gx ulong gy ulong el ulong sh ulong to ulong
580put s 32 tb
581put s 33 tb
582put s 34 gx
583put s 35 gy
584put s 36 el
585put s 37 sh
586put s 40 gx
587put s 41 gy
588put s 42 tb
589put s 43 1
590put s 44 1
591put s 45 sh
592put s 0 10
593ret ulong 0
594end
595note ae_mmcfg: the matmul launch: CTA (x, y) over 16 x 8 tiles, 32 threads, 1024 shared bytes, three pointer
596note parameters at 0x380, 10 cbank words.
597fn ae_mmcfg s edit ulong 128 to ulong
598m = get s 13
599gy = div m 16
600el = and mul m get s 15 4294967295
601gx = get s 19
602x = ae_cfg s 32 gx gy el 1024
603put s 46 10
604put s 47 3
605for i ulong 3
606x = ae_prm s i add 896 mul i 8 8 1
607end
608ret ulong 7
609end
610note ae_atcfg: the attention launch: 128 threads, q-heads / heads-per-CTA CTAs, (3 * hpc + 1) * 128 * 4 shared
611note bytes, four pointers at 0x380 then eight u32 at 0x3a0, 16 cbank words.
612fn ae_atcfg s edit ulong 128 to ulong
613hq = get s 16
614hp = get s 21
615sh = add mul 3 hp 1
616sh = and mul sh 512 4294967295
617gx = div hq hp
618el = and mul hq 128 4294967295
619x = ae_cfg s 128 gx 1 el sh
620put s 46 16
621put s 47 12
622for i ulong 4
623x = ae_prm s i add 896 mul i 8 8 1
624end
625for i ulong 8
626x = ae_prm s add 4 i add 928 mul i 4 4 0
627end
628ret ulong 11
629end
630fn ae_spec s edit ulong 128 t view uchar 262144 to ulong
631for i ulong 4
632w = ulong 0
633for j ulong 8
634c = ulong get t add mul i 8 j
635w = or w shl c mul j 8
636end
637put s add 80 i w
638end
639ret ulong 0
640end
641note ae_stext: "omega-attention-spec/1\nhead_dim=128\nq_heads=%u\nkv_heads=%u\nlog2_gqa=%u\n", hashed by
642note the shell.
643fn ae_stext s edit ulong 128 o edit uchar 262144 to ulong
644p = ulong 0
645note s "omega-attention-spec/1\nhead_dim=128\nq_heads="
646p = ae_s o p 8386033877510352239 8
647p = ae_s o p 3273676477860570484 8
648p = ae_s o p 7496858609312428147 8
649p = ae_s o p 4426309888593125733 8
650p = ae_s o p 7307195334516027953 8
651p = ae_s o p 1030972513 4
652p = ae_u o p get s 16
653note s "\nkv_heads="
654p = ae_s o p 7233173975486327562 8
655p = ae_s o p 15731 2
656p = ae_u o p get s 17
657note s "\nlog2_gqa="
658p = ae_s o p 8171604718975413258 8
659p = ae_s o p 15713 2
660p = ae_u o p get s 20
661put o p uchar 10
662put s 0 9
663ret add 9 shl add p 1 8
664end
665fn ae_hex o edit uchar 262144 p ulong s view ulong 128 to ulong
666q = p
667for i ulong 32
668w = get s add 80 div i 8
669b = and shr w mul rem i 8 8 255
670for j ulong 2
671d = shr b mul sub 1 j 4
672d = and d 15
673if lt d 10
674put o q uchar add 48 d
675else
676put o q uchar add 87 d
677end
678q = add q 1
679end
680end
681put o q uchar 0
682ret add q 1
683end
684note ae_mmtx: the matmul manifest texts up to the bounds.
685fn ae_mmtx s edit ulong 128 o edit uchar 262144 to ulong
686p = ulong 0
687note s "matmul\0matmul-bf16-v1\0bf16\0fp32\0abs<=1e-5*max(1,abs(ref))\0m="
688p = ae_s o p 7854397001737462125 8
689p = ae_s o p 7377509083436119137 8
690p = ae_s o p 7377459352022365745 8
691p = ae_s o p 14130306676176433 8
692p = ae_s o p 3271074843431494241 8
693p = ae_s o p 3184370909023382069 8
694p = ae_s o p 2983183344158859873 8
695p = ae_s o p 1030553641 4
696p = ae_u o p get s 13
697note s ",k="
698p = ae_s o p 4025132 3
699p = ae_u o p get s 14
700note s ",n="
701p = ae_s o p 4025900 3
702p = ae_u o p get s 15
703note s "\0m<=8192,k<=16384,n<=8192\0"
704p = ae_s o p 3618977893184204032 8
705p = ae_s o p 4049640075044875052 8
706p = ae_s o p 4121136969678728244 8
707p = ae_s o p 50 2
708p = ae_hex o p s
709note s "omega_matmul_bf16\0"
710p = ae_s o p 7020372266091638127 8
711p = ae_s o p 3559640717464006004 8
712p = ae_s o p 54 2
713ret p
714end
715fn ae_attx s edit ulong 128 o edit uchar 262144 to ulong
716p = ulong 0
717note s "gqa-causal-attention\0gqa-causal-v1\0f32-kv\0fp32\0rel<=1e-3,abs<=1e-4\0r>=1,base=0,hq="
718p = ae_s o p 8319662965227876711 8
719p = ae_s o p 7954892360015244385 8
720p = ae_s o p 7021506545597770100 8
721p = ae_s o p 3273098177709957933 8
722p = ae_s o p 7722884132346278262 8
723p = ae_s o p 8214620916834238582 8
724p = ae_s o p 3687714932041477221 8
725p = ae_s o p 7291676601532703020 8
726p = ae_s o p 3184393749937533997 8
727p = ae_s o p 7506427719172972898 8
728p = ae_s o p 15729 2
729p = ae_u o p get s 16
730note s ",hkv="
731p = ae_s o p 263979755564 5
732p = ae_u o p get s 17
733note s ",hd=128\0hq<=64,hkv<=64,hd=128,rows+base<=4096\0"
734p = ae_s o p 15817785760573484 8
735p = ae_s o p 7506432086480023912 8
736p = ae_s o p 7506432086480025195 8
737p = ae_s o p 8030529705426894180 8
738p = ae_s o p 4352011477019489143 8
739p = ae_s o p 232887694397 6
740p = ae_hex o p s
741note s "omega_gqa_attention_causal\0"
742p = ae_s o p 8171604920838221167 8
743p = ae_s o p 8389754706680962913 8
744p = ae_s o p 8319662966067588969 8
745p = ae_s o p 27745 3
746ret p
747end
748note ae_texts: the 13 manifest texts in the order op, contract name, precision, accumulation, tolerance,
749note shape, bounds, semantic spec id, kernel function, minimum driver, requires, tool version,
750note qualification.
751fn ae_texts s edit ulong 128 o edit uchar 262144 to ulong
752p = ulong 0
753if eq get s 5 1
754p = ae_mmtx s o
755else
756p = ae_attx s o
757end
758note s "580.173.02\0sm_121,nvidia-cubin-abi-v8\0cudapp-artifact-export/1\0"
759p = ae_s o p 3329065233924765749 8
760p = ae_s o p 3616776899440685616 8
761p = ae_s o p 7019251898354904113 8
762p = ae_s o p 7002374394533471021 8
763p = ae_s o p 8458604767632779618 8
764p = ae_s o p 8390875903532491108 8
765p = ae_s o p 8675390235105912425 8
766p = ae_s o p 54079886880624 7
767note s "offline-disassembly=PASS;device-load=NOT_RUN;device-exec=NOT_RUN\0"
768p = ae_s o p 3271142103423805039 8
769p = ae_s o p 7882833662175308132 8
770p = ae_s o p 6004214541099560034 8
771p = ae_s o p 3271130008963605563 8
772p = ae_s o p 6075160447930167148 8
773p = ae_s o p 8531335275003335263 8
774p = ae_s o p 7162263158351291241 8
775p = ae_s o p 5644508277368639037 8
776p = ae_s o p 0 1
777put s 0 14
778ret ulong 14
779end
780note ae_done: after the export: t holds the rc name and the error, or the id, the contract id and PREFIX.
781fn ae_done s edit ulong 128 f view ulong 8 t view uchar 262144 o edit uchar 262144 to ulong
782p = ulong 0
783if ne get s 18 get f 1
784note s "artifact-export refused: "
785p = ae_s o p 8386654023577793121 8
786p = ae_s o p 2338619929466004781 8
787p = ae_s o p 4207599498436175218 8
788p = ae_s o p 32 1
789p = ae_cp o p t 0
790note s ": "
791p = ae_s o p 8250 2
792p = ae_cp o p t ae_skip t 0
793put o p uchar 10
794ret ae_exit s add p 1 3
795end
796at = ulong 0
797note s "artifact_id="
798p = ae_s o p 8386654023577793121 8
799p = ae_s o p 1029990751 4
800p = ae_cp o p t at
801at = ae_skip t at
802note s "\nop="
803p = ae_s o p 1030778634 4
804if eq get s 5 1
805note s "matmul"
806p = ae_s o p 119251603317101 6
807else
808note s "gqa-causal-attention"
809p = ae_s o p 8319662965227876711 8
810p = ae_s o p 7954892360015244385 8
811p = ae_s o p 1852795252 4
812end
813note s "\ncontract_id="
814p = ae_s o p 7161130726890365706 8
815p = ae_s o p 263677632372 5
816p = ae_cp o p t at
817at = ae_skip t at
818note s "\ncubin="
819p = ae_s o p 17291372481831690 7
820p = ae_cp o p t at
821note s ".cubin\n"
822p = ae_s o p 2936148669588270 7
823put s 0 99
824ret add 15 shl p 8
825end
826note ae_args: phases 0..3, the command line.
827fn ae_args s edit ulong 128 t view uchar 262144 o edit uchar 262144 to ulong
828ph = get s 0
829i = get s 1
830ac = get s 3
831if eq ph 0
832if lt ac 2
833ret ae_usage s o
834end
835put s 1 1
836put s 0 1
837ret ulong 1
838end
839if eq ph 1
840put s 5 ae_mode t get s 2
841i = ulong 2
842end
843if eq ph 2
844k = ae_flag t get s 2
845if or eq k 0 ge add i 1 ac
846ret ae_usage s o
847end
848put s 4 k
849put s 1 add i 1
850put s 0 3
851ret ulong 1
852end
853if eq ph 3
854x = ae_val s t
855i = add i 1
856end
857put s 1 i
858if lt i ac
859put s 0 2
860ret ulong 1
861end
862ret ae_chk s o
863end
864fn artexp f view ulong 8 s edit ulong 128 t view uchar 262144 o edit uchar 262144 to ulong
865ph = get s 0
866rc = get s 18
867p = ulong 0
868if lt ph 4
869ret ae_args s t o
870end
871if eq ph 5
872if ne rc 0
873note s "spec refused\n"
874p = ae_s o p 7378429047948537971 8
875p = ae_s o p 44634043253 5
876ret ae_exit s p 3
877end
878m = get s 13
879n = get s 15
880gx = div n 8
881put s 0 6
882if eq get s 14 16
883put s 19 gx
884ret ulong 4
885end
886b = div get f 0 div m 16
887if eq b 0
888b = ulong 1
889end
890if gt gx b
891gx = b
892end
893put s 19 gx
894ret ulong 5
895end
896if eq ph 6
897if ne rc 0
898note s "codegen refused\n"
899p = ae_s o p 2336916751408983907 8
900p = ae_s o p 748834984615634290 8
901ret ae_exit s p 3
902end
903put s 0 7
904ret ulong 6
905end
906if eq ph 7
907x = ae_spec s t
908ret ae_mmcfg s
909end
910if eq ph 8
911if ne rc 0
912note s "attention codegen refused: "
913p = ae_s o p 8028075828261975137 8
914p = ae_s o p 7306920402471821422 8
915p = ae_s o p 7310315702801539182 8
916p = ae_s o p 2112100 3
917p = ae_d o p rc
918put o p uchar 10
919ret ae_exit s add p 1 3
920end
921ret ae_stext s o
922end
923if eq ph 9
924x = ae_spec s t
925put s 0 12
926ret ulong 10
927end
928if eq ph 12
929ret ae_atcfg s
930end
931if eq ph 10
932put s 0 11
933ret ulong 12
934end
935if eq ph 11
936put s 38 get s 23
937if eq get s 24 0
938note s "declared registers refused\n"
939p = ae_s o p 7234314139196417380 8
940p = ae_s o p 7310594991672619552 8
941p = ae_s o p 8319668472529318770 8
942p = ae_s o p 681061 3
943ret ae_exit s p 3
944end
945put s 0 13
946ret ulong 13
947end
948if eq ph 13
949if ne rc 0
950note s "QMD template refused\n"
951p = ae_s o p 8101242854141349201 8
952p = ae_s o p 7378429047983071596 8
953p = ae_s o p 44634043253 5
954ret ae_exit s p 3
955end
956ret ae_texts s o
957end
958if eq ph 14
959ret ae_done s f t o
960end
961ret ulong 0
962end