Skip to content

Commit 89f59f2

Browse files
committed
Add validation for tensor_split size exceeding LLAMA_MAX_DEVICES
1 parent f30aa20 commit 89f59f2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llama_cpp/llama.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ def __init__(
308308
self.tensor_split = tensor_split
309309
self._p_tensor_split = None
310310
if self.tensor_split is not None:
311+
if len(self.tensor_split) > llama_cpp.LLAMA_MAX_DEVICES:
312+
raise ValueError(f"Attempt to split tensors above the maximum supported devices. Current LLAMA_MAX_DEVICES={llama_cpp.LLAMA_MAX_DEVICES}")
311313
# Type conversion and expand the list to the length of LLAMA_MAX_DEVICES
312314
FloatArray = ctypes.c_float * llama_cpp.LLAMA_MAX_DEVICES
313315
self._c_tensor_split = FloatArray(

0 commit comments

Comments
 (0)