Skip to content

Commit 781790f

Browse files
committed
fix(HybridCheckpointCache): ValueError: bytes must be in range(0, 256)
1 parent 0acb224 commit 781790f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

llama_cpp/llama_cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from abc import ABC, abstractmethod
2+
import array
23
from collections import OrderedDict
34
import ctypes
45
from dataclasses import dataclass
@@ -383,7 +384,7 @@ def _hash_prefix(self, tokens: List[int], length: int) -> str:
383384
tokens_size = len(tokens)
384385
if length > tokens_size:
385386
length = tokens_size
386-
data = bytes(tokens[:length])
387+
data = array.array('i', tokens[:length]).tobytes()
387388
return hashlib.sha256(data).hexdigest()[:32]
388389

389390
def find_best_checkpoint(self, tokens: List[int], seq_id: int = 0) -> Optional[HybridCheckpoint]:

0 commit comments

Comments
 (0)