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);
}
}

View file

@ -39,7 +39,7 @@ static void batch_decode(llama_context * ctx, llama_batch & batch, float * outpu
const struct llama_model * model = llama_get_model(ctx);
// clear previous kv_cache values (irrelevant for embeddings)
llama_kv_self_clear(ctx);
llama_memory_clear(llama_get_memory(ctx),true);
// run model
if(embeddings_debug)
@ -144,7 +144,7 @@ bool embeddingstype_load_model(const embeddings_load_model_inputs inputs)
}
std::vector<int> tmp = {1, 2, 3, 4};
llama_kv_self_clear(embeddings_ctx);
llama_memory_clear(llama_get_memory(embeddings_ctx),true);
auto er = llama_decode(embeddings_ctx, llama_batch_get_one(tmp.data(), tmp.size()));
if(er!=0)
{
@ -185,7 +185,7 @@ embeddings_generation_outputs embeddingstype_generate(const embeddings_generatio
double timetaken = 0;
timer_start();
llama_kv_self_clear(embeddings_ctx);
llama_memory_clear(llama_get_memory(embeddings_ctx),true);
std::string prompt = inputs.prompt;
// max batch size

View file

@ -560,7 +560,7 @@ bool ttstype_load_model(const tts_load_model_inputs inputs)
}
std::vector<int> tmp = {1, 2, 3, 4};
llama_kv_self_clear(ttc_ctx);
llama_memory_clear(llama_get_memory(ttc_ctx),true);
auto er = llama_decode(ttc_ctx, llama_batch_get_one(tmp.data(), tmp.size()));
if(er!=0)
{
@ -619,8 +619,8 @@ tts_generation_outputs ttstype_generate(const tts_generation_inputs inputs)
const std::string sampletext = (custom_speaker_text=="")?process_text("but that is what it is",ttsver):process_text(custom_speaker_text,ttsver);
// process prompt and generate voice codes
llama_kv_self_clear(ttc_ctx);
llama_kv_self_clear(cts_ctx);
llama_memory_clear(llama_get_memory(ttc_ctx),true);
llama_memory_clear(llama_get_memory(cts_ctx),true);
std::vector<llama_token> prompt_inp;
prompt_init(prompt_inp, ttcvocab);
@ -818,7 +818,7 @@ tts_generation_outputs ttstype_generate(const tts_generation_inputs inputs)
}
}
guide_tokens.clear();
llama_kv_self_clear(ttc_ctx);
llama_memory_clear(llama_get_memory(ttc_ctx),true);
prompt_init(prompt_inp, ttcvocab);
next_token_uses_guide_token = true;
}