Commit 7a2e5aba9 for llama.cpp

commit 7a2e5aba905126be2de919dd5dd9f1491a893a73
Author: Georgi Gerganov <ggerganov@gmail.com>
Date:   Tue Oct 27 07:53:44 2026 +0200

    llama : remove obsolete n_pad from memory instances (#31200)

    Every caller passes n_pad = 1 and the only two users clamp it to 256.
    Drop the parameter, the members and the trivially true kv_size assert.

    Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (MacBook, M5 Max, 128GB)

diff --git a/src/llama-kv-cache-dsa-iswa.cpp b/src/llama-kv-cache-dsa-iswa.cpp
index 02d14a344..3d91228f3 100644
--- a/src/llama-kv-cache-dsa-iswa.cpp
+++ b/src/llama-kv-cache-dsa-iswa.cpp
@@ -23,7 +23,6 @@ llama_kv_cache_dsa_iswa::llama_kv_cache_dsa_iswa(
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
     const layer_filter_cb & filter_mla,
     const layer_filter_cb & filter_lid,
     const  layer_reuse_cb & reuse) : unified(unified) {
@@ -65,14 +64,14 @@ llama_kv_cache_dsa_iswa::llama_kv_cache_dsa_iswa(

     kv_dsa = std::make_unique<llama_kv_cache_dsa>(
             model, no_alloc, type_k, type_v,
-            v_trans, offload, unified, size_dsa, n_seq_max, n_pad,
+            v_trans, offload, unified, size_dsa, n_seq_max,
             0, LLAMA_SWA_TYPE_NONE, filter_dsa, filter_lid, reuse);

     LLAMA_LOG_INFO("%s: creating SWA KV cache, size = %u cells\n", __func__, size_swa);

     kv_swa = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams, type_k, type_v,
-            v_trans, offload, unified, size_swa, n_seq_max, n_pad,
+            v_trans, offload, unified, size_swa, n_seq_max,
             hparams.n_swa, hparams.swa_type, nullptr, filter_swa, reuse, nullptr);
 }

diff --git a/src/llama-kv-cache-dsa-iswa.h b/src/llama-kv-cache-dsa-iswa.h
index 1aae269da..73fbaa7df 100644
--- a/src/llama-kv-cache-dsa-iswa.h
+++ b/src/llama-kv-cache-dsa-iswa.h
@@ -24,7 +24,6 @@ public:
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
                      uint32_t   n_ubatch,
-                     uint32_t   n_pad,
         const layer_filter_cb & filter_mla,
         const layer_filter_cb & filter_lid,
         const  layer_reuse_cb & reuse);
