From c1c3421462f0f67e7653026868dc137c4c3557ca Mon Sep 17 00:00:00 2001 From: usrlocalben Date: Sat, 7 Mar 2026 01:01:14 -0700 Subject: [PATCH] Fix incorrect --amb n_max_head fitting (#1375) kv_f32_size should be fit to --amb by number of divisions, not heads per division. Regression in b85a2a5 --- src/llama-build-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama-build-context.cpp b/src/llama-build-context.cpp index cc39dca0..163141c7 100644 --- a/src/llama-build-context.cpp +++ b/src/llama-build-context.cpp @@ -7079,7 +7079,7 @@ ggml_cgraph * llm_build_context::build_deepseek2() { if (cparams.attn_max_batch > 0 && kv_f32_size > cparams.attn_max_batch) { n_max_head = 1; for (int niter = 2; niter < n_head; ++niter) { - if (n_head % niter == 0 && kv_f32_size/(n_head/niter) <= cparams.attn_max_batch) { + if (n_head % niter == 0 && kv_f32_size/niter <= cparams.attn_max_batch) { n_max_head = n_head/niter; break; }