char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e29acf74f
char/aliceai-t5-moe
1#version 450 2 3#include "dequant_head.glsl" 4 5layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 6 7layout (binding = 0) readonly buffer A {block_iq4_xs data_a[];}; 8layout (binding = 1) writeonly buffer D {D_TYPE data_b[];}; 9 10void main() { 11 // Each thread handles 1 subblock (1 scale and 32 quantized values) 12 const uint ib = gl_WorkGroupID.x * 32 + gl_LocalInvocationID.x / 8; 13 14 init_iq_shmem(gl_WorkGroupSize); 15 16 if (ib >= p.nel / 256) { 17 return; 18 } 19 20 const uint ib32 = gl_LocalInvocationID.x % 8; 21 22 const float d = float(data_a[ib].d); 23 // Scales are 6 bits 24 const uint scale = ((data_a[ib].scales_l[ib32/2] >> (4 * (ib32 & 1))) & 0xF) 25 | (((data_a[ib].scales_h >> (2 * ib32)) & 3) << 4); 26 const float dl = d * (int(scale) - 32); 27 28 const uint b_idx = 256 * ib + 32 * ib32; 29 const uint q_idx = 16 * ib32; 30 [[unroll]] for (uint l = 0; l < 16; ++l) { 31 data_b[b_idx + l + 0] = D_TYPE(dl * kvalues_iq4nl[data_a[ib].qs[q_idx + l] & 0xF]); 32 data_b[b_idx + l + 16] = D_TYPE(dl * kvalues_iq4nl[data_a[ib].qs[q_idx + l] >> 4]); 33 } 34}