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 / gemmex / fp8.om

52 lines · 1457 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note The dequantization of one weight-row run of omega_gpu_gemm_ex_fp8_block_rows (CUDApp#144,
3note src/omega_gpu_gemm_ex.c l.467-476): d[c] = f32(((f64 e4m3 w[c]) * (f64 sr[cb])) * scale_mul), one rounding,
4note cb = (c0 + c) / block ((cb + 1) % kb under mutant 5).
5note q: 0 cn (<= 16383), 1 c0, 2 block, 3 kb, 4 scale_mul f64 bits, 5 mutant, 6 sbase = c0 / block, 7 sr[0] bits;
6note s[i] = sr[sbase + i] as binary32 bits and d[c] binary32 (the C shell copies min(16384, kb - sbase) entries).
7note Gives 0, or 1 for a block outside s. The block and its scale are found once per block, not per element.
8
9note the scale bits of block cb, or 1 << 32 when the block lies outside s
10fn gx_fsv q view ulong 8 s view uint 16384 cb ulong to ulong
11sb = get q 6
12if eq get q 5 5
13cb = rem add cb 1 get q 3
14end
15if ge cb sb
16if ge sub cb sb 16384
17ret shl ulong 1 32
18end
19ret ulong get s sub cb sb
20end
21if ne cb 0
22ret shl ulong 1 32
23end
24ret get q 7
25end
26
27fn gemm_ex_fp8 q view ulong 8 w view uchar 65536 s view uint 16384 d edit f32 16384 to ulong
28if eq get q 0 0
29ret 0
30end
31bl = get q 2
32cb = div get q 1 bl
33r = rem get q 1 bl
34sv = gx_fsv view q view s cb
35m = bitcast f64 get q 4
36for c ulong get q 0
37if gt sv 4294967295
38ret 1
39end
40x = f64 gx_e4m3 uint get w c
41x = mul x f64 bitcast f32 uint sv
42x = mul x m
43put d c f32 x
44r = add r 1
45if eq r bl
46r = ulong 0
47cb = add cb 1
48sv = gx_fsv view q view s cb
49end
50end
51ret 0
52end