Skip to content

Commit 7372716

Browse files
committed
Auto-endianness integrated!
1 parent d4b22d3 commit 7372716

28 files changed

+1184
-269
lines changed

buildenv

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export ZOPEN_DEV_TAG="master"
77
export ZOPEN_NAME="llamacpp-master"
88
export ZOPEN_RUNTIME_DEPS="ncurses"
99

10+
export ZOPEN_SKIP_ZOSLIB_ENV_HOOK=1
11+
1012
rm -f "llama"
1113
ln -s "llama.cpp" "llama"
1214
ln -s "llama.cpp" $ZOPEN_NAME
@@ -17,7 +19,7 @@ export ZOPEN_COMP="CLANG"
1719
export BLAS_HOME="/usr/lpp/cbclib"
1820

1921
export ZOPEN_CONFIGURE="cmake"
20-
export ZOPEN_CONFIGURE_OPTS="-B ../build --install-prefix \"\$ZOPEN_INSTALL_DIR/\" -DCURL_LIBRARY=\$CURL_HOME/lib/libcurl.a -DCURL_INCLUDE_DIR=\$CURL_HOME/include -DBUILD_SHARED_LIBS_DEFAULT=OFF -DBUILD_SHARED_LIBS=OFF -DGGML_STATIC=ON -DGGML_BACKEND_DL=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS=\$BLAS_HOME/include/openblas -DBLAS_LIBRARIES=\$BLAS_HOME/lib/libopenblas.so -DLLAMA_BUILD_TESTS=ON ."
22+
export ZOPEN_CONFIGURE_OPTS="-B ../build --install-prefix \"\$ZOPEN_INSTALL_DIR/\" -DCMAKE_C_FLAGS=\"-fzvector -m64 -march=z15 -lmass.arch13\" -DCMAKE_C_STANDARD=11 -DCMAKE_C_STANDARD_REQUIRED=ON -DCMAKE_C_EXTENSIONS=OFF -DCMAKE_BUILD_TYPE=Release -DLLAMA_SERVER_SSL=ON -DOPENSSL_ROOT_DIR=\$OPENSSL_HOME -DCURL_LIBRARY=\$CURL_HOME/lib/libcurl.a -DCURL_INCLUDE_DIR=\$CURL_HOME/include -DBUILD_SHARED_LIBS_DEFAULT=OFF -DBUILD_SHARED_LIBS=OFF -DGGML_STATIC=ON -DGGML_BACKEND_DL=OFF -DGGML_OPENBLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS=/usr/lpp/cbclib/include/openblas -DBLAS_LIBRARIES=/usr/lpp/cbclib/lib/libopenblas.so -DLLAMA_BUILD_TESTS=ON -DLLAMA_CURL=ON ."
2123

2224
export ZOPEN_MAKE="cmake"
2325
export ZOPEN_MAKE_OPTS="--build ../build --parallel \$ZOPEN_NUM_JOBS --config Release"
@@ -61,11 +63,27 @@ zopen_check_results()
6163
echo "expectedTotalTests:$total"
6264
}
6365

66+
zopen_pre_check()
67+
{
68+
unset SSL_CERT_FILE
69+
unset SSL_CERT_PATH
70+
export CFLAGS="$CFLAGS -march=z15 -mzvector"
71+
export CPPFLAGS="$CPPFLAGS -march=z15"
72+
}
73+
6474
zopen_append_to_env()
6575
{
76+
export SSL_CERT_PATH=$(curl-config --ca)
6677
# echo envars outside of PATH, MANPATH, LIBPATH
6778
}
6879

