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

Class BaseLlamaCache

llama_cpp/llama_cache.py:17–46  ·  view source on GitHub ↗

Base cache class for a llama.cpp model.

Source from the content-addressed store, hash-verified

15
16
17class BaseLlamaCache(ABC):
18 """Base cache class for a llama.cpp model."""
19
20 def __init__(self, capacity_bytes: int = (2 << 30)):
21 self.capacity_bytes = capacity_bytes
22
23 @property
24 @abstractmethod
25 def cache_size(self) -> int:
26 raise NotImplementedError
27
28 def _find_longest_prefix_key(
29 self,
30 key: Tuple[int, ...],
31 ) -> Optional[Tuple[int, ...]]:
32 pass
33
34 @abstractmethod
35 def __getitem__(self, key: Sequence[int]) -> "llama_cpp.llama.LlamaState":
36 raise NotImplementedError
37
38 @abstractmethod
39 def __contains__(self, key: Sequence[int]) -> bool:
40 raise NotImplementedError
41
42 @abstractmethod
43 def __setitem__(
44 self, key: Sequence[int], value: "llama_cpp.llama.LlamaState"
45 ) -> None:
46 raise NotImplementedError
47
48
49class LlamaRAMCache(BaseLlamaCache):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…