From e852eb490136dfa335586b9dd6efb94b02c8fdd3 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 24 Mar 2026 12:57:57 +0800 Subject: [PATCH] llama-fit: fix regex pattern for gate_up tensors (#20910) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * llama-fit: fix regex pattern for gate_up tensors * Apply suggestions from code review Co-authored-by: Johannes Gäßler --------- Co-authored-by: Johannes Gäßler --- src/llama.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/llama.cpp b/src/llama.cpp index 872e659edc..4a8a71b08a 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -365,14 +365,14 @@ static void llama_params_fit_impl( case LAYER_FRACTION_ATTN: { static std::array patterns; if (patterns[il].empty()) { - patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(up|gate|down).*"; + patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(gate|up|gate_up|down).*"; } return patterns[il].c_str(); } case LAYER_FRACTION_UP: { static std::array patterns; if (patterns[il].empty()) { - patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(gate|down).*"; + patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(gate|gate_up|down).*"; } return patterns[il].c_str(); } @@ -386,7 +386,7 @@ static void llama_params_fit_impl( case LAYER_FRACTION_MOE: { static std::array patterns; if (patterns[il].empty()) { - patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(up|down|gate)_(ch|)exps"; + patterns[il] = "blk\\." + std::to_string(il) + "\\.ffn_(up|down|gate_up|gate)_(ch|)exps"; } return patterns[il].c_str(); } @@ -480,7 +480,7 @@ static void llama_params_fit_impl( int64_t global_surplus_cpu_moe = 0; if (hp_nex > 0) { - const static std::string pattern_moe_all = "blk\\.\\d+\\.ffn_(up|down|gate)_(ch|)exps"; // matches all MoE tensors + const static std::string pattern_moe_all = "blk\\.\\d+\\.ffn_(up|down|gate_up|gate)_(ch|)exps"; // matches all MoE tensors ggml_backend_buffer_type_t cpu_buft = ggml_backend_cpu_buffer_type(); tensor_buft_overrides[0] = {pattern_moe_all.c_str(), cpu_buft}; tensor_buft_overrides[1] = {nullptr, nullptr};