Skip to content

Commit b501665

Browse files
authored
Add validation for tensor_split size exceeding LLAMA_MAX_DEVICES (ggml-org#820)
* Add validation for tensor_split size exceeding LLAMA_MAX_DEVICES * reword
1 parent f30aa20 commit b501665

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llama_cpp/llama.py

+2
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 that exceed 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)