char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

michaeltrabalka-techvulkan: add TQ2_0 (ternary) support (#25850)a7cd2f0e9

char/aliceai-t5-moe
1.1 KiB31 linesraw
1#version 450
2
3#include "dequant_head.glsl"
4
5layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
6
7layout (binding = 0) readonly buffer A {A_TYPE data_a[];};
8layout (binding = 1) writeonly buffer D {D_TYPE data_b[];};
9
10void main() {
11    [[unroll]] for (uint wgy = 0; wgy < 256; wgy++) {
12        const uint i = gl_WorkGroupID.x * 256 + wgy;
13        if (i >= p.nel / QUANT_K) {
14            return;
15        }
16
17        const uint tid = gl_LocalInvocationID.x;
18        const uint ip = tid / 32;         // group 0,1 (128 elems each)
19        const uint il = tid - 32 * ip;    // byte in group 0..31
20
21        const uint y_idx = i * QUANT_K + 128 * ip + il;
22
23        const uint8_t qs = data_a[i].qs[32 * ip + il];
24
25        const FLOAT_TYPE d = FLOAT_TYPE(data_a[i].d);
26        data_b[y_idx +  0] = D_TYPE(d * FLOAT_TYPE(int((qs >> 0) & 3) - 1));
27        data_b[y_idx + 32] = D_TYPE(d * FLOAT_TYPE(int((qs >> 2) & 3) - 1));
28        data_b[y_idx + 64] = D_TYPE(d * FLOAT_TYPE(int((qs >> 4) & 3) - 1));
29        data_b[y_idx + 96] = D_TYPE(d * FLOAT_TYPE(int((qs >> 6) & 3) - 1));
30    }
31}