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 / attn-any / plan.om

55 lines · 1245 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Shape: seq_q,seq_kv,head_dim,q_heads,kv_heads,causal,dtype,scale_bits.
3note Plan: total Q/KV/O bytes, unused, per-head Q/KV/O byte offsets, rows, threads, mode.
4note Refusal 1 is shape/format/size refusal, separate from bridge trap and allocation failure.
5fn aa_plan s view ulong 8 head ulong p edit ulong 16 to ulong
6for i ulong 16
7put p i 0
8end
9for i ulong 5
10if eq get s i 0
11ret 1
12end
13end
14if or gt get s 0 65535 gt get s 1 65535
15ret 1
16end
17if or gt get s 2 256 gt get s 3 65535
18ret 1
19end
20if gt get s 4 get s 3
21ret 1
22end
23if ne rem get s 3 get s 4 0
24ret 1
25end
26if or gt get s 5 1 gt get s 6 2
27ret 1
28end
29if or ge head get s 3 gt get s 7 4294967295
30ret 1
31end
32if eq and get s 7 2139095040 2139095040
33ret 1
34end
35bytes = ulong 4
36if ne get s 6 0
37bytes = ulong 2
38end
39qn = mul mul get s 0 get s 2 get s 3
40kn = mul mul get s 1 get s 2 get s 4
41if or gt qn 1073741824 gt kn 1073741824
42ret 1
43end
44put p 0 mul qn bytes
45put p 1 mul kn bytes
46put p 2 mul qn 4
47put p 4 mul mul mul head get s 0 get s 2 bytes
48kh = div head div get s 3 get s 4
49put p 5 mul mul mul kh get s 1 get s 2 bytes
50put p 6 mul mul mul head get s 0 get s 2 4
51put p 7 get s 0
52put p 8 32
53put p 9 or get s 6 shl get s 5 8
54ret 0
55end