|
|
|
@@ -980,6 +980,7 @@ struct vk_device_struct {
|
|
|
|
|
vk_pipeline pipeline_concat_i8, pipeline_concat_i16, pipeline_concat_i32, pipeline_concat_i64;
|
|
|
|
|
vk_pipeline pipeline_upscale_nearest_f32, pipeline_upscale_bilinear_f32, pipeline_upscale_bicubic_f32, pipeline_upscale_bilinear_antialias_f32;
|
|
|
|
|
vk_pipeline pipeline_scale_f32;
|
|
|
|
|
vk_pipeline pipeline_mul_mat_scale_f32;
|
|
|
|
|
vk_pipeline pipeline_log[2];
|
|
|
|
|
vk_pipeline pipeline_tri[2];
|
|
|
|
|
vk_pipeline pipeline_diag[2];
|
|
|
|
@@ -1317,6 +1318,9 @@ struct vk_mat_mat_push_constants {
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_BIAS1 0x2
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_SCALE0 0x4
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_SCALE1 0x8
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE 0x10
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE_VEC 0x20
|
|
|
|
|
#define MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE_2D 0x40
|
|
|
|
|
|
|
|
|
|
struct vk_mat_vec_push_constants {
|
|
|
|
|
uint32_t ncols;
|
|
|
|
@@ -1642,6 +1646,13 @@ struct vk_op_binary_push_constants {
|
|
|
|
|
float param1; float param2; int32_t param3;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct vk_op_mul_mat_scale_push_constants {
|
|
|
|
|
uint32_t ne0; uint32_t ne1; uint32_t ne2; uint32_t ne3;
|
|
|
|
|
uint32_t sne0; uint32_t sne1; uint32_t sne2; uint32_t sne3;
|
|
|
|
|
uint32_t per_expert;
|
|
|
|
|
uint32_t ids_s0; uint32_t ids_s1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Distinct type with the same layout so concat can overload tensor offset initialization.
|
|
|
|
|
struct vk_op_concat_push_constants : vk_op_binary_push_constants {};
|
|
|
|
|
static_assert(sizeof(vk_op_concat_push_constants) == sizeof(vk_op_binary_push_constants));
|
|
|
|
@@ -4750,6 +4761,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_f16[GGML_TYPE_MXFP4], matmul_mxfp4_f16, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3)
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_f16[GGML_TYPE_NVFP4], matmul_nvfp4_f16, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3)
|
|
|
|
|
}
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_f16[GGML_TYPE_F8_E4M3], matmul_f8_e4m3_f16, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3)
|
|
|
|
|
|
|
|
|
|
GGML_ASSERT(device->subgroup_ballot);
|
|
|
|
|
|
|
|
|
@@ -4791,6 +4803,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4], matmul_id_subgroup_mxfp4_f16, mmqid_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, 5)
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4], matmul_id_subgroup_nvfp4_f16, mmqid_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, 5)
|
|
|
|
|
}
|
|
|
|
|
CREATE_MM2(pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3], matmul_id_subgroup_f8_e4m3_f16, mmqid_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, 5)
|
|
|
|
|
#undef CREATE_MM
|
|
|
|
|
#undef CREATE_MM2
|
|
|
|
|
} else
|
|
|
|
@@ -4865,6 +4878,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_MXFP4], matmul_mxfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, );
|
|
|
|
|
CREATE_MM2(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_NVFP4], matmul_nvfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, );
|
|
|
|
|
}
|
|
|
|
|
CREATE_MM2(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat[GGML_TYPE_F8_E4M3], matmul_f8_e4m3_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, );
|
|
|
|
|
|
|
|
|
|
GGML_ASSERT(device->subgroup_ballot);
|
|
|
|
|
|
|
|
|
@@ -4909,6 +4923,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4], matmul_id_subgroup_mxfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4], matmul_id_subgroup_nvfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id);
|
|
|
|
|
}
|
|
|
|
|
CREATE_MM2(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3], matmul_id_subgroup_f8_e4m3_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id);
|
|
|
|
|
#undef CREATE_MM2
|
|
|
|
|
#undef CREATE_MM
|
|
|
|
|
} else
|
|
|
|
@@ -4992,6 +5007,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat[GGML_TYPE_IQ4_NL], matmul_iq4_nl_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_MXFP4], matmul_mxfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_NVFP4], matmul_nvfp4_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat[GGML_TYPE_F8_E4M3], matmul_f8_e4m3_f32, mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5041,6 +5057,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_IQ4_NL], matmul_id_subgroup_iq4_nl_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4], matmul_id_subgroup_mxfp4_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4], matmul_id_subgroup_nvfp4_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3], matmul_id_subgroup_f8_e4m3_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5089,6 +5106,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM2(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_IQ4_NL], matmul_id_iq4_nl_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4], matmul_id_mxfp4_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4], matmul_id_nvfp4_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM2(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3], matmul_id_f8_e4m3_f32, mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5169,6 +5187,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat[GGML_TYPE_IQ4_NL].f32acc, matmul_iq4_nl_f32, , mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_MXFP4].f32acc, matmul_mxfp4_f32, , mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat[GGML_TYPE_NVFP4].f32acc, matmul_nvfp4_f32, , mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat[GGML_TYPE_F8_E4M3].f32acc, matmul_f8_e4m3_f32, , mmq_wg_denoms, warptile_mmq, vk_mat_mat_push_constants, 3, , 0);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5217,6 +5236,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_IQ4_NL].f32acc, matmul_id_subgroup_iq4_nl_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4].f32acc, matmul_id_subgroup_mxfp4_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4].f32acc, matmul_id_subgroup_nvfp4_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
CREATE_MM(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3].f32acc, matmul_id_subgroup_f8_e4m3_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, mul_mat_subgroup_size);
|
|
|
|
|
} else {
|
|
|
|
|
CREATE_MM(GGML_TYPE_F32, pipeline_matmul_id_f32, matmul_id_f32_f32, , wg_denoms, warptile, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_F16, pipeline_matmul_id_f16.f32acc, matmul_id_f16, , wg_denoms, warptile, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
@@ -5247,6 +5267,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
CREATE_MM(GGML_TYPE_IQ4_NL, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_IQ4_NL].f32acc, matmul_id_iq4_nl_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_MXFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_MXFP4].f32acc, matmul_id_mxfp4_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_NVFP4, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_NVFP4].f32acc, matmul_id_nvfp4_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
CREATE_MM(GGML_TYPE_F8_E4M3, pipeline_dequant_mul_mat_mat_id[GGML_TYPE_F8_E4M3].f32acc, matmul_id_f8_e4m3_f32, , mmq_wg_denoms, warptile_mmqid, vk_mat_mat_id_push_constants, mul_mat_id_param_count, _id, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// reusing CREATE_MM from the fp32 path
|
|
|
|
@@ -5356,6 +5377,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f32_f32[w][GGML_TYPE_IQ4_NL][i], "mul_mat_vec_iq4_nl_f32_f32", arr_dmmv_iq4_nl_f32_f32_len[reduc16], arr_dmmv_iq4_nl_f32_f32_data[reduc16], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f32_f32[w][GGML_TYPE_MXFP4][i], "mul_mat_vec_mxfp4_f32_f32", OCP_DMMV_LEN(arr_dmmv_mxfp4_f32_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_mxfp4_f32_f32, reduc16), "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f32_f32[w][GGML_TYPE_NVFP4][i], "mul_mat_vec_nvfp4_f32_f32", OCP_DMMV_LEN(arr_dmmv_nvfp4_f32_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_nvfp4_f32_f32, reduc16), "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f32_f32[w][GGML_TYPE_F8_E4M3][i], "mul_mat_vec_f8_e4m3_f32_f32", arr_dmmv_f8_e4m3_f32_f32_len[reduc16], arr_dmmv_f8_e4m3_f32_f32_data[reduc16], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_F32 ][i], "mul_mat_vec_f32_f16_f32", arr_dmmv_f32_f16_f32_len[reduc], arr_dmmv_f32_f16_f32_data[reduc], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {1, 1, 1}, {wg_size_subgroup, 1, i+1}, 1, false, use_subgroups, force_subgroup_size);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_F16 ][i], "mul_mat_vec_f16_f16_f32", arr_dmmv_f16_f16_f32_len[reduc], arr_dmmv_f16_f16_f32_data[reduc], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {2, 1, 1}, {wg_size_subgroup, 2, i+1}, 1, false, use_subgroups, force_subgroup_size);
|
|
|
|
@@ -5384,6 +5406,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_IQ4_NL][i], "mul_mat_vec_iq4_nl_f16_f32", arr_dmmv_iq4_nl_f16_f32_len[reduc16], arr_dmmv_iq4_nl_f16_f32_data[reduc16], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_MXFP4][i], "mul_mat_vec_mxfp4_f16_f32", OCP_DMMV_LEN(arr_dmmv_mxfp4_f16_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_mxfp4_f16_f32, reduc16), "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_NVFP4][i], "mul_mat_vec_nvfp4_f16_f32", OCP_DMMV_LEN(arr_dmmv_nvfp4_f16_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_nvfp4_f16_f32, reduc16), "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_f16_f32[w][GGML_TYPE_F8_E4M3][i], "mul_mat_vec_f8_e4m3_f16_f32", arr_dmmv_f8_e4m3_f16_f32_len[reduc16], arr_dmmv_f8_e4m3_f16_f32_data[reduc16], "main", mul_mat_vec_num_bindings, sizeof(vk_mat_vec_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq, i+1}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5439,6 +5462,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_id_f32[w][GGML_TYPE_IQ4_NL], "mul_mat_vec_id_iq4_nl_f32", arr_dmmv_id_iq4_nl_f32_f32_len[reduc16], arr_dmmv_id_iq4_nl_f32_f32_data[reduc16], "main", mul_mat_vec_id_num_bindings, sizeof(vk_mat_vec_id_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_id_f32[w][GGML_TYPE_MXFP4], "mul_mat_vec_id_mxfp4_f32", OCP_DMMV_LEN(arr_dmmv_id_mxfp4_f32_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_id_mxfp4_f32_f32, reduc16), "main", mul_mat_vec_id_num_bindings, sizeof(vk_mat_vec_id_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_id_f32[w][GGML_TYPE_NVFP4], "mul_mat_vec_id_nvfp4_f32", OCP_DMMV_LEN(arr_dmmv_id_nvfp4_f32_f32, reduc16), OCP_DMMV_DATA(arr_dmmv_id_nvfp4_f32_f32, reduc16), "main", mul_mat_vec_id_num_bindings, sizeof(vk_mat_vec_id_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant_mul_mat_vec_id_f32[w][GGML_TYPE_F8_E4M3], "mul_mat_vec_id_f8_e4m3_f32", arr_dmmv_id_f8_e4m3_f32_f32_len[reduc16], arr_dmmv_id_f8_e4m3_f32_f32_data[reduc16], "main", mul_mat_vec_id_num_bindings, sizeof(vk_mat_vec_id_push_constants), {rm_iq, 1, 1}, {wg_size_subgroup16, rm_iq}, 1, true, use_subgroups16, force_subgroup_size16);
|
|
|
|
|
|
|
|
|
|
#if defined(GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT)
|
|
|
|
|
if (device->integer_dot_product) {
|
|
|
|
@@ -5505,6 +5529,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant[GGML_TYPE_IQ4_NL], "dequant_iq4_nl", dequant_iq4_nl_len, dequant_iq4_nl_data, "main", 2, 5 * sizeof(uint32_t), {256 * 16, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant[GGML_TYPE_MXFP4], "dequant_mxfp4", dequant_mxfp4_len, dequant_mxfp4_data, "main", 2, 5 * sizeof(uint32_t), {256 * 16, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant[GGML_TYPE_NVFP4], "dequant_nvfp4", dequant_nvfp4_len, dequant_nvfp4_data, "main", 2, 5 * sizeof(uint32_t), {256 * 16, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_dequant[GGML_TYPE_F8_E4M3], "dequant_f8_e4m3", dequant_f8_e4m3_len, dequant_f8_e4m3_data, "main", 2, 5 * sizeof(uint32_t), {256, 1, 1}, {}, 1);
|
|
|
|
|
|
|
|
|
|
// get_rows
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_F32 ], "get_rows_f32", get_rows_f32_len, get_rows_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), { 512, 1, 1}, {}, 1);
|
|
|
|
@@ -5534,6 +5559,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_IQ4_NL], "get_rows_iq4_nl", get_rows_iq4_nl_len, get_rows_iq4_nl_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_MXFP4], "get_rows_mxfp4", get_rows_mxfp4_len, get_rows_mxfp4_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_NVFP4], "get_rows_nvfp4", get_rows_nvfp4_len, get_rows_nvfp4_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_F8_E4M3], "get_rows_f8_e4m3", get_rows_f8_e4m3_len, get_rows_f8_e4m3_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows[GGML_TYPE_I32], "get_rows_i32", get_rows_i32_len, get_rows_i32_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_f32[GGML_TYPE_F32 ], "get_rows_f32_f32", get_rows_f32_f32_len, get_rows_f32_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), { 512, 1, 1}, {}, 1);
|
|
|
|
@@ -5563,6 +5589,7 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_f32[GGML_TYPE_IQ4_NL], "get_rows_iq4_nl_f32", get_rows_iq4_nl_f32_len, get_rows_iq4_nl_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_f32[GGML_TYPE_MXFP4], "get_rows_mxfp4_f32", get_rows_mxfp4_f32_len, get_rows_mxfp4_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_f32[GGML_TYPE_NVFP4], "get_rows_nvfp4_f32", get_rows_nvfp4_f32_len, get_rows_nvfp4_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_f32[GGML_TYPE_F8_E4M3], "get_rows_f8_e4m3_f32", get_rows_f8_e4m3_f32_len, get_rows_f8_e4m3_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), {1024, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_get_rows_back_f32, "get_rows_back_f32", get_rows_back_f32_len, get_rows_back_f32_data, "main", 3, sizeof(vk_op_binary_push_constants), {256, 1, 1}, {}, 1, true);
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_matmul_split_k_reduce, "split_k_reduce", split_k_reduce_len, split_k_reduce_data, "main", 2, 2 * sizeof(uint32_t), {256 * 4, 1, 1}, {}, 1);
|
|
|
|
@@ -5715,6 +5742,8 @@ static void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_scale_f32, "scale_f32", scale_f32_len, scale_f32_data, "main", 2, sizeof(vk_op_unary_push_constants), {512, 1, 1}, {}, 1);
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_mul_mat_scale_f32, "mul_mat_scale_f32", mul_mat_scale_f32_len, mul_mat_scale_f32_data, "main", 3, sizeof(vk_op_mul_mat_scale_push_constants), {256, 1, 1}, {}, 1);
|
|
|
|
|
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_log[0], "log_f32", log_f32_len, log_f32_data, "main", 2, sizeof(vk_op_unary_push_constants), {512, 1, 1}, {}, 1);
|
|
|
|
|
ggml_vk_create_pipeline(device, device->pipeline_log[1], "log_f16", log_f16_len, log_f16_data, "main", 2, sizeof(vk_op_unary_push_constants), {512, 1, 1}, {}, 1);
|
|
|
|
|
|
|
|
|
@@ -7787,6 +7816,7 @@ static vk_pipeline ggml_vk_get_to_fp16(ggml_backend_vk_context * ctx, ggml_type
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
@@ -7862,6 +7892,7 @@ static vk_matmul_pipeline ggml_vk_get_mul_mat_mat_pipeline(ggml_backend_vk_conte
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
@@ -7932,6 +7963,7 @@ static vk_pipeline ggml_vk_get_dequantize_mul_mat_vec(ggml_backend_vk_context *
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
@@ -8026,6 +8058,7 @@ static vk_matmul_pipeline ggml_vk_get_mul_mat_mat_id_pipeline(ggml_backend_vk_co
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
@@ -8099,6 +8132,7 @@ static vk_pipeline ggml_vk_get_dequantize_mul_mat_vec_id(ggml_backend_vk_context
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
@@ -9839,6 +9873,15 @@ static void ggml_vk_mul_mat_vec_q_f16(ggml_backend_vk_context * ctx, vk_context&
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_BIAS1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fold weight scale (src[2]) via the F0 slot, free since scaled matmuls don't fuse
|
|
|
|
|
if (dst->src[2] != nullptr) {
|
|
|
|
|
d_F0 = ggml_vk_tensor_subbuffer(ctx, dst->src[2]);
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE;
|
|
|
|
|
if (ggml_nelements(dst->src[2]) > 1) {
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE_VEC;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ggml_pipeline_request_descriptor_sets(ctx, dmmv, CEIL_DIV(ne12 * ne13, ctx->device->properties.limits.maxComputeWorkGroupCount[1]));
|
|
|
|
|
|
|
|
|
|
uint32_t base_work_group_y = 0;
|
|
|
|
@@ -10119,12 +10162,49 @@ static void ggml_vk_fwht(ggml_backend_vk_context * ctx, vk_context& subctx, cons
|
|
|
|
|
ggml_vk_dispatch_pipeline(ctx, subctx, pipeline, { src_buf, dst_buf }, pc, { workgroups_x, 1, 1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggml_vk_mul_mat_scale(ggml_backend_vk_context * ctx, vk_context& subctx, ggml_tensor * dst) {
|
|
|
|
|
const bool is_id = dst->op == GGML_OP_MUL_MAT_ID;
|
|
|
|
|
const ggml_tensor * scale = is_id ? dst->src[3] : dst->src[2];
|
|
|
|
|
const ggml_tensor * ids = is_id ? dst->src[2] : nullptr;
|
|
|
|
|
|
|
|
|
|
GGML_ASSERT(scale != nullptr && scale->type == GGML_TYPE_F32 && ggml_is_contiguous(scale));
|
|
|
|
|
GGML_ASSERT(dst->type == GGML_TYPE_F32 && ggml_is_contiguous(dst));
|
|
|
|
|
|
|
|
|
|
const bool per_expert = is_id && ((uint64_t)ggml_nelements(scale) == (uint64_t)dst->src[0]->ne[2] ||
|
|
|
|
|
(uint64_t)scale->ne[1] == (uint64_t)dst->src[0]->ne[2]);
|
|
|
|
|
|
|
|
|
|
vk_pipeline pipeline = ctx->device->pipeline_mul_mat_scale_f32;
|
|
|
|
|
ggml_pipeline_request_descriptor_sets(ctx, pipeline, 1);
|
|
|
|
|
|
|
|
|
|
ggml_vk_sync_buffers(ctx, subctx);
|
|
|
|
|
|
|
|
|
|
vk_subbuffer d_D = ggml_vk_tensor_subbuffer(ctx, dst);
|
|
|
|
|
vk_subbuffer d_S = ggml_vk_tensor_subbuffer(ctx, scale);
|
|
|
|
|
vk_subbuffer d_I = per_expert ? ggml_vk_tensor_subbuffer(ctx, ids) : d_S;
|
|
|
|
|
|
|
|
|
|
const vk_op_mul_mat_scale_push_constants pc = {
|
|
|
|
|
(uint32_t)dst->ne[0], (uint32_t)dst->ne[1], (uint32_t)dst->ne[2], (uint32_t)dst->ne[3],
|
|
|
|
|
(uint32_t)scale->ne[0], (uint32_t)scale->ne[1], (uint32_t)scale->ne[2], (uint32_t)scale->ne[3],
|
|
|
|
|
per_expert ? 1u : 0u,
|
|
|
|
|
per_expert ? (uint32_t)(ids->nb[0] / sizeof(int32_t)) : 0u,
|
|
|
|
|
per_expert ? (uint32_t)(ids->nb[1] / sizeof(int32_t)) : 0u,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const uint64_t total = (uint64_t)ggml_nelements(dst);
|
|
|
|
|
const uint64_t max_elems = (uint64_t)ctx->device->properties.limits.maxComputeWorkGroupCount[0] * 256;
|
|
|
|
|
const uint32_t elements0 = (uint32_t)std::min(total, max_elems);
|
|
|
|
|
|
|
|
|
|
ggml_vk_dispatch_pipeline(ctx, subctx, pipeline, { d_D, d_S, d_I }, pc, { elements0, 1, 1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggml_vk_mul_mat(ggml_backend_vk_context * ctx, vk_context& subctx, const struct ggml_cgraph * cgraph, int node_idx) {
|
|
|
|
|
ggml_tensor * dst = cgraph->nodes[node_idx];
|
|
|
|
|
ggml_tensor * src0 = dst->src[0];
|
|
|
|
|
ggml_tensor * src1 = dst->src[1];
|
|
|
|
|
VK_LOG_DEBUG("ggml_vk_mul_mat(" << src0 << ", " << src1 << ", " << dst << ")");
|
|
|
|
|
|
|
|
|
|
bool folded = false;
|
|
|
|
|
|
|
|
|
|
// Handle huge A matrix by splitting the M dimensions. This works well for convolution use cases
|
|
|
|
|
// where the M dimension is very large.
|
|
|
|
|
// Split_k doesn't work with M splitting.
|
|
|
|
@@ -10176,11 +10256,16 @@ static void ggml_vk_mul_mat(ggml_backend_vk_context * ctx, vk_context& subctx, c
|
|
|
|
|
// mul_mat_vec supports batching ne12*ne13 when ne11==1, or treating ne11 as the batch size (up to four)
|
|
|
|
|
// when ne12 and ne13 are one.
|
|
|
|
|
} else if ((dst->ne[1] == 1 || (dst->ne[1] <= mul_mat_vec_max_cols && src1->ne[2] * src1->ne[3] == 1)) &&
|
|
|
|
|
(src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16 || src0->type == GGML_TYPE_BF16 || ggml_is_quantized(src0->type))) {
|
|
|
|
|
(src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16 || src0->type == GGML_TYPE_BF16 || src0->type == GGML_TYPE_F8_E4M3 || ggml_is_quantized(src0->type))) {
|
|
|
|
|
ggml_vk_mul_mat_vec_q_f16(ctx, subctx, cgraph, node_idx);
|
|
|
|
|
folded = true;
|
|
|
|
|
} else {
|
|
|
|
|
ggml_vk_mul_mat_q_f16(ctx, subctx, src0, src1, dst, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dst->src[2] != nullptr && !folded) {
|
|
|
|
|
ggml_vk_mul_mat_scale(ctx, subctx, dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggml_vk_mul_mat_id_q_f16(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, const ggml_tensor * src1, const ggml_tensor * ids, ggml_tensor * dst) {
|
|
|
|
@@ -10755,6 +10840,18 @@ static void ggml_vk_mul_mat_vec_id_q_f16(ggml_backend_vk_context * ctx, vk_conte
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_SCALE1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fold weight scale (src[3]) via the F0 slot, free since scaled matmuls don't fuse
|
|
|
|
|
if (dst->src[3] != nullptr) {
|
|
|
|
|
d_F0 = ggml_vk_tensor_subbuffer(ctx, dst->src[3]);
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE;
|
|
|
|
|
if (ggml_nelements(dst->src[3]) > 1) {
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE_VEC;
|
|
|
|
|
}
|
|
|
|
|
if (dst->src[3]->ne[1] > 1) {
|
|
|
|
|
fusion_flags |= MAT_VEC_FUSION_FLAGS_WEIGHT_SCALE_2D;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Loop over the batch dimension
|
|
|
|
|
for (uint32_t expert_i1 = 0; expert_i1 < nei1; ++expert_i1) {
|
|
|
|
|
const vk_mat_vec_id_push_constants pc = {
|
|
|
|
@@ -10787,7 +10884,7 @@ static bool ggml_vk_use_mul_mat_vec_id(const struct ggml_cgraph * cgraph, int no
|
|
|
|
|
ggml_tensor * dst = cgraph->nodes[node_idx];
|
|
|
|
|
ggml_tensor * src0 = dst->src[0];
|
|
|
|
|
ggml_tensor * src2 = dst->src[2];
|
|
|
|
|
return (src2->ne[1] <= 8) && (src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16 || ggml_is_quantized(src0->type));
|
|
|
|
|
return (src2->ne[1] <= 8) && (src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16 || src0->type == GGML_TYPE_F8_E4M3 || ggml_is_quantized(src0->type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggml_vk_mul_mat_id(ggml_backend_vk_context * ctx, vk_context& subctx, const struct ggml_cgraph * cgraph, int node_idx) {
|
|
|
|
@@ -10796,11 +10893,17 @@ static void ggml_vk_mul_mat_id(ggml_backend_vk_context * ctx, vk_context& subctx
|
|
|
|
|
ggml_tensor * src1 = dst->src[1];
|
|
|
|
|
ggml_tensor * src2 = dst->src[2];
|
|
|
|
|
VK_LOG_DEBUG("ggml_vk_mul_mat_id(" << src0 << ", " << src1 << ", " << src2 << ", " << dst << ")");
|
|
|
|
|
bool folded = false;
|
|
|
|
|
if (ggml_vk_use_mul_mat_vec_id(cgraph, node_idx)) {
|
|
|
|
|
ggml_vk_mul_mat_vec_id_q_f16(ctx, subctx, cgraph, node_idx);
|
|
|
|
|
folded = true;
|
|
|
|
|
} else {
|
|
|
|
|
ggml_vk_mul_mat_id_q_f16(ctx, subctx, src0, src1, src2, dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dst->src[3] != nullptr && !folded) {
|
|
|
|
|
ggml_vk_mul_mat_scale(ctx, subctx, dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool ggml_vk_flash_attn_scalar_shmem_support(const vk_device& device, const vk_fa_tuning_params& params, uint32_t hsk, uint32_t hsv, bool f32acc, ggml_type k_type, ggml_type v_type) {
|
|
|
|
@@ -16917,6 +17020,15 @@ static bool ggml_vk_can_fuse(const ggml_backend_vk_context * ctx, const struct g
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// don't fuse onto a scaled matmul: an additive bias would apply before the scale epilogue
|
|
|
|
|
{
|
|
|
|
|
const ggml_tensor * base = cgraph->nodes[node_idx];
|
|
|
|
|
if ((base->op == GGML_OP_MUL_MAT && base->src[2] != nullptr) ||
|
|
|
|
|
(base->op == GGML_OP_MUL_MAT_ID && base->src[3] != nullptr)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ops.size() == 2 && ops.begin()[0] == GGML_OP_RMS_NORM && ops.begin()[1] == GGML_OP_MUL) {
|
|
|
|
|
// additional constraints specific to this fusion
|
|
|
|
|
const ggml_tensor *rms_norm = cgraph->nodes[node_idx];
|
|
|
|
@@ -18673,6 +18785,7 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggm
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
@@ -18779,6 +18892,7 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggm
|
|
|
|
|
case GGML_TYPE_MXFP4:
|
|
|
|
|
case GGML_TYPE_NVFP4:
|
|
|
|
|
case GGML_TYPE_TQ2_0:
|
|
|
|
|
case GGML_TYPE_F8_E4M3:
|
|
|
|
|
case GGML_TYPE_I32:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
@@ -19762,9 +19876,11 @@ static void ggml_vk_check_results_0(ggml_backend_vk_context * ctx, ggml_cgraph *
|
|
|
|
|
ggml_flash_attn_ext_add_sinks(tensor_clone, src_clone[4]);
|
|
|
|
|
}
|
|
|
|
|
} else if (tensor->op == GGML_OP_MUL_MAT) {
|
|
|
|
|
tensor_clone = ggml_mul_mat(ggml_ctx, src_clone[0], src_clone[1]);
|
|
|
|
|
tensor_clone = src_clone[2] ? ggml_mul_mat_ext(ggml_ctx, src_clone[0], src_clone[1], src_clone[2], nullptr)
|
|
|
|
|
: ggml_mul_mat(ggml_ctx, src_clone[0], src_clone[1]);
|
|
|
|
|
} else if (tensor->op == GGML_OP_MUL_MAT_ID) {
|
|
|
|
|
tensor_clone = ggml_mul_mat_id(ggml_ctx, src_clone[0], src_clone[1], src_clone[2]);
|
|
|
|
|
tensor_clone = src_clone[3] ? ggml_mul_mat_id_ext(ggml_ctx, src_clone[0], src_clone[1], src_clone[2], src_clone[3], nullptr)
|
|
|
|
|
: ggml_mul_mat_id(ggml_ctx, src_clone[0], src_clone[1], src_clone[2]);
|
|
|
|
|
} else if (tensor->op == GGML_OP_SUB) {
|
|
|
|
|
tensor_clone = ggml_sub(ggml_ctx, src_clone[0], src_clone[1]);
|
|
|
|
|
} else if (tensor->op == GGML_OP_MUL) {
|
|
|
|
|