MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / _truncate_memory

Method _truncate_memory

examples/server/server.py:2381–2396  ·  view source on GitHub ↗
(self, seq_id: int, keep_len: int)

Source from the content-addressed store, hash-verified

2379 self.ready_pos[seq_id] = self.verify_h_pos[seq_id][row] + 1
2380
2381 def _truncate_memory(self, seq_id: int, keep_len: int) -> None:
2382 if seq_id < 0 or seq_id >= self.n_seq_max:
2383 return
2384 if self.is_mem_shared:
2385 self.context_pos[seq_id] = min(self.context_pos[seq_id], keep_len)
2386 return
2387 if not llama_cpp.llama_memory_seq_rm(
2388 self.mem,
2389 seq_id,
2390 keep_len,
2391 -1,
2392 ):
2393 raise RuntimeError(
2394 f"failed to truncate MTP draft sequence {seq_id} at position {keep_len}"
2395 )
2396 self.context_pos[seq_id] = min(self.context_pos[seq_id], keep_len)
2397
2398 def truncate(self, seq_id: int, keep_len: int) -> None:
2399 if seq_id < 0 or seq_id >= self.n_seq_max:

Callers 3

process_sampled_batchMethod · 0.95
truncateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected