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_iq1_s data_a[];};
8layout (binding = 1) writeonly buffer D {D_TYPE data_b[];};
9
10void main() {
11 // Each thread handles 1 subblock (32 values with 2 scales)
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 const uint b_idx = 256 * ib + 32 * ib32;
22
23 uint qh = data_a[ib].qh[ib32];
24 const float d = float(data_a[ib].d);
25 const float dl = d * float(2 * bitfieldExtract(qh, 12, 3) + 1);
26 const float delta = ((qh & 0x8000) != 0) ? -IQ1S_DELTA : IQ1S_DELTA;
27 [[unroll]] for (uint l = 0; l < 4; ++l) {
28 const uint qs = data_a[ib].qs[4 * ib32 + l];
29 const uint hi = bitfieldExtract(qh, 3 * int(l), 3);
30 const int16_t grid = int16_t(iq1s_grid[qs | (hi << 8)]);
31 [[unroll]] for (int j = 0; j < 8; ++j) {
32 data_b[b_idx + 8 * l + j] = D_TYPE(dl * (bitfieldExtract(grid, 2*j, 2) + delta));
33 }
34 }
35}