diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cu index 28fd850d8..d298ba103 100644 --- a/ggml/src/ggml-cuda/ggml-cuda.cu +++ b/ggml/src/ggml-cuda/ggml-cuda.cu @@ -1929,6 +1929,19 @@ static void ggml_cuda_mul_mat(ggml_backend_cuda_context & ctx, const ggml_tensor ggml_cuda_mul_mat_vec_q(ctx, src0, src1, nullptr, dst); return; } +#ifndef GGML_CUDA_FORCE_MMQ + // Bound FP16 weight workspace and keep small batches on MMQ. + const bool sm75_ffn = (ne00 == 4096 && ne01 == 12288) || (ne00 == 12288 && ne01 == 4096) + || (ne00 == 5120 && ne01 == 17408) || (ne00 == 17408 && ne01 == 5120); + if (cc == GGML_CUDA_CC_TURING && sm75_ffn && ne11 >= 1024 && ne11 <= 2048 + && (src0->type == GGML_TYPE_Q4_K || src0->type == GGML_TYPE_IQ4_XS) + && ne02 == 1 && ne03 == 1 && ne12 == 1 && ne13 == 1 + && ggml_is_contiguous(src0) && ggml_is_contiguous(src1) + && !ggml_backend_buffer_is_host(src0->buffer)) { + ggml_cuda_mul_mat_cublas(ctx, src0, src1, dst); + return; + } +#endif if (ggml_cuda_should_use_mmq(src0->type, cc, ne11, /*n_experts =*/ 0)) { ggml_cuda_mul_mat_q(ctx, src0, src1, nullptr, dst); return;