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 / q38-head / plan.om

117 lines · 2741 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Pure layout and schedule for the experimental 27B exact head.
3note Info: norm bits, scratch bytes, rounding count, scaled, scores, coefficients, lo, hi, tau, padded count.
4fn q38_layout q edit ulong 192 to void
5put q 2 10384
6put q 3 0
7put q 4 20480
8put q 5 add get q 4 mul ulong 248320 4
9put q 6 add get q 5 mul ulong 248320 4
10put q 9 mul div add ulong 248320 2047 2048 2048
11put q 7 add get q 6 mul get q 9 4
12put q 8 add get q 7 mul ulong 248320 4
13put q 1 add get q 8 256
14note Additional admission reserve for the resident screen, coefficients and scratch, rounded conservatively to 2 GiB.
15put q 10 shl ulong 1 31
16end
17note A descriptor has kind, grid, element count, input A, input B, output A, output B, scalar, count.
18fn q38_schedule m view ulong 16 q edit ulong 192 to ulong
19if ne get m 1 248320
20ret 0
21end
22if or eq get m 2 0 ge get m 2 2139095040
23ret 0
24end
25for j ulong 6
26v = get m add j 3
27if or eq v 0 ge v shl ulong 1 48
28ret 0
29end
30if ne rem v 16 0
31ret 0
32end
33end
34lay = new ulong 192 0
35q38_layout lay
36base = get m 3
37hidden = get m 4
38for j ulong 192
39put q j 0
40end
41note Scale hidden by 2^64, then compact FP8 screen.
42put q 0 1
43put q 1 20
44put q 2 5120
45put q 3 hidden
46put q 5 add base get lay 3
47put q 8 5120
48put q 16 2
49put q 19 get m 8
50put q 20 add base get lay 3
51put q 21 add base get lay 4
52note Conservative intervals, then maximum lower bound.
53put q 32 3
54put q 33 div add ulong 248320 255 256
55put q 34 248320
56put q 35 add base get lay 4
57put q 36 add base get lay 5
58put q 37 add base get lay 6
59put q 38 add base get lay 7
60put q 39 get m 2
61put q 40 248320
62put q 48 4
63put q 49 div get lay 9 2048
64put q 50 get lay 9
65put q 51 add base get lay 6
66put q 53 get m 6
67put q 54 get m 7
68put q 64 5
69put q 65 1
70put q 66 2048
71put q 67 get m 6
72put q 68 get m 7
73put q 69 add base get lay 8
74put q 70 add add base get lay 8 4
75note Recheck retained candidates with the original BF16 weights and hidden values.
76put q 80 6
77put q 83 hidden
78put q 84 add base get lay 7
79put q 85 get m 5
80put q 86 add base get lay 8
81ret 6
82end
83note m[0]=1: info from folded weights. m[0]=2: six schedule descriptors.
84note Schedule m[1..8]=vocab,norm bits,scratch,hidden,logits,argmax values,argmax indices,FP8 table.
85fn q38_runtime m view ulong 16 bits view uchar 20480 q edit ulong 192 to ulong
86if eq get m 0 2
87ret q38_schedule m q
88end
89if and eq get m 0 3 eq get m 1 248320
90for j ulong 192
91put q j 0
92end
93q38_layout q
94ret 1
95end
96if or ne get m 0 1 ne get m 1 248320
97ret 0
98end
99wb = new uint 5120 0
100for i ulong 5120
101v = ulong 0
102for j ulong 4
103v = or v shl ulong get bits add mul i 4 j mul j 8
104end
105put wb i uint v
106end
107hn = q38_envelope wb
108if eq hn 0
109ret 0
110end
111for j ulong 192
112put q j 0
113end
114q38_layout q
115put q 0 hn
116ret 1
117end