MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / seq_keep

Method seq_keep

smallthinker/src/llama-kv-cache-recurrent.cpp:238–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void llama_kv_cache_recurrent::seq_keep(llama_seq_id seq_id) {
239 uint32_t new_head = size;
240
241 for (uint32_t i = 0; i < size; ++i) {
242 if ((llama_seq_id) i != seq_id) {
243 cells[i].tail = -1;
244 }
245
246 if (!cells[i].has_seq_id(seq_id)) {
247 if (cells[i].pos >= 0) {
248 used--;
249 }
250
251 cells[i].pos = -1;
252 cells[i].src = -1;
253 cells[i].seq_id.clear();
254
255 if (new_head == size){
256 new_head = i;
257 }
258 } else {
259 cells[i].seq_id.clear();
260 cells[i].seq_id.insert(seq_id);
261 }
262 }
263
264 // If we freed up a slot, set head to it so searching can start there.
265 if (new_head != size && new_head < head) {
266 head = new_head;
267 }
268}
269
270void llama_kv_cache_recurrent::seq_add(llama_seq_id seq_id, llama_pos p0, llama_pos p1, llama_pos shift) {
271 if (shift == 0) {

Callers

nothing calls this directly

Calls 3

has_seq_idMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected