From ac8e77d82e0e9b6f24744b5a97437976cfe19737 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Tue, 9 Jun 2026 22:33:00 +0800 Subject: [PATCH] Revert "cleanup round 2" This reverts commit c7e39f9c9793064b02221342198b8a28d4fbeb50. --- gpttype_adapter.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/gpttype_adapter.cpp b/gpttype_adapter.cpp index b35fda538..e76ecd537 100644 --- a/gpttype_adapter.cpp +++ b/gpttype_adapter.cpp @@ -4512,9 +4512,6 @@ static void PrepareMediaEmbds(const int nctx, const std::vector & media_int { printf("\nMTMD Media %i used Tokens: %d, Positions: %d, Boundary Tokens: %d",i,mediatokensneeded,mediaposneeded,boundarytokensneeded); } - // Media chunks have two sizes: placeholder/embed tokens and KV positions. - // Text wrapper tokens consume both equally, so add them after taking the - // larger media-side requirement. int mediactxneeded = std::max(mediatokensneeded, mediaposneeded) + boundarytokensneeded; if(i==0) { @@ -5028,15 +5025,11 @@ generation_outputs gpttype_generate(const generation_inputs inputs) } //shorten memory if needed - const int media_context_size = std::max((int)last_media_mem.size(), last_media_pos_count); - const int media_context_extra = media_context_size - (int)last_media_mem.size(); - if (embd_inp_mem.size() + media_context_extra + kcpp_data->n_predict + 4 > nctx) + if (embd_inp_mem.size() + kcpp_data->n_predict + 4 > nctx) { - int limit = nctx - (kcpp_data->n_predict + 4) - media_context_extra; - const int protected_media_prefix = (int)last_media_mem.size() + (bos.empty() ? 0 : 1); - limit = std::max(limit, protected_media_prefix); - if (embd_inp_mem.size() > (size_t)limit) { - embd_inp_mem.resize((size_t)limit); + int limit = nctx - (kcpp_data->n_predict + 4); + if (embd_inp_mem.size() > limit) { + embd_inp_mem.resize(limit); } } }