Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update llama.cpp #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 00-llama-cpp-enable-main.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 427015be..e945a722 100644
index 79370912..a3c3bc00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1157,6 +1157,7 @@ endif()
@@ -188,6 +188,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/llama.pc"
#

add_subdirectory(common)
Expand All @@ -11,11 +11,11 @@ index 427015be..e945a722 100644
if (LLAMA_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
include(CTest)
diff --git a/examples/main/main.cpp b/examples/main/main.cpp
index 0ed4d79f..74b77cc9 100644
index a0d817b1..5dff0482 100644
--- a/examples/main/main.cpp
+++ b/examples/main/main.cpp
@@ -911,6 +911,9 @@ int main(int argc, char ** argv) {
llama_save_session_file(ctx, path_session.c_str(), session_tokens.data(), session_tokens.size());
@@ -975,6 +975,9 @@ int main(int argc, char ** argv) {
llama_state_save_file(ctx, path_session.c_str(), session_tokens.data(), session_tokens.size());
}

+ printf("\n");
Expand Down
6 changes: 3 additions & 3 deletions build-multi-thread.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
LLAMA_CPP_WASM_BUILD_DIR=build
LLAMA_CPP_WASM_DIST_DIR=dist
LLAMA_CPP_WASM_DIST_LLAMA_DIR=$LLAMA_CPP_WASM_DIST_DIR/llama-mt
LLAMA_CPP_GIT_HASH="8c933b7"
LLAMA_CPP_GIT_HASH="081fe43"
LLAMA_CPP_SOURCE_DIR=$LLAMA_CPP_WASM_BUILD_DIR/llama.cpp
LLAMA_CPP_BUILD_DIR=$LLAMA_CPP_WASM_BUILD_DIR/build

Expand All @@ -29,7 +29,7 @@ emcc --clear-cache
emcmake cmake ../../$LLAMA_CPP_SOURCE_DIR
# export EMCC_CFLAGS="-O3 -pthread -DNDEBUG -flto -s SHARED_MEMORY=1 -s EXPORT_ALL=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s INITIAL_MEMORY=2GB -s MAXIMUM_MEMORY=4GB -s ALLOW_MEMORY_GROWTH -s FORCE_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=_main -s EXPORTED_RUNTIME_METHODS=callMain -s NO_EXIT_RUNTIME=1"
export EMCC_CFLAGS="-O3 -msimd128 -pthread -fno-rtti -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=32 -DNDEBUG -flto=full -s SHARED_MEMORY=1 -s EXPORT_ALL=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s INITIAL_MEMORY=800MB -s MAXIMUM_MEMORY=4GB -s ALLOW_MEMORY_GROWTH -s FORCE_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=_main -s EXPORTED_RUNTIME_METHODS=callMain -s NO_EXIT_RUNTIME=1"
emmake make main -j
emmake make llama-cli -j
cd ../..

#
Expand All @@ -41,7 +41,7 @@ fi

mkdir -p $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp -rv src/llama/* $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp $LLAMA_CPP_BUILD_DIR/bin/main.* $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp $LLAMA_CPP_BUILD_DIR/bin/llama-cli.* $LLAMA_CPP_WASM_DIST_LLAMA_DIR

rm -rf docs/llama-mt
cp -rv $LLAMA_CPP_WASM_DIST_LLAMA_DIR docs/
6 changes: 3 additions & 3 deletions build-single-thread.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
LLAMA_CPP_WASM_BUILD_DIR=build
LLAMA_CPP_WASM_DIST_DIR=dist
LLAMA_CPP_WASM_DIST_LLAMA_DIR=$LLAMA_CPP_WASM_DIST_DIR/llama-st
LLAMA_CPP_GIT_HASH="8c933b7"
LLAMA_CPP_GIT_HASH="081fe43"
LLAMA_CPP_SOURCE_DIR=$LLAMA_CPP_WASM_BUILD_DIR/llama.cpp
LLAMA_CPP_BUILD_DIR=$LLAMA_CPP_WASM_BUILD_DIR/build

Expand All @@ -29,7 +29,7 @@ emcc --clear-cache
emcmake cmake ../../$LLAMA_CPP_SOURCE_DIR
# export EMCC_CFLAGS="-O3 -DNDEBUG -flto -s BUILD_AS_WORKER=1 -s EXPORT_ALL=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s INITIAL_MEMORY=2GB -s MAXIMUM_MEMORY=4GB -s ALLOW_MEMORY_GROWTH -s FORCE_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=_main -s EXPORTED_RUNTIME_METHODS=callMain -s NO_EXIT_RUNTIME=1"
export EMCC_CFLAGS="-O3 -msimd128 -fno-rtti -DNDEBUG -flto=full -s BUILD_AS_WORKER=1 -s EXPORT_ALL=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s INITIAL_MEMORY=800MB -s MAXIMUM_MEMORY=4GB -s ALLOW_MEMORY_GROWTH -s FORCE_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=_main -s EXPORTED_RUNTIME_METHODS=callMain -s NO_EXIT_RUNTIME=1"
emmake make main -j
emmake make llama-cli -j
cd ../..

#
Expand All @@ -41,7 +41,7 @@ fi

mkdir -p $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp -rv src/llama/* $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp $LLAMA_CPP_BUILD_DIR/bin/main.* $LLAMA_CPP_WASM_DIST_LLAMA_DIR
cp $LLAMA_CPP_BUILD_DIR/bin/llama-cli.* $LLAMA_CPP_WASM_DIST_LLAMA_DIR

rm -rf docs/llama-st
cp -rv $LLAMA_CPP_WASM_DIST_LLAMA_DIR docs/
2 changes: 2 additions & 0 deletions docs/example-multi-thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ <h2> Demo </h2>
<option value="https://huggingface.co/stabilityai/stablelm-2-zephyr-1_6b/resolve/main/stablelm-2-zephyr-1_6b-Q4_1.gguf">stabilityai/stablelm-2-zephyr-1_6b Q4_1 (1.07 GB)</option>
<option value="https://huggingface.co/TKDKid1000/phi-1_5-GGUF/resolve/main/phi-1_5-Q4_K_M.gguf">microsoft/phi-1_5 Q4_K_M (918 MB)</option>
<option value="https://huggingface.co/TheBloke/phi-2-GGUF/resolve/main/phi-2.Q3_K_M.gguf">microsoft/phi-2 Q3_K_M (1.48 GB)</option>
<option value="https://huggingface.co/SanctumAI/Phi-3-mini-4k-instruct-GGUF/resolve/main/phi-3-mini-4k-instruct.Q3_K_M.gguf">microsoft/phi-3-mini-4k Q3_K_M (1.96 GB)</option>
<option value="https://huggingface.co/Felladrin/gguf-flan-t5-small/resolve/main/flan-t5-small.Q3_K_M.gguf">google/flan-t5-small Q3_K_M (88.3 MB)</option>
</select>

<label> Prompt: </label>
Expand Down
2 changes: 2 additions & 0 deletions docs/example-single-thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ <h2> Demo </h2>
<option value="https://huggingface.co/stabilityai/stablelm-2-zephyr-1_6b/resolve/main/stablelm-2-zephyr-1_6b-Q4_1.gguf">stabilityai/stablelm-2-zephyr-1_6b Q4_1 (1.07 GB)</option>
<option value="https://huggingface.co/TKDKid1000/phi-1_5-GGUF/resolve/main/phi-1_5-Q4_K_M.gguf">microsoft/phi-1_5 Q4_K_M (918 MB)</option>
<option value="https://huggingface.co/TheBloke/phi-2-GGUF/resolve/main/phi-2.Q3_K_M.gguf">microsoft/phi-2 Q3_K_M (1.48 GB)</option>
<option value="https://huggingface.co/SanctumAI/Phi-3-mini-4k-instruct-GGUF/resolve/main/phi-3-mini-4k-instruct.Q3_K_M.gguf">microsoft/phi-3-mini-4k Q3_K_M (1.96 GB)</option>
<option value="https://huggingface.co/Felladrin/gguf-flan-t5-small/resolve/main/flan-t5-small.Q3_K_M.gguf">google/flan-t5-small Q3_K_M (88.3 MB)</option>
</select>

<label> Prompt: </label>
Expand Down
22 changes: 22 additions & 0 deletions docs/llama-mt/llama-cli.js

Large diffs are not rendered by default.

Binary file added docs/llama-mt/llama-cli.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/llama-mt/main-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from "./actions.js";
import { loadBinaryResource } from "./utility.js";
import Module from "./main.js";
import Module from "./llama-cli.js";

// WASM Module
let module;
Expand Down
15 changes: 0 additions & 15 deletions docs/llama-mt/main.js

This file was deleted.

Binary file removed docs/llama-mt/main.wasm
Binary file not shown.
1 change: 0 additions & 1 deletion docs/llama-mt/main.worker.mjs

This file was deleted.

16 changes: 16 additions & 0 deletions docs/llama-st/llama-cli.js

Large diffs are not rendered by default.

Binary file added docs/llama-st/llama-cli.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/llama-st/main-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from "./actions.js";
import { loadBinaryResource } from "./utility.js";
import Module from "./main.js";
import Module from "./llama-cli.js";

// WASM Module
let module;
Expand Down
15 changes: 0 additions & 15 deletions docs/llama-st/main.js

This file was deleted.

Binary file removed docs/llama-st/main.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/llama/main-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from "./actions.js";
import { loadBinaryResource } from "./utility.js";
import Module from "./main.js";
import Module from "./llama-cli.js";

// WASM Module
let module;
Expand Down