@@ -60,6 +60,8 @@ int main(int argc, char ** argv) {
6060 llama_model * model = llama_init.model .get ();
6161 llama_context * ctx = llama_init.context .get ();
6262
63+ auto * mem = llama_get_memory (ctx);
64+
6365 const llama_vocab * vocab = llama_model_get_vocab (model);
6466
6567 // Tokenize the prompt
@@ -94,7 +96,7 @@ int main(int argc, char ** argv) {
9496 llama_decode (ctx, llama_batch_get_one (&inp.back (), 1 ));
9597
9698 for (int s = 1 ; s < W + G + 1 ; ++s) {
97- llama_kv_self_seq_cp (ctx , 0 , s, -1 , -1 );
99+ llama_memory_seq_cp (mem , 0 , s, -1 , -1 );
98100 }
99101
100102 const auto t_enc_end = ggml_time_us ();
@@ -427,17 +429,17 @@ int main(int argc, char ** argv) {
427429
428430 // KV cache management
429431 // if no verification token matched, we simply remove all cells from this batch -> no fragmentation
430- llama_kv_self_seq_rm (ctx , -1 , n_past, -1 );
432+ llama_memory_seq_rm (mem , -1 , n_past, -1 );
431433
432434 if (seq_id_best != 0 ) {
433435 // if a verification token matched, we keep the best sequence and remove the rest
434436 // this leads to some KV cache fragmentation
435- llama_kv_self_seq_keep (ctx , seq_id_best);
436- llama_kv_self_seq_cp (ctx , seq_id_best, 0 , -1 , -1 );
437- llama_kv_self_seq_rm (ctx , seq_id_best, -1 , -1 );
437+ llama_memory_seq_keep (mem , seq_id_best);
438+ llama_memory_seq_cp (mem , seq_id_best, 0 , -1 , -1 );
439+ llama_memory_seq_rm (mem , seq_id_best, -1 , -1 );
438440
439441 for (int s = 1 ; s < W + G + 1 ; ++s) {
440- llama_kv_self_seq_cp (ctx , 0 , s, -1 , -1 );
442+ llama_memory_seq_cp (mem , 0 , s, -1 , -1 );
441443 }
442444 }
443445 }
0 commit comments