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 / moe / moe_group_wide.om

117 lines · 2517 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note moe_group with contributions per token read from directory_slots instead of the literal 9.
3note Profiles: (directory_slots 9, shared_id 256) Qwen3.6-35B; (11, 512) Qwen3.8-Flash-Next.
4note req: ids,tgu,tdn,sgu,sdn,xmap,ymap,stride,tokens,seg_entries,map_entries,
5note directory_slots,session_generation,current_generation,admitted,shared_id.
6note admitted is the external selector/cache admission verdict, NOT qualification here.
7note Router ids row = directory_slots-1 routed u32 picks; table rows directory_slots*16 bytes.
8note seg_entries must cover ALL R descriptors, including GROUP trailing zero writes.
9note Output is exact OMEGA_DEC_GR_WORDS u32 constant-bank words, little endian pairs.
10note groups=11 needs a GROUP kernel built for 11 contributions; this unit emits host words only.
11fn mwg_word o edit uchar 64 p ulong v ulong to void
12for b ulong 4
13put o add mul p 4 b uchar and shr v mul b 8 255
14end
15end
16fn mwg_pair o edit uchar 64 p ulong v ulong to void
17mwg_word o p and v 4294967295
18mwg_word o add p 1 shr v 32
19end
20fn mwg_profile r view ulong 16 to ulong
21if eq get r 11 9
22if eq get r 15 256
23ret 0
24end
25end
26if eq get r 11 11
27if eq get r 15 512
28ret 0
29end
30end
31ret 1
32end
33fn mwg_extent r view ulong 16 i ulong to ulong
34k = get r 11
35if lt i 3
36width = mul k 16
37if eq i 0
38width = mul sub k 1 4
39end
40ret add mul sub get r 8 1 get r 7 width
41end
42if lt i 5
43ret mul mul get r 8 k 32
44end
45ret mul add mul get r 8 k 8 4
46end
47fn mwg_overlap a ulong al ulong b ulong bl ulong to bool
48if ge a add b bl
49ret false
50end
51ret lt b add a al
52end
53fn mwg_alias r view ulong 16 to bool
54for i ulong 7
55n = mwg_extent r i
56if gt get r i sub ulong 18446744073709551615 n
57ret true
58end
59end
60for j ulong 4
61for i ulong add j 3
62n = mwg_extent r i
63m = mwg_extent r add j 3
64if mwg_overlap get r i n get r add j 3 m
65ret true
66end
67end
68end
69ret false
70end
71fn moe_group_wide r view ulong 16 o edit uchar 64 to ulong
72if gt get r 8 128
73ret 1
74end
75if ne mwg_profile r 0
76ret 1
77end
78rows = mul get r 8 get r 11
79if or eq get r 8 0 gt rows 128
80ret 1
81end
82if lt get r 9 rows
83ret 2
84end
85if lt get r 10 add rows 8
86ret 2
87end
88if or eq get r 7 0 gt get r 7 4294967295
89ret 2
90end
91if lt get r 7 mul get r 11 16
92ret 2
93end
94if ne rem get r 7 16 0
95ret 3
96end
97for i ulong 7
98if or eq get r i 0 ne rem get r i 8 0
99ret 3
100end
101end
102if ne get r 12 get r 13
103ret 4
104end
105if ne get r 14 1
106ret 4
107end
108if mwg_alias r
109ret 5
110end
111for i ulong 7
112mwg_pair edit o mul i 2 get r i
113end
114mwg_word o 14 get r 7
115mwg_word o 15 get r 8
116ret 0
117end