diff --git a/src/llama-kv-cache-dsa.cpp b/src/llama-kv-cache-dsa.cpp
index 307ff31dd..2602ae3c3 100644
--- a/src/llama-kv-cache-dsa.cpp
+++ b/src/llama-kv-cache-dsa.cpp
@@ -21,7 +21,6 @@ llama_kv_cache_dsa::llama_kv_cache_dsa(
                      bool   unified,
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
     const layer_filter_cb & filter_mla,
@@ -33,7 +32,7 @@ llama_kv_cache_dsa::llama_kv_cache_dsa(

     kv_mla = std::make_unique<llama_kv_cache>(
             model, no_alloc, model.hparams, type_k, type_v,
-            v_trans, offload, unified, kv_size, n_seq_max, n_pad,
+            v_trans, offload, unified, kv_size, n_seq_max,
             n_swa, swa_type, nullptr, filter_mla, reuse, nullptr);

     // we use llama_kv_cache for caching indexer keys
@@ -50,7 +49,7 @@ llama_kv_cache_dsa::llama_kv_cache_dsa(

     kv_lid = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams_lid, type_k, type_v,
-            v_trans, offload, unified, kv_size, n_seq_max, n_pad,
+            v_trans, offload, unified, kv_size, n_seq_max,
             n_swa, swa_type, nullptr, filter_lid, reuse, nullptr);
 }

diff --git a/src/llama-kv-cache-dsa.h b/src/llama-kv-cache-dsa.h
index 584ab40b9..13a59047c 100644
--- a/src/llama-kv-cache-dsa.h
+++ b/src/llama-kv-cache-dsa.h
@@ -24,7 +24,6 @@ public:
                          bool   unified,
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
-                     uint32_t   n_pad,
                      uint32_t   n_swa,
                llama_swa_type   swa_type,
         const layer_filter_cb & filter_mla,
diff --git a/src/llama-kv-cache-dsv4.cpp b/src/llama-kv-cache-dsv4.cpp
index 70bfee8f9..f0ab9f35d 100644
--- a/src/llama-kv-cache-dsv4.cpp
+++ b/src/llama-kv-cache-dsv4.cpp
@@ -1252,7 +1252,6 @@ llama_kv_cache_dsv4::llama_kv_cache_dsv4(
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
                  uint32_t   n_rs_seq,
     const layer_filter_cb & filter,
     const  layer_reuse_cb & reuse) :
@@ -1288,7 +1287,7 @@ llama_kv_cache_dsv4::llama_kv_cache_dsv4(

     kv_raw = std::make_unique<llama_kv_cache_iswa>(
             model, no_alloc, hparams_raw, type_k, type_v,
-            v_trans, offload, swa_full, unified_raw, kv_size, n_seq_max, n_ubatch, n_pad,
+            v_trans, offload, swa_full, unified_raw, kv_size, n_seq_max, n_ubatch,
             nullptr, filter_raw, reuse, nullptr);

     // V4.1: CSA slot = ratio 2, HCA slot = ratio 1, no overlap and no indexer compressor; the index K is stored
@@ -1392,7 +1391,7 @@ llama_kv_cache_dsv4::llama_kv_cache_dsv4(

     kv_csa = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams_csa, type_k, type_v,
-            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_csa), 256u), n_seq_max, n_pad,
+            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_csa), 256u), n_seq_max,
             0, LLAMA_SWA_TYPE_NONE, nullptr, filter_csa, nullptr, nullptr);

     LLAMA_LOG_INFO("%s: creating DSV4 HCA compressed KV cache, size = %u cells\n",
@@ -1400,7 +1399,7 @@ llama_kv_cache_dsv4::llama_kv_cache_dsv4(

     kv_hca = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams_hca, type_k, type_v,
-            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_hca), 256u), n_seq_max, n_pad,
+            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_hca), 256u), n_seq_max,
             0, LLAMA_SWA_TYPE_NONE, nullptr, filter_hca, nullptr, nullptr);

     LLAMA_LOG_INFO("%s: creating DSV4 lightning-indexer KV cache, size = %u cells\n",
@@ -1408,7 +1407,7 @@ llama_kv_cache_dsv4::llama_kv_cache_dsv4(

     kv_lid = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams_lid, type_k, type_v,
-            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_csa), 256u), n_seq_max, n_pad,
+            v_trans, offload, unified_compressed, GGML_PAD(dsv4_comp_size(kv_size, ratio_csa), 256u), n_seq_max,
             0, LLAMA_SWA_TYPE_NONE, nullptr, filter_lid, nullptr, nullptr);

     LLAMA_LOG_INFO("%s: creating DSV4 CSA compressor state\n", __func__);
diff --git a/src/llama-kv-cache-dsv4.h b/src/llama-kv-cache-dsv4.h
index 3e97c46e2..44bf95955 100644
--- a/src/llama-kv-cache-dsv4.h
+++ b/src/llama-kv-cache-dsv4.h
@@ -101,7 +101,6 @@ public:
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
                      uint32_t   n_ubatch,
-                     uint32_t   n_pad,
                      uint32_t   n_rs_seq,
         const layer_filter_cb & filter,
         const  layer_reuse_cb & reuse);
diff --git a/src/llama-kv-cache-iswa.cpp b/src/llama-kv-cache-iswa.cpp
index 4606bcf98..8ce8e0165 100644
--- a/src/llama-kv-cache-iswa.cpp
+++ b/src/llama-kv-cache-iswa.cpp
@@ -23,13 +23,12 @@ llama_kv_cache_iswa::llama_kv_cache_iswa(
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
            llama_memory_t   mem_other,
     const layer_filter_cb & filter,
     const  layer_reuse_cb & reuse,
     const  layer_share_cb & share) :
     llama_kv_cache_iswa(model, no_alloc, model.hparams, type_k, type_v, v_trans, offload, swa_full, unified,
-            kv_size, n_seq_max, n_ubatch, n_pad, mem_other, filter, reuse, share) {
+            kv_size, n_seq_max, n_ubatch, mem_other, filter, reuse, share) {
 }

 llama_kv_cache_iswa::llama_kv_cache_iswa(
@@ -45,7 +44,6 @@ llama_kv_cache_iswa::llama_kv_cache_iswa(
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
            llama_memory_t   mem_other,
     const layer_filter_cb & filter,
     const  layer_reuse_cb & reuse,
@@ -96,14 +94,14 @@ llama_kv_cache_iswa::llama_kv_cache_iswa(

     kv_base = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams, type_k, type_v,
-            v_trans, offload, unified, size_base, n_seq_max, n_pad,
+            v_trans, offload, unified, size_base, n_seq_max,
             0, LLAMA_SWA_TYPE_NONE, mem_other_base, filter_base, reuse, share);

     LLAMA_LOG_INFO("%s: creating     SWA KV cache, size = %u cells\n", __func__, size_swa);

     kv_swa = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams, type_k, type_v,
-            v_trans, offload, unified, size_swa, n_seq_max, n_pad,
+            v_trans, offload, unified, size_swa, n_seq_max,
             hparams.n_swa, hparams.swa_type, mem_other_swa, filter_swa, reuse, share);
 }