80+
zopen_append_to_zoslib_env()
81+
{
82+
cat<<EOF
83+
SSL_CERT_PATH|set|$(curl-config --ca)
84+
EOF
85+
}
86+
6987
zopen_append_to_setup()
7088
{
7189
# echo commands that will run when installing via setup.sh

patches/arg.cpp.patch

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/common/arg.cpp b/common/arg.cpp
2-
index 40af7e57..46fec792 100644
2+
index 06005359..28220aac 100644
33
--- a/common/arg.cpp
44
+++ b/common/arg.cpp
55
@@ -36,6 +36,9 @@
@@ -30,7 +30,17 @@ index 40af7e57..46fec792 100644
3030
http_headers.ptr = curl_slist_append(http_headers.ptr, "User-Agent: llama-cpp");
3131
// Check if hf-token or bearer-token was specified
3232
if (!bearer_token.empty()) {
33-
@@ -569,6 +574,7 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string &
33+
@@ -506,7 +511,8 @@ static bool common_download_model(
34+
struct gguf_init_params gguf_params = {
35+
/*.no_alloc = */ true,
36+
/*.ctx = */ NULL,
37+
- };
38+
+ /* .allow_byteswapping = */ true,
39+
+ };
40+
auto * ctx_gguf = gguf_init_from_file(model.path.c_str(), gguf_params);
41+
if (!ctx_gguf) {
42+
LOG_ERR("\n%s: failed to load input GGUF from %s\n", __func__, model.path.c_str());
43+
@@ -569,6 +575,7 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string &
3444
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
3545
curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 1L);
3646
curl_easy_setopt(curl.get(), CURLOPT_FOLLOWLOCATION, 1L);

patches/clip.cpp.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/tools/mtmd/clip.cpp b/tools/mtmd/clip.cpp
2+
index a4b62f9a..2d89d4b1 100644
3+
--- a/tools/mtmd/clip.cpp
4+
+++ b/tools/mtmd/clip.cpp
5+
@@ -2028,6 +2028,7 @@ struct clip_model_loader {
6+
struct gguf_init_params params = {
7+
/*.no_alloc = */ true,
8+
/*.ctx = */ &meta,
9+
+ /*.allow_byteswapping = */ true,
10+
};
11+
12+
ctx_gguf = gguf_context_ptr(gguf_init_from_file(fname, params));

patches/common.cpp.patch

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/common/common.cpp b/common/common.cpp
2-
index 4cc40ed..234ad95 100644
2+
index d8c4d988..00aa7d43 100644
33
--- a/common/common.cpp
44
+++ b/common/common.cpp
5-
@@ -851,7 +851,7 @@ std::string fs_get_cache_directory() {
5+
@@ -874,7 +874,7 @@ std::string fs_get_cache_directory() {
66
if (getenv("LLAMA_CACHE")) {
77
cache_directory = std::getenv("LLAMA_CACHE");
88
} else {
@@ -11,3 +11,11 @@ index 4cc40ed..234ad95 100644
1111
if (std::getenv("XDG_CACHE_HOME")) {
1212
cache_directory = std::getenv("XDG_CACHE_HOME");
1313
} else {
14+
@@ -1436,6 +1436,7 @@ static common_control_vector_data common_control_vector_load_one(const common_co
15+
struct gguf_init_params meta_gguf_params = {
16+
/* .no_alloc = */ false,
17+
/* .ctx = */ &ctx,
18+
+ /* .allow_byteswapping = */ true,
19+
};
20+
struct gguf_context * ctx_gguf = gguf_init_from_file(load_info.fname.c_str(), meta_gguf_params);
21+
if (!ctx_gguf) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp
2+
index bdf0eed2..b36170bc 100644
3+
--- a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp
4+
+++ b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp
5+
@@ -535,6 +535,7 @@ static void load_vocab(const char * filename, const Config * config, struct my_l
6+
struct gguf_init_params params = {
7+
/*.no_alloc = */ false,
8+
/*.ctx = */ &ctx_data,
9+
+ /*.allow_byteswapping = */ true,
10+
};
11+
12+
struct gguf_context * ctx = gguf_init_from_file(filename, params);

patches/examples_gguf.cpp.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp
2+
index f31989c8..94ac3e5a 100644
3+
--- a/examples/gguf/gguf.cpp
4+
+++ b/examples/gguf/gguf.cpp
5+
@@ -87,6 +87,7 @@ static bool gguf_ex_read_0(const std::string & fname) {
6+
struct gguf_init_params params = {
7+
/*.no_alloc = */ false,
8+
/*.ctx = */ NULL,
9+
+ /*.allow_byteswapping = */ true,
10+
};
11+
12+
struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);

patches/export-lora.cpp.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/tools/export-lora/export-lora.cpp b/tools/export-lora/export-lora.cpp
2+
index f038019b..bf750ab9 100644
3+
--- a/tools/export-lora/export-lora.cpp
4+
+++ b/tools/export-lora/export-lora.cpp
5+
@@ -50,6 +50,7 @@ static struct gguf_context * load_gguf(std::string & fname, struct ggml_context
6+
struct gguf_init_params params = {
7+
/*.no_alloc = */ true,
8+
/*.ctx = */ ctx_ggml,
9+
+ /*.allow_byteswapping = */ true,
10+
};
11+
struct gguf_context * ctx_gguf = gguf_init_from_file(fname.c_str(), params);
12+
if (!ctx_gguf) {

patches/ggml-backend-reg.cpp.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp
2-
index 405d8e3..b3682a9 100644
2+
index f0cdac31..29247c6a 100644
33
--- a/ggml/src/ggml-backend-reg.cpp
44
+++ b/ggml/src/ggml-backend-reg.cpp
5-
@@ -556,7 +556,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
5+
@@ -561,7 +561,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
66
}
77

88
void ggml_backend_load_all() {

patches/ggml-cpu.c.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c
2-
index c7426df..e074799 100644
2+
index c5271b77..6a547e4b 100644
33
--- a/ggml/src/ggml-cpu/ggml-cpu.c
44
+++ b/ggml/src/ggml-cpu/ggml-cpu.c
55
@@ -17,7 +17,7 @@

patches/ggml-cpu.cpp.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cpp
2-
index e013e8b..6290b22 100644
2+
index c9daa4c3..63839d07 100644
33
--- a/ggml/src/ggml-cpu/ggml-cpu.cpp
44
+++ b/ggml/src/ggml-cpu/ggml-cpu.cpp
55
@@ -33,6 +33,38 @@

0 commit comments

Comments
 (0)