Base cache class for a llama.cpp model.
| 15 | |
| 16 | |
| 17 | class 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 | |
| 49 | class LlamaRAMCache(BaseLlamaCache): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…