diff --git a/src/llama-kv-cache-iswa.h b/src/llama-kv-cache-iswa.h
index 8352669dd..65aba2af7 100644
--- a/src/llama-kv-cache-iswa.h
+++ b/src/llama-kv-cache-iswa.h
@@ -25,7 +25,6 @@ public:
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
                      uint32_t   n_ubatch,
-                     uint32_t   n_pad,
                llama_memory_t   mem_other,
         const layer_filter_cb & filter,
         const  layer_reuse_cb & reuse,
@@ -44,7 +43,6 @@ public:
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
                      uint32_t   n_ubatch,
-                     uint32_t   n_pad,
                llama_memory_t   mem_other,
         const layer_filter_cb & filter,
         const  layer_reuse_cb & reuse,
diff --git a/src/llama-kv-cache-msa.cpp b/src/llama-kv-cache-msa.cpp
index a57937ff4..2d6bac0cb 100644
--- a/src/llama-kv-cache-msa.cpp
+++ b/src/llama-kv-cache-msa.cpp
@@ -20,21 +20,20 @@ llama_kv_cache_msa::llama_kv_cache_msa(
                      bool   unified,
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
     const layer_filter_cb & filter,
     const layer_filter_cb & filter_idx,
     const  layer_reuse_cb & reuse) :
     hparams_idx(model.hparams),
