@@ -60,6 +60,8 @@ int main(int argc, char ** argv) {
60
60
llama_model * model = llama_init.model .get ();
61
61
llama_context * ctx = llama_init.context .get ();
62
62
63
+ auto * mem = llama_get_memory (ctx);
64
+
63
65
const llama_vocab * vocab = llama_model_get_vocab (model);
64
66
65
67
// Tokenize the prompt
@@ -94,7 +96,7 @@ int main(int argc, char ** argv) {
94
96
llama_decode (ctx, llama_batch_get_one (&inp.back (), 1 ));
95
97
96
98
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 );
98
100
}
99
101
100
102
const auto t_enc_end = ggml_time_us ();
@@ -427,17 +429,17 @@ int main(int argc, char ** argv) {
427
429
428
430
// KV cache management
429
431
// 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 );
431
433
432
434
if (seq_id_best != 0 ) {
433
435
// if a verification token matched, we keep the best sequence and remove the rest
434
436
// 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 );
438
440
439
441
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 );
441
443
}
442
444
}
443
445
}
0 commit comments