Skip to content

Commit 25d7ae4

Browse files
committed
go even further
1 parent f833b75 commit 25d7ae4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q6_k.comp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ layout (constant_id = 0) const uint BLOCK_SIZE = 32;
1010
layout (constant_id = 1) const uint NUM_ROWS = 1;
1111

1212
shared FLOAT_TYPE tmpsh[NUM_ROWS][BLOCK_SIZE];
13+
shared FLOAT_TYPE sccache[BLOCK_SIZE/16][16];
1314
shared block_q6_K_packed16 blkcache[BLOCK_SIZE/16];
1415

1516
void compute_outputs(const uint32_t first_row, const uint32_t num_rows) {
@@ -57,12 +58,13 @@ void compute_outputs(const uint32_t first_row, const uint32_t num_rows) {
5758

5859
// cache full superblock into shared memory with coalesced reads
5960
// we assume 64 threads here!
60-
[[unroll]] for (int l = 0; (l < 4) && (i0 + l < num_blocks_per_row); ++l) {
61-
blkcache[l].ql[tid] = data_a_packed16[ib0 + i0 + l].ql[tid];
62-
// hacky method of reading beyond ql and the block struct size but it looks like vulkan doesn't care? o_O
63-
// this assumes that the struct is packed in continous 16 bit blocks to work
64-
blkcache[l].ql[64 + tid] = data_a_packed16[ib0 + i0 + l].ql[64 + tid];
61+
//
62+
// hacky method of reading beyond ql and the block struct size but it looks like vulkan doesn't care? o_O
63+
// this assumes that the struct is packed in continous 16 bit blocks to work
64+
[[unroll]] for (int l = 0; l < 7; ++l) {
65+
blkcache[0].ql[tid + 64*l] = data_a_packed16[ib0 + i0].ql[tid + 64*l];
6566
}
67+
sccache[ix][itid] = FLOAT_TYPE(blkcache[ix].scales[itid]);
6668
barrier();
6769
if (i >= num_blocks_per_row)
6870
continue;
@@ -100,7 +102,7 @@ void compute_outputs(const uint32_t first_row, const uint32_t num_rows) {
100102
}
101103

102104
[[unroll]] for (int l = 0; l < 4; ++l)
103-
sum[l] *= FLOAT_TYPE(blkcache[ix].scales[s_offset + l*2]);
105+
sum[l] *= sccache[ix][s_offset + l*2];
104106
temp[n] += (sum[0] + sum[1] + sum[2] + sum[3]) * FLOAT_TYPE(blkcache[ix].d);
105107
}
106108
}

0 commit comments

Comments
 (0)