Skip to content

Commit 2833a6f

Browse files
authored
ggml-cuda : fix f16 mul mat (#3961)
* ggml-cuda : fix f16 mul mat ggml-ci * silence common.cpp warning (bonus)
1 parent d9ccce2 commit 2833a6f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

common/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ void process_escapes(std::string& input) {
101101
input[output_idx++] = char(val);
102102
break;
103103
}
104-
// Intentionally fall through to default.
105104
}
105+
// fall through
106106
default: input[output_idx++] = '\\';
107107
input[output_idx++] = input[input_idx]; break;
108108
}

ggml-cuda.cu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7414,6 +7414,8 @@ static void ggml_cuda_mul_mat(const ggml_tensor * src0, const ggml_tensor * src1
74147414
(src1->backend == GGML_BACKEND_GPU) &&
74157415
( dst->backend == GGML_BACKEND_GPU);
74167416

7417+
const bool split = src0->backend == GGML_BACKEND_GPU_SPLIT;
7418+
74177419
int64_t min_compute_capability = INT_MAX;
74187420
for (int64_t id = 0; id < g_device_count; ++id) {
74197421
if (min_compute_capability > g_compute_capabilities[id] && g_tensor_split[id] < (id + 1 < g_device_count ? g_tensor_split[id + 1] : 1.0f)) {
@@ -7435,13 +7437,13 @@ static void ggml_cuda_mul_mat(const ggml_tensor * src0, const ggml_tensor * src1
74357437
//printf("src0 is contiguous %d, transposed %d, type = %s, name = %s\n", ggml_is_contiguous(src0), ggml_is_transposed(src0), ggml_type_name(src0->type), src0->name);
74367438
//printf("src1 is contiguous %d, transposed %d, type = %s, name = %s\n", ggml_is_contiguous(src1), ggml_is_transposed(src1), ggml_type_name(src1->type), src1->name);
74377439

7438-
if (all_on_device && !use_tensor_cores && src0->type == GGML_TYPE_F16 && ggml_is_permuted(src0) && ggml_is_permuted(src1) && src1->ne[1] == 1) {
7440+
if (!split && all_on_device && !use_tensor_cores && src0->type == GGML_TYPE_F16 && ggml_is_permuted(src0) && ggml_is_permuted(src1) && src1->ne[1] == 1) {
74397441
// KQ single-batch
74407442
ggml_cuda_mul_mat_vec_p021(src0, src1, dst);
7441-
} else if (all_on_device && !use_tensor_cores && src0->type == GGML_TYPE_F16 && !ggml_is_contiguous(src0) && !ggml_is_transposed(src1) && src1->ne[1] == 1) {
7443+
} else if (!split && all_on_device && !use_tensor_cores && src0->type == GGML_TYPE_F16 && !ggml_is_contiguous(src0) && !ggml_is_transposed(src1) && src1->ne[1] == 1) {
74427444
// KQV single-batch
74437445
ggml_cuda_mul_mat_vec_nc(src0, src1, dst);
7444-
} else if (all_on_device && use_tensor_cores && src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F32 && !ggml_is_transposed(src0) && !ggml_is_transposed(src1)) {
7446+
} else if (!split && all_on_device && use_tensor_cores && src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F32 && !ggml_is_transposed(src0) && !ggml_is_transposed(src1)) {
74457447
// KQ + KQV multi-batch
74467448
ggml_cuda_mul_mat_mat_batched_cublas(src0, src1, dst);
74477449
} else if (src0->type == GGML_TYPE_F32) {

0 commit comments

Comments
 (0)