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 / om / kgen / attention_ollm.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Own Omega LLM one-row decode, E=64, MHA H=6/8/16. No allocation or launch effects. |
| 3 | note Compose with attention_emit/tuned/general/ir.om; emits the existing fused general kernel. |
| 4 | note KV layout per layer: [K plane | V plane], each [head][capacity][64], head contiguous. |
| 5 | note Query and output are f32 [H][64], already RoPE rotated. KV f32 by default, BF16 opt-in. |
| 6 | note shape[0..3] = heads,capacity,position,kv_bf16. Caller supplies args[0..7] pointer pairs: |
| 7 | note Q, layer pool (K plane), output, table. This function fills remaining constant-bank words. |
| 8 | note Table row [lo,hi,block-table-word-offset,reserved], then H byte offsets, then block id zero. |
| 9 | note All unused table words are cleared so a reused table cannot extend the admitted range. |
| 10 | note Score scale = Log[2,E]/Sqrt[64], Wolfram 0.18033688011112042591999058512523651718. |
| 11 | fn attention_ollm_wire shape view ulong 4 tab edit uint 64 args edit uint 32 to ulong |
| 12 | h = get shape 0 |
| 13 | cap = get shape 1 |
| 14 | pos = get shape 2 |
| 15 | bf = get shape 3 |
| 16 | if and and ne h 6 ne h 8 ne h 16 |
| 17 | ret 1 |
| 18 | end |
| 19 | if or or eq cap 0 gt cap 16384 ge pos cap |
| 20 | ret 1 |
| 21 | end |
| 22 | if gt bf 1 |
| 23 | ret 1 |
| 24 | end |
| 25 | esize = ulong 4 |
| 26 | if eq bf 1 |
| 27 | esize = ulong 2 |
| 28 | end |
| 29 | headb = mul mul cap 64 esize |
| 30 | for i ulong 64 |
| 31 | put tab i 0 |
| 32 | end |
| 33 | put tab 1 uint add pos 1 |
| 34 | put tab 2 uint add h 4 |
| 35 | for i ulong h |
| 36 | put tab add i 4 uint mul i headb |
| 37 | end |
| 38 | for i ulong 24 |
| 39 | put args add i 8 0 |
| 40 | end |
| 41 | put args 9 bitcast uint 0.1803368801111204259f32 |
| 42 | put args 11 uint mul 64 esize |
| 43 | put args 12 uint mul h headb |
| 44 | put args 13 16 |
| 45 | put args 14 uint h |
| 46 | ret 0 |
| 47 | end |
| 48 | fn attention_ollm_ir bf ulong ins edit ulong 8192 meta edit ulong 512 to ulong |
| 49 | if gt bf 1 |
| 50 | ret 1 |
| 51 | end |
| 52 | kind = ulong 3 |
| 53 | if eq bf 1 |
| 54 | kind = ulong 2 |
| 55 | end |
| 56 | ret attention_ir kind 64 31 0 ins meta |
| 57 | end |