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
CUDApp / tests / attention_ollm.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | text AOOK "ATTENTION OLLM PASS (36 resident KV wires; 2 fused kernel streams equal existing oracle-checked roots; future-token mask; invalid shape refusals)\n" |
| 3 | fn aowire h ulong cap ulong bf ulong last bool to bool |
| 4 | shape = new ulong 4 0 |
| 5 | tab = new uint 64 0 |
| 6 | args = new uint 32 0 |
| 7 | put shape 0 h |
| 8 | put shape 1 cap |
| 9 | pos = ulong 0 |
| 10 | if last |
| 11 | pos = sub cap 1 |
| 12 | end |
| 13 | put shape 2 pos |
| 14 | put shape 3 bf |
| 15 | put args 0 1234 |
| 16 | if ne attention_ollm_wire shape tab args 0 |
| 17 | ret false |
| 18 | end |
| 19 | if ne get tab 0 0 |
| 20 | ret false |
| 21 | end |
| 22 | if ne get tab 1 uint add pos 1 |
| 23 | ret false |
| 24 | end |
| 25 | if ne get tab 2 uint add h 4 |
| 26 | ret false |
| 27 | end |
| 28 | if ne get args 0 1234 |
| 29 | ret false |
| 30 | end |
| 31 | esize = ulong 4 |
| 32 | if eq bf 1 |
| 33 | esize = ulong 2 |
| 34 | end |
| 35 | headb = mul mul cap 64 esize |
| 36 | for i ulong h |
| 37 | if ne get tab add i 4 uint mul i headb |
| 38 | ret false |
| 39 | end |
| 40 | end |
| 41 | if ne get args 12 uint mul h headb |
| 42 | ret false |
| 43 | end |
| 44 | if ne get args 11 uint mul 64 esize |
| 45 | ret false |
| 46 | end |
| 47 | put shape 2 cap |
| 48 | if eq attention_ollm_wire shape tab args 0 |
| 49 | ret false |
| 50 | end |
| 51 | put shape 2 0 |
| 52 | put shape 0 7 |
| 53 | if eq attention_ollm_wire shape tab args 0 |
| 54 | ret false |
| 55 | end |
| 56 | ret true |
| 57 | end |
| 58 | fn aokernel bf ulong to bool |
| 59 | ins = new ulong 8192 0 |
| 60 | ref = new ulong 8192 0 |
| 61 | meta = new ulong 512 0 |
| 62 | rm = new ulong 512 0 |
| 63 | if ne attention_ollm_ir bf ins meta 0 |
| 64 | ret false |
| 65 | end |
| 66 | kind = ulong 3 |
| 67 | if eq bf 1 |
| 68 | kind = ulong 2 |
| 69 | end |
| 70 | if ne attention_ir kind 64 31 0 ref rm 0 |
| 71 | ret false |
| 72 | end |
| 73 | for i ulong 8192 |
| 74 | if ne get ins i get ref i |
| 75 | ret false |
| 76 | end |
| 77 | end |
| 78 | for i ulong 512 |
| 79 | if ne get meta i get rm i |
| 80 | ret false |
| 81 | end |
| 82 | end |
| 83 | ret gt get meta 0 0 |
| 84 | end |
| 85 | fn main to int |
| 86 | for bf ulong 2 |
| 87 | if not aokernel bf |
| 88 | ret 1 |
| 89 | end |
| 90 | for s ulong 3 |
| 91 | h = ulong 6 |
| 92 | if eq s 1 |
| 93 | h = ulong 8 |
| 94 | end |
| 95 | if eq s 2 |
| 96 | h = ulong 16 |
| 97 | end |
| 98 | for t ulong 3 |
| 99 | cap = shl ulong 512 mul t 2 |
| 100 | if not aowire h cap bf false |
| 101 | ret 2 |
| 102 | end |
| 103 | if not aowire h cap bf true |
| 104 | ret 3 |
| 105 | end |
| 106 | end |
| 107 | end |
| 108 | end |
| 109 | n = write 1 AOOK 0 len AOOK |
| 110 | if ne n long len AOOK |
| 111 | ret 4 |
| 112 | end |
| 113 | ret 0 |
| 114 | end |