update deprecated apis

This commit is contained in:
Concedo 2025-06-13 22:21:15 +08:00
parent 4204f111f7
commit c494525b33
3 changed files with 22 additions and 22 deletions

View file

@ -522,10 +522,10 @@ void ContextRewind(std::vector<int> &embd, std::vector<int> &current_context_tok
if (file_format == FileFormat::GGUF_GENERIC)
{
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(llama_ctx_v4), 0, n_past, -1);
if(draft_ctx)
{
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(draft_ctx), 0, n_past, -1);
}
}
@ -1866,12 +1866,12 @@ void PurgeMissingTokens(llama_context * ctx, llama_context * draft_ctx, std::vec
//extract the unwanted tokens out from context and KV
int diff = found - trimstart;
llama_kv_self_seq_rm(ctx, 0, trimstart, trimstart + diff);
llama_kv_self_seq_add(ctx, 0, trimstart + diff, -1, -diff);
llama_memory_seq_rm(llama_get_memory(ctx), 0, trimstart, trimstart + diff);
llama_memory_seq_add(llama_get_memory(ctx), 0, trimstart + diff, -1, -diff);
if(draft_ctx)
{
llama_kv_self_seq_rm(draft_ctx, 0, trimstart, trimstart + diff);
llama_kv_self_seq_add(draft_ctx, 0, trimstart + diff, -1, -diff);
llama_memory_seq_rm(llama_get_memory(draft_ctx), 0, trimstart, trimstart + diff);
llama_memory_seq_add(llama_get_memory(draft_ctx), 0, trimstart + diff, -1, -diff);
}
for (size_t i = trimstart + diff; i < current_context_tokens.size() - 1; i++)
@ -2475,14 +2475,14 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in
for (int i = 1; i <= 33; ++i) {
tmp.push_back(i);
}
llama_kv_self_clear(llama_ctx_v4);
llama_memory_clear(llama_get_memory(llama_ctx_v4),true);
auto er = llama_decode(llama_ctx_v4, llama_batch_get_one(tmp.data(), tmp.size()));
if(er!=0)
{
printf("\nModel Warmup Failed! (code:%d)\n",er);
}
tmp = {1};
llama_kv_self_clear(llama_ctx_v4);
llama_memory_clear(llama_get_memory(llama_ctx_v4),true);
er = llama_decode(llama_ctx_v4, llama_batch_get_one(tmp.data(), tmp.size()));
if(er!=0)
{
@ -3442,7 +3442,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
int guidance_n_past = 0;
if(guidance_ctx)
{
llama_kv_self_clear(guidance_ctx);
llama_memory_clear(llama_get_memory(guidance_ctx),true);
//prepare negative prompt
if(negative_prompt!="" && inputs.guidance_scale!=1.0f)
{
@ -3552,10 +3552,10 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
{
if(n_past==0)
{
llama_kv_self_clear(llama_ctx_v4);
llama_memory_clear(llama_get_memory(llama_ctx_v4),true);
if(draft_ctx)
{
llama_kv_self_clear(draft_ctx);
llama_memory_clear(llama_get_memory(draft_ctx),true);
}
}
else if(embd_inp.size()==0)
@ -3582,10 +3582,10 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
}
if(file_format == FileFormat::GGUF_GENERIC)
{
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(llama_ctx_v4), 0, n_past, -1);
if(draft_ctx)
{
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(draft_ctx), 0, n_past, -1);
}
}
}
@ -4130,9 +4130,9 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
//if we have somehow skipped ahead (e.g drafting), ensure that all tokens after npast are purged
if (file_format == FileFormat::GGUF_GENERIC && draft_used)
{
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(llama_ctx_v4), 0, n_past, -1);
if (draft_ctx) {
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
llama_memory_seq_rm(llama_get_memory(draft_ctx), 0, n_past, -1);
}
}