interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / kgen / attention_ollm.om

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