Support new 230519 llama.cpp

This commit is contained in:
niansa/tuxifan 2023-05-20 14:30:08 +02:00 committed by AT
parent 071d42dd4e
commit c1157f285f
6 changed files with 28 additions and 14 deletions

11
.gitmodules vendored
View File

@ -1,6 +1,9 @@
[submodule "llama.cpp"] [submodule "llama.cpp-230519"]
path = gpt4all-backend/llama.cpp path = gpt4all-backend/llama.cpp-230519
url = https://github.com/ggerganov/llama.cpp.git url = https://github.com/ggerganov/llama.cpp.git
[submodule "llama.cpp-old"] [submodule "llama.cpp-230511"]
path = gpt4all-backend/llama.cpp-old path = gpt4all-backend/llama.cpp-230511
url = https://github.com/manyoso/llama.cpp.git url = https://github.com/manyoso/llama.cpp.git
[submodule "llama.cpp-mainline"]
path = gpt4all-backend/llama.cpp-mainline
url = https://github.com/ggerganov/llama.cpp.git

View File

@ -54,8 +54,9 @@ foreach(BUILD_VARIANT IN LISTS BUILD_VARIANTS)
set(LLAMA_FMA ${GPT4ALL_ALLOW_NON_AVX}) set(LLAMA_FMA ${GPT4ALL_ALLOW_NON_AVX})
# Include GGML # Include GGML
include_ggml(llama.cpp-old -old-${BUILD_VARIANT} ON) include_ggml(llama.cpp-mainline -mainline-${BUILD_VARIANT} ON)
include_ggml(llama.cpp -${BUILD_VARIANT} ON) include_ggml(llama.cpp-230511 -230511-${BUILD_VARIANT} ON)
include_ggml(llama.cpp-230519 -230519-${BUILD_VARIANT} ON)
# Function for preparing individual implementations # Function for preparing individual implementations
function(prepare_target TARGET_NAME BASE_LIB) function(prepare_target TARGET_NAME BASE_LIB)
@ -73,21 +74,29 @@ foreach(BUILD_VARIANT IN LISTS BUILD_VARIANTS)
endfunction() endfunction()
# Add each individual implementations # Add each individual implementations
add_library(llamamodel-${BUILD_VARIANT} SHARED add_library(llamamodel-mainline-${BUILD_VARIANT} SHARED
llamamodel.cpp) llamamodel.cpp)
prepare_target(llamamodel llama) target_compile_definitions(llamamodel-mainline-${BUILD_VARIANT} PRIVATE
LLAMA_VERSIONS=>=3)
prepare_target(llamamodel-mainline llama-mainline)
add_library(llamamodel-old-${BUILD_VARIANT} SHARED add_library(llamamodel-230519-${BUILD_VARIANT} SHARED
llamamodel.cpp)
target_compile_definitions(llamamodel-230519-${BUILD_VARIANT} PRIVATE
LLAMA_VERSIONS===2)
prepare_target(llamamodel-230519 llama-230519)
add_library(llamamodel-230511-${BUILD_VARIANT} SHARED
llamamodel_old.cpp) llamamodel_old.cpp)
prepare_target(llamamodel-old llama-old) prepare_target(llamamodel-230511 llama-230511)
add_library(gptj-${BUILD_VARIANT} SHARED add_library(gptj-${BUILD_VARIANT} SHARED
gptj.cpp) gptj.cpp)
prepare_target(gptj ggml-old) prepare_target(gptj ggml-230511)
add_library(mpt-${BUILD_VARIANT} SHARED add_library(mpt-${BUILD_VARIANT} SHARED
mpt.cpp) mpt.cpp)
prepare_target(mpt ggml-old) prepare_target(mpt ggml-230511)
endforeach() endforeach()
add_library(llmodel add_library(llmodel

@ -0,0 +1 @@
Subproject commit ea600071cb005267e9e8f2629c1e406dd5fde083

View File

@ -147,7 +147,8 @@ size_t LLamaModel::saveState(uint8_t *dest) const
size_t LLamaModel::restoreState(const uint8_t *src) size_t LLamaModel::restoreState(const uint8_t *src)
{ {
return llama_set_state_data(d_ptr->ctx, src); // const_cast is required, see: https://github.com/ggerganov/llama.cpp/pull/1540
return llama_set_state_data(d_ptr->ctx, const_cast<uint8_t*>(src));
} }
void LLamaModel::prompt(const std::string &prompt, void LLamaModel::prompt(const std::string &prompt,
@ -346,7 +347,7 @@ bool magic_match(std::istream& f) {
// Check version // Check version
uint32_t version = 0; uint32_t version = 0;
f.read(reinterpret_cast<char*>(&version), sizeof(version)); f.read(reinterpret_cast<char*>(&version), sizeof(version));
return version >= 2; return version LLAMA_VERSIONS;
} }
LLModel *construct() { LLModel *construct() {