Skip to content

Commit 51592ce

Browse files
committed
vulkan: use prealloc intermediate reuse for mmvq path
1 parent eabd689 commit 51592ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4559,7 +4559,7 @@ static vk_pipeline ggml_vk_get_dequantize_mul_mat_vec(ggml_backend_vk_context *
45594559

45604560
// heuristic to choose workgroup size
45614561
uint32_t dmmv_wg = DMMV_WG_SIZE_SUBGROUP;
4562-
if (ctx->device->vendor_id == VK_VENDOR_ID_NVIDIA || ctx->device->vendor_id == VK_VENDOR_ID_INTEL) {
4562+
if (ctx->device->vendor_id == VK_VENDOR_ID_NVIDIA) {
45634563
// Prefer larger workgroups when M is small, to spread the work out more
45644564
// and keep more SMs busy.
45654565
// q6_k seems to prefer small workgroup size even for "medium" values of M.
@@ -4575,7 +4575,7 @@ static vk_pipeline ggml_vk_get_dequantize_mul_mat_vec(ggml_backend_vk_context *
45754575
}
45764576

45774577
if (b_type == GGML_TYPE_Q8_1) {
4578-
return ctx->device->pipeline_dequant_mul_mat_vec_q8_1_f32[DMMV_WG_SIZE_SUBGROUP][a_type][num_cols-1];
4578+
return ctx->device->pipeline_dequant_mul_mat_vec_q8_1_f32[dmmv_wg][a_type][num_cols-1];
45794579
}
45804580

45814581
return b_type == GGML_TYPE_F32 ? ctx->device->pipeline_dequant_mul_mat_vec_f32_f32[dmmv_wg][a_type][num_cols-1] : ctx->device->pipeline_dequant_mul_mat_vec_f16_f32[dmmv_wg][a_type][num_cols-1];
@@ -6036,7 +6036,12 @@ static void ggml_vk_mul_mat_vec_q_f16(ggml_backend_vk_context * ctx, vk_context&
60366036
}
60376037
}
60386038
if (quantize_y) {
6039-
ggml_vk_quantize_q8_1(ctx, subctx, { d_Qy, qy_buf_offset, VK_WHOLE_SIZE }, { d_Y, 0, VK_WHOLE_SIZE }, y_ne * ne12 * ne13, true);
6039+
if (ctx->prealloc_y_last_pipeline_used != to_q8_1.get() ||
6040+
ctx->prealloc_y_last_tensor_used != src1) {
6041+
ggml_vk_quantize_q8_1(ctx, subctx, { d_Qy, qy_buf_offset, VK_WHOLE_SIZE }, { d_Y, 0, VK_WHOLE_SIZE }, y_ne * ne12 * ne13, true);
6042+
ctx->prealloc_y_last_pipeline_used = to_q8_1.get();
6043+
ctx->prealloc_y_last_tensor_used = src1;
6044+
}
60406045
}
60416046

60426047
// For batch_n, the A matrix is the same for each batch, and B/D use the row stride as the batch stride

0 commit comments

Comments
 (0)