sobelio / llm-chain

`llm-chain` is a powerful rust crate for building chains in large language models allowing you to summarise text and complete complex tasks
https://llm-chain.xyz
MIT License
1.27k stars 127 forks source link

fix segfault in tensor split #251

Closed andychenbruce closed 6 months ago

andychenbruce commented 6 months ago

This only affects if using CUDA with llama.cpp.

Passing in a empty vector (instead of null) to tensor_split into the model parameters causes it to segfault. Passing a nullptr is fine and will cause llama.cpp use some default settings for tensor_split. Passing a empty vector by Vec::new() doesn't allocate any memory but also isn't a nullptr, it goes to 0x04 for some reason, then the c++ code in llama.cpp only check is == nullptr which 0x04 passes and then causes llama.cpp to segfault.

Make the tensor_split an Option<Vec<32>> works better since then you can just pass in a null for the None case.