-    n_stream(unified ? 1 : n_seq_max), n_seq_max(n_seq_max), n_pad(n_pad),
+    n_stream(unified ? 1 : n_seq_max), n_seq_max(n_seq_max),
     n_swa(n_swa), swa_type(swa_type) {

     LLAMA_LOG_INFO("%s: creating main KV cache, size = %u cells\n", __func__, kv_size);

     kv_base = std::make_unique<llama_kv_cache>(
             model, no_alloc, model.hparams, type_k, type_v,
-            v_trans, offload, unified, kv_size, n_seq_max, n_pad,
+            v_trans, offload, unified, kv_size, n_seq_max,
             n_swa, swa_type, nullptr, filter, reuse, nullptr);

     // the MSA indexer uses a single key head per layer
@@ -46,7 +45,7 @@ llama_kv_cache_msa::llama_kv_cache_msa(

     kv_idx = std::make_unique<llama_kv_cache>(
             model, no_alloc, hparams_idx, type_k, type_v,
-            v_trans, offload, unified, kv_size, n_seq_max, n_pad,
+            v_trans, offload, unified, kv_size, n_seq_max,
             n_swa, swa_type, nullptr, filter_idx, reuse, nullptr);
 }

@@ -262,7 +261,7 @@ const llama_kv_cache_context * llama_kv_cache_msa_context::get_idx() const {

 uint32_t llama_kv_cache_msa_context::get_n_pos() const {
     // pad the value so that the graph remains constant across batches and can be reused
-    const uint32_t n_pad_cur = std::max(kv->get_n_pad(), 256u);
+    const uint32_t n_pad = 256;

     llama_pos pos_max = -1;

@@ -270,7 +269,7 @@ uint32_t llama_kv_cache_msa_context::get_n_pos() const {
         pos_max = std::max(pos_max, kv->seq_pos_max(seq_id));
     }

-    return std::max(n_pad_cur, GGML_PAD((uint32_t) (pos_max + 1), n_pad_cur));
+    return std::max(n_pad, GGML_PAD((uint32_t) (pos_max + 1), n_pad));
 }

 void llama_kv_cache_msa_context::set_input_cell_pos(ggml_tensor * dst, const llama_ubatch * ubatch, int32_t div) const {
diff --git a/src/llama-kv-cache-msa.h b/src/llama-kv-cache-msa.h
index 3b1477c83..81c6827f3 100644
--- a/src/llama-kv-cache-msa.h
+++ b/src/llama-kv-cache-msa.h
@@ -23,7 +23,6 @@ public:
                          bool   unified,
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
-                     uint32_t   n_pad,
                      uint32_t   n_swa,
                llama_swa_type   swa_type,
         const layer_filter_cb & filter,
@@ -68,7 +67,6 @@ public:
     llama_kv_cache * get_base() const;
     llama_kv_cache * get_idx () const;

-    uint32_t       get_n_pad()    const { return n_pad; }
     uint32_t       get_n_seq_max() const { return n_seq_max; }
     uint32_t       get_n_swa()    const { return n_swa; }
     llama_swa_type get_swa_type() const { return swa_type; }
@@ -79,7 +77,6 @@ private:

     const uint32_t n_stream  = 1;
     const uint32_t n_seq_max = 1;
-    const uint32_t n_pad     = 1;

     const uint32_t       n_swa    = 0;
     const llama_swa_type swa_type = LLAMA_SWA_TYPE_NONE;
diff --git a/src/llama-kv-cache.cpp b/src/llama-kv-cache.cpp
index 61b5cb370..e108f0423 100644
--- a/src/llama-kv-cache.cpp
+++ b/src/llama-kv-cache.cpp
@@ -73,7 +73,6 @@ llama_kv_cache::llama_kv_cache(
                      bool   unified,
                  uint32_t   kv_size,
                  uint32_t   n_seq_max,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
            llama_memory_t   mem_other,
@@ -82,7 +81,7 @@ llama_kv_cache::llama_kv_cache(
     const  layer_share_cb & share,
                const char * name_tag) :
     model(model), hparams(hparams), v_trans(v_trans),
-    n_seq_max(n_seq_max), n_stream(unified ? 1 : n_seq_max), n_pad(n_pad), n_swa(n_swa), swa_type(swa_type),
+    n_seq_max(n_seq_max), n_stream(unified ? 1 : n_seq_max), n_swa(n_swa), swa_type(swa_type),
     ctxs_bufs(no_alloc),
     other(static_cast<llama_kv_cache *>(mem_other)),
     v_cells_impl(other ? other->v_cells_impl : std::make_shared<llama_kv_cells_vec>()),
@@ -99,8 +98,6 @@ llama_kv_cache::llama_kv_cache(
         }
     }

-    GGML_ASSERT(kv_size % n_pad == 0);
-
     const uint32_t n_layer = hparams.n_layer_all;

     // define a comparator for the buft -> ctx map to ensure that the order is well-defined:
@@ -1260,12 +1257,12 @@ uint32_t llama_kv_cache::get_n_kv(const slot_info & sinfo) const {

     // pad the n_kv value so that the graph remains constant across batches and can be reused
     // note: this also helps some backends with performance (f.ex https://github.com/ggml-org/llama.cpp/pull/16812#issuecomment-3455112220)
-    const uint32_t n_pad_cur = std::max(n_pad, 256u);
+    const uint32_t n_pad = 256;

     for (uint32_t s = 0; s < sinfo.n_stream(); ++s) {
         const auto & cells = v_cells[sinfo.strm[s]];

-        result = std::max(std::min(cells.size(), std::max(n_pad_cur, GGML_PAD(cells.used_max_p1(), n_pad_cur))), result);
+        result = std::max(std::min(cells.size(), std::max(n_pad, GGML_PAD(cells.used_max_p1(), n_pad))), result);
     }

     return result;
diff --git a/src/llama-kv-cache.h b/src/llama-kv-cache.h
index b31cc226d..60d2e183c 100644
--- a/src/llama-kv-cache.h
+++ b/src/llama-kv-cache.h
@@ -107,7 +107,6 @@ public:
                          bool   unified,
                      uint32_t   kv_size,
                      uint32_t   n_seq_max,
-                     uint32_t   n_pad,
                      uint32_t   n_swa,
                llama_swa_type   swa_type,
                llama_memory_t   mem_other,
@@ -272,9 +271,6 @@ private:
     const uint32_t n_seq_max = 1;
     const uint32_t n_stream  = 1;

-    // required padding
-    const uint32_t n_pad = 1;
-
     // SWA
     const uint32_t n_swa = 0;

diff --git a/src/llama-memory-hybrid-idx.cpp b/src/llama-memory-hybrid-idx.cpp
index 03f0c342d..da1747649 100644
--- a/src/llama-memory-hybrid-idx.cpp
+++ b/src/llama-memory-hybrid-idx.cpp
@@ -24,7 +24,6 @@ llama_memory_hybrid_idx::llama_memory_hybrid_idx(
                 ggml_type   type_v,
                      bool   v_trans,
                  uint32_t   kv_size,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
                             /* recurrent */
@@ -43,7 +42,7 @@ llama_memory_hybrid_idx::llama_memory_hybrid_idx(
     llama_memory_hybrid(
         model,
         no_alloc,
-        type_k, type_v, v_trans, kv_size, n_pad, n_swa, swa_type,
+        type_k, type_v, v_trans, kv_size, n_swa, swa_type,
         type_r, type_s, rs_size,
         n_seq_max, n_rs_seq, offload, unified,
         filter_attn, filter_recr),
@@ -67,7 +66,7 @@ llama_memory_hybrid_idx::llama_memory_hybrid_idx(

         return new llama_kv_cache(
             model, no_alloc, hparams_idx, type_k, type_v, v_trans, offload, unified,
-            kv_size, n_seq_max, n_pad, n_swa, swa_type,
+            kv_size, n_seq_max, n_swa, swa_type,
             nullptr, filter_idx, nullptr, nullptr, "idx_");
     }()) {}

diff --git a/src/llama-memory-hybrid-idx.h b/src/llama-memory-hybrid-idx.h
index faa1724b0..59940dbb8 100644
--- a/src/llama-memory-hybrid-idx.h
+++ b/src/llama-memory-hybrid-idx.h
@@ -24,7 +24,6 @@ public:
                 ggml_type   type_v,
                      bool   v_trans,
                  uint32_t   kv_size,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
                             /* recurrent */
diff --git a/src/llama-memory-hybrid-iswa.cpp b/src/llama-memory-hybrid-iswa.cpp
index 4c0f14c22..6d843c76e 100644
--- a/src/llama-memory-hybrid-iswa.cpp
+++ b/src/llama-memory-hybrid-iswa.cpp
@@ -18,7 +18,6 @@ llama_memory_hybrid_iswa::llama_memory_hybrid_iswa(
                      bool   swa_full,
                  uint32_t   kv_size,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
                             /* recurrent */
                 ggml_type   type_r,
                 ggml_type   type_s,
@@ -44,7 +43,6 @@ llama_memory_hybrid_iswa::llama_memory_hybrid_iswa(
         kv_size,
         n_seq_max,
         n_ubatch,
-        n_pad,
         nullptr,
         filter_attn == nullptr ?
             [&](int32_t il) { return !hparams.is_recr(il); }
diff --git a/src/llama-memory-hybrid-iswa.h b/src/llama-memory-hybrid-iswa.h
index 6e68f3f44..52c885ac9 100644
--- a/src/llama-memory-hybrid-iswa.h
+++ b/src/llama-memory-hybrid-iswa.h
@@ -28,7 +28,6 @@ public:
                      bool   swa_full,
                  uint32_t   kv_size,
                  uint32_t   n_ubatch,
-                 uint32_t   n_pad,
                             /* recurrent */
                 ggml_type   type_r,
                 ggml_type   type_s,
diff --git a/src/llama-memory-hybrid.cpp b/src/llama-memory-hybrid.cpp
index 0361b23ca..7d3b27908 100644
--- a/src/llama-memory-hybrid.cpp
+++ b/src/llama-memory-hybrid.cpp
@@ -16,7 +16,6 @@ llama_memory_hybrid::llama_memory_hybrid(
                 ggml_type   type_v,
                      bool   v_trans,
                  uint32_t   kv_size,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
                             /* recurrent */
@@ -43,7 +42,6 @@ llama_memory_hybrid::llama_memory_hybrid(
         unified,
         kv_size,
         n_seq_max,
-        n_pad,
         n_swa,
         swa_type,
         nullptr,
diff --git a/src/llama-memory-hybrid.h b/src/llama-memory-hybrid.h
index 74fa89ea6..2b4d1269c 100644
--- a/src/llama-memory-hybrid.h
+++ b/src/llama-memory-hybrid.h
@@ -26,7 +26,6 @@ public:
                 ggml_type   type_v,
                      bool   v_trans,
                  uint32_t   kv_size,
-                 uint32_t   n_pad,
                  uint32_t   n_swa,
            llama_swa_type   swa_type,
                             /* recurrent */
diff --git a/src/llama-model.cpp b/src/llama-model.cpp
index 78a387e5d..0220c5ab8 100644
--- a/src/llama-model.cpp
+++ b/src/llama-model.cpp
@@ -2842,7 +2842,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                         cparams.kv_unified,
                         cparams.n_ctx_seq,
                         cparams.n_seq_max,
-                        1,
                         hparams.n_swa,
                         hparams.swa_type,
                         nullptr,
@@ -2870,7 +2869,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.kv_unified,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
-                            1,
                             hparams.n_swa,
                             hparams.swa_type,
                             nullptr,
@@ -2896,7 +2894,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.kv_unified,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
-                            1,
                             hparams.n_swa,
                             hparams.swa_type,
                             filter_mla,
@@ -2935,7 +2932,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                     /* attn_type_v       */ params.type_v,
                     /* attn_v_trans      */ !cparams.flash_attn,
                     /* attn_kv_size      */ cparams.n_ctx_seq,
-                    /* attn_n_pad        */ 1,
                     /* attn_n_swa        */ hparams.n_swa,
                     /* attn_swa_type     */ hparams.swa_type,
                     /* recurrent_type_r  */ GGML_TYPE_F32,
@@ -2964,7 +2960,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.kv_unified,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
-                            1,
                             hparams.n_swa,
                             hparams.swa_type,
                             nullptr,
@@ -2985,7 +2980,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.kv_unified,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
-                            1,
                             hparams.n_swa,
                             hparams.swa_type,
                             nullptr,
@@ -3013,7 +3007,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.kv_unified,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
-                            1,
                             hparams.n_swa,
                             hparams.swa_type,
                             nullptr,
@@ -3040,7 +3033,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
                             cparams.n_ubatch,
-                            1,
                             filter_mla,
                             filter_lid,
                             nullptr);
@@ -3068,7 +3060,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
                             cparams.n_ubatch,
-                            1,
                             nullptr,
                             filter_mtp,
                             nullptr,
@@ -3086,7 +3077,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
                             cparams.n_ubatch,
-                            1,
                             cparams.n_rs_seq,
                             nullptr,
                             nullptr);
@@ -3110,7 +3100,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             cparams.n_ctx_seq,
                             cparams.n_seq_max,
                             cparams.n_ubatch,
-                            1,
                             nullptr,
                             nullptr,
                             nullptr,
@@ -3198,7 +3187,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             /* attn_swa_full     */ params.swa_full,
                             /* attn_kv_size      */ cparams.n_ctx_seq,
                             /* attn_n_ubatch     */ cparams.n_ubatch,
-                            /* attn_n_pad        */ 1,
                             /* recurrent_type_r  */ GGML_TYPE_F32,
                             /* recurrent_type_s  */ GGML_TYPE_F32,
                             /* recurrent_rs_size */ std::max((uint32_t) 1, cparams.n_seq_max),
@@ -3217,7 +3205,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             /* attn_type_v       */ params.type_v,
                             /* attn_v_trans      */ !cparams.flash_attn,
                             /* attn_kv_size      */ cparams.n_ctx_seq,
-                            /* attn_n_pad        */ 1,
                             /* attn_n_swa        */ hparams.n_swa,
                             /* attn_swa_type     */ hparams.swa_type,
                             /* recurrent_type_k  */ GGML_TYPE_F32,
@@ -3238,7 +3225,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                             /* attn_type_v       */ params.type_v,
                             /* attn_v_trans      */ !cparams.flash_attn,
                             /* attn_kv_size      */ cparams.n_ctx_seq,
-                            /* attn_n_pad        */ 1,
                             /* attn_n_swa        */ hparams.n_swa,
                             /* attn_swa_type     */ hparams.swa_type,
                             /* recurrent_type_k  */ GGML_TYPE_F32,
@@ -3310,7 +3296,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                                     cparams.n_ctx_seq,
                                     cparams.n_seq_max,
                                     cparams.n_ubatch,
-                                    1,
                                     mem_other,
                                     filter,
                                     reuse,
@@ -3328,7 +3313,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                                     cparams.n_ctx_seq,
                                     cparams.n_seq_max,
                                     cparams.n_ubatch,
-                                    1,
                                     nullptr,
                                     filter,
                                     reuse,
@@ -3348,7 +3332,6 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
                                 cparams.kv_unified,
                                 cparams.n_ctx_seq,
                                 cparams.n_seq_max,
-                                1,
                                 hparams.n_swa,
                                 hparams.swa_type,
                                 nullptr,