From 29d218106153d6afa234334f6d2a766952a52959 Mon Sep 17 00:00:00 2001 From: dusterbloom <32869278+dusterbloom@users.noreply.github.com> Date: Thu, 27 Aug 2026 12:10:51 +0000 Subject: [PATCH 1/2] perf(ds4): enable sparse gate-up MMQ prefill --- server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu b/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu index f8fc6aa2a..cb2183a30 100644 --- a/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu +++ b/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu @@ -2816,7 +2816,14 @@ static bool ggml_cuda_try_fuse_mul_mat_glu( } const int64_t ncols = ids ? src1->ne[2] : src1->ne[1]; - if (ggml_cuda_should_use_mmq( + const char * mix_mmq = std::getenv("DFLASH_DS4_MIX_MMQ_PREFILL"); + const bool default_ds4_mix_gate_up_mmq = + src0->type == GGML_TYPE_Q2_1_ROCMFP2_MIX && + ids != nullptr && + GGML_CUDA_CC_IS_RDNA3_5(cc) && + (!mix_mmq || !(mix_mmq[0] == '0' && mix_mmq[1] == '\0')); + if (default_ds4_mix_gate_up_mmq || + ggml_cuda_should_use_mmq( src0->type, cc, ncols, ids ? src0->ne[2] : /*n_experts=*/0)) { ggml_cuda_mul_mat_q_pair( From 465a85b56dc360fad12413ea6406a352193e5ad9 Mon Sep 17 00:00:00 2001 From: dusterbloom <32869278+dusterbloom@users.noreply.github.com> Date: Thu, 27 Aug 2026 22:54:22 +0200 Subject: [PATCH 2/2] fix(cuda): honor force cublas for DS4 mix pair --- server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu b/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu index cb2183a30..a1c178fde 100644 --- a/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu +++ b/server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu @@ -2816,12 +2816,17 @@ static bool ggml_cuda_try_fuse_mul_mat_glu( } const int64_t ncols = ids ? src1->ne[2] : src1->ne[1]; +#ifdef GGML_CUDA_FORCE_CUBLAS + // The global force-cuBLAS policy is authoritative over this RDNA 3.5 default. + constexpr bool default_ds4_mix_gate_up_mmq = false; +#else const char * mix_mmq = std::getenv("DFLASH_DS4_MIX_MMQ_PREFILL"); const bool default_ds4_mix_gate_up_mmq = src0->type == GGML_TYPE_Q2_1_ROCMFP2_MIX && ids != nullptr && GGML_CUDA_CC_IS_RDNA3_5(cc) && (!mix_mmq || !(mix_mmq[0] == '0' && mix_mmq[1] == '\0')); +#endif if (default_ds4_mix_gate_up_mmq || ggml_cuda_should_use_mmq( src0->type, cc, ncols,