Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
72962c6e
Unverified
Commit
72962c6e
authored
Sep 17, 2024
by
Michael Yang
Committed by
GitHub
Sep 17, 2024
Browse files
Merge pull request #6833 from ollama/mxyng/git-am
make patches git am-able
parents
8f9ab5e1
7bd7b027
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
130 additions
and
55 deletions
+130
-55
llm/generate/gen_common.sh
llm/generate/gen_common.sh
+4
-16
llm/generate/gen_windows.ps1
llm/generate/gen_windows.ps1
+2
-22
llm/patches/0000-cmakelist.patch
llm/patches/0000-cmakelist.patch
+22
-0
llm/patches/0001-load-progress.patch
llm/patches/0001-load-progress.patch
+17
-4
llm/patches/0002-clip-log.patch
llm/patches/0002-clip-log.patch
+13
-1
llm/patches/0003-load_exception.patch
llm/patches/0003-load_exception.patch
+15
-3
llm/patches/0004-metal.patch
llm/patches/0004-metal.patch
+14
-2
llm/patches/0005-default-pretokenizer.patch
llm/patches/0005-default-pretokenizer.patch
+13
-1
llm/patches/0006-embeddings.patch
llm/patches/0006-embeddings.patch
+15
-3
llm/patches/0007-clip-unicode.patch
llm/patches/0007-clip-unicode.patch
+15
-3
No files found.
llm/generate/gen_common.sh
View file @
72962c6e
...
@@ -69,22 +69,10 @@ git_module_setup() {
...
@@ -69,22 +69,10 @@ git_module_setup() {
}
}
apply_patches
()
{
apply_patches
()
{
# Wire up our CMakefile
# apply temporary patches until fix is upstream
if
!
grep
ollama
${
LLAMACPP_DIR
}
/CMakeLists.txt
;
then
for
patch
in
../patches/
*
.patch
;
do
echo
'add_subdirectory(../ext_server ext_server) # ollama'
>>
${
LLAMACPP_DIR
}
/CMakeLists.txt
git
-c
'user.name=nobody'
-c
'user.email=<>'
-C
${
LLAMACPP_DIR
}
am
${
patch
}
fi
done
if
[
-n
"
$(
ls
-A
../patches/
*
.diff
)
"
]
;
then
# apply temporary patches until fix is upstream
for
patch
in
../patches/
*
.diff
;
do
for
file
in
$(
grep
"^+++ "
${
patch
}
|
cut
-f2
-d
' '
|
cut
-f2-
-d
/
)
;
do
(
cd
${
LLAMACPP_DIR
}
;
git checkout
${
file
}
)
done
done
for
patch
in
../patches/
*
.diff
;
do
(
cd
${
LLAMACPP_DIR
}
&&
git apply
${
patch
}
)
done
fi
}
}
build
()
{
build
()
{
...
...
llm/generate/gen_windows.ps1
View file @
72962c6e
...
@@ -83,29 +83,9 @@ function git_module_setup {
...
@@ -83,29 +83,9 @@ function git_module_setup {
}
}
function
apply_patches
{
function
apply_patches
{
# Wire up our CMakefile
if
(
!
(
Select-String
-Path
"
${script:llamacppDir}
/CMakeLists.txt"
-Pattern
'ollama'
))
{
Add-Content
-Path
"
${script:llamacppDir}
/CMakeLists.txt"
-Value
'add_subdirectory(../ext_server ext_server) # ollama'
}
# Apply temporary patches until fix is upstream
# Apply temporary patches until fix is upstream
$patches
=
Get-ChildItem
"../patches/*.diff"
foreach
(
$patch
in
$
(
Get-ChildItem
"../patches/*.patch"
))
{
foreach
(
$patch
in
$patches
)
{
git
-c
'user.name=nobody'
-c
'user.email=<>'
-C
"
${script:llamacppDir}
"
am
$patch
.
FullName
# Extract file paths from the patch file
$filePaths
=
Get-Content
$patch
.
FullName
|
Where-Object
{
$_
-match
'^\+\+\+ '
}
|
ForEach-Object
{
$parts
=
$_
-split
' '
(
$parts
[
1
]
-split
'/'
,
2
)[
1
]
}
# Checkout each file
foreach
(
$file
in
$filePaths
)
{
git
-C
"
${script:llamacppDir}
"
checkout
$file
}
}
# Apply each patch
foreach
(
$patch
in
$patches
)
{
git
-C
"
${script:llamacppDir}
"
apply
$patch
.
FullName
}
}
}
}
...
...
llm/patches/0000-cmakelist.patch
0 → 100644
View file @
72962c6e
From 8b8d83ffca775840acc5dc700f3b3703e9f5cfe4 Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Fri, 23 Aug 2024 11:27:48 -0700
Subject: [PATCH] patch cmakelist
---
CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3132063..6a2a9912 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -199,3 +199,5 @@
if (LLAMA_BUILD_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(pocs)
endif()
+
+add_subdirectory(../ext_server ext_server) # ollama
--
2.45.2
llm/patches/01-load-progress.
diff
→
llm/patches/
00
01-load-progress.
patch
View file @
72962c6e
From 2cfaa0a04faa9c87ba8f1ac8527eb953e69c6cde Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:10 -0700
Subject: [PATCH] 01-load-progress.diff
---
common/common.cpp | 2 ++
common/common.h | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/common/common.cpp b/common/common.cpp
diff --git a/common/common.cpp b/common/common.cpp
index
2c05a4d4..927f0e3d
100644
index
9fa18472..48ff41e9
100644
--- a/common/common.cpp
--- a/common/common.cpp
+++ b/common/common.cpp
+++ b/common/common.cpp
@@ -2
09
3,6 +2
09
3,8 @@
struct llama_model_params llama_model_params_from_gpt_params(const gpt_params &
@@ -2
57
3,6 +2
57
3,8 @@
struct llama_model_params llama_model_params_from_gpt_params(const gpt_params &
mparams.use_mmap = params.use_mmap;
mparams.use_mmap = params.use_mmap;
mparams.use_mlock = params.use_mlock;
mparams.use_mlock = params.use_mlock;
mparams.check_tensors = params.check_tensors;
mparams.check_tensors = params.check_tensors;
...
@@ -12,10 +22,10 @@ index 2c05a4d4..927f0e3d 100644
...
@@ -12,10 +22,10 @@ index 2c05a4d4..927f0e3d 100644
mparams.kv_overrides = NULL;
mparams.kv_overrides = NULL;
} else {
} else {
diff --git a/common/common.h b/common/common.h
diff --git a/common/common.h b/common/common.h
index
65c0ef81..ebca2c7
7 100644
index
cb5e7f6d..d8f043f
7 100644
--- a/common/common.h
--- a/common/common.h
+++ b/common/common.h
+++ b/common/common.h
@@ -
18
4,6 +
18
4,13 @@
struct gpt_params {
@@ -
20
4,6 +
20
4,13 @@
struct gpt_params {
std::string mmproj = ""; // path to multimodal projector
std::string mmproj = ""; // path to multimodal projector
std::vector<std::string> image; // path to image file(s)
std::vector<std::string> image; // path to image file(s)
...
@@ -29,3 +39,6 @@ index 65c0ef81..ebca2c77 100644
...
@@ -29,3 +39,6 @@ index 65c0ef81..ebca2c77 100644
// embedding
// embedding
bool embedding = false; // get only sentence embedding
bool embedding = false; // get only sentence embedding
int32_t embd_normalize = 2; // normalisation for embendings (-1=none, 0=max absolute int16, 1=taxicab, 2=euclidean, >2=p-norm)
int32_t embd_normalize = 2; // normalisation for embendings (-1=none, 0=max absolute int16, 1=taxicab, 2=euclidean, >2=p-norm)
--
2.46.0
llm/patches/02-clip-log.
diff
→
llm/patches/
00
02-clip-log.
patch
View file @
72962c6e
From ba4bba80a744f76ac67b8234451c259a3c5da83b Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:11 -0700
Subject: [PATCH] 02-clip-log.diff
---
examples/llava/clip.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
index
e431c7f7..f077e688
100644
index
9b890571..cb51793d
100644
--- a/examples/llava/clip.cpp
--- a/examples/llava/clip.cpp
+++ b/examples/llava/clip.cpp
+++ b/examples/llava/clip.cpp
@@ -3,6 +3,7 @@
@@ -3,6 +3,7 @@
...
@@ -10,3 +19,6 @@ index e431c7f7..f077e688 100644
...
@@ -10,3 +19,6 @@ index e431c7f7..f077e688 100644
#include "log.h"
#include "log.h"
#include "ggml.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-alloc.h"
--
2.46.0
llm/patches/03-load_exception.
diff
→
llm/patches/
00
03-load_exception.
patch
View file @
72962c6e
From e43bfd3f607a6dfcaba2d490d35f412a52e55e30 Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:12 -0700
Subject: [PATCH] 03-load_exception.diff
---
src/llama.cpp | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/llama.cpp b/src/llama.cpp
diff --git a/src/llama.cpp b/src/llama.cpp
index
73f52435..58a00fb1
100644
index
88355971..926bb71a
100644
--- a/src/llama.cpp
--- a/src/llama.cpp
+++ b/src/llama.cpp
+++ b/src/llama.cpp
@@ -
7241,7 +7241
,7 @@
static int llama_model_load(const std::string & fname, llama_model & model, llam
@@ -
8635,7 +8635
,7 @@
static int llama_model_load(const std::string & fname, llama_model & model, llam
}
}
} catch (const std::exception & err) {
} catch (const std::exception & err) {
LLAMA_LOG_ERROR("%s: error loading model: %s\n", __func__, err.what());
LLAMA_LOG_ERROR("%s: error loading model: %s\n", __func__, err.what());
...
@@ -11,7 +20,7 @@ index 73f52435..58a00fb1 100644
...
@@ -11,7 +20,7 @@ index 73f52435..58a00fb1 100644
}
}
return 0;
return 0;
@@ -1
7564
,16 +1
7564
,23 @@
struct llama_model * llama_load_model_from_file(
@@ -1
8022
,16 +1
8022
,23 @@
struct llama_model * llama_load_model_from_file(
}
}
model->rpc_servers.push_back(servers);
model->rpc_servers.push_back(servers);
}
}
...
@@ -43,3 +52,6 @@ index 73f52435..58a00fb1 100644
...
@@ -43,3 +52,6 @@ index 73f52435..58a00fb1 100644
}
}
return model;
return model;
--
2.46.0
llm/patches/04-metal.
diff
→
llm/patches/
00
04-metal.
patch
View file @
72962c6e
From 29411d9a9d2b6a0af6425ffe88498f17f71f7d5d Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:12 -0700
Subject: [PATCH] 04-metal.diff
---
ggml/src/ggml-metal.m | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/ggml/src/ggml-metal.m b/ggml/src/ggml-metal.m
diff --git a/ggml/src/ggml-metal.m b/ggml/src/ggml-metal.m
index
0207b787..b5e9884b
100644
index
91b5e61b..9cfa72ac
100644
--- a/ggml/src/ggml-metal.m
--- a/ggml/src/ggml-metal.m
+++ b/ggml/src/ggml-metal.m
+++ b/ggml/src/ggml-metal.m
@@ -1
396
,27 +1
396
,23 @@
static enum ggml_status ggml_metal_graph_compute(
@@ -1
734
,27 +1
734
,23 @@
static enum ggml_status ggml_metal_graph_compute(
// to the matrix-vector kernel
// to the matrix-vector kernel
int ne11_mm_min = 1;
int ne11_mm_min = 1;
...
@@ -43,3 +52,6 @@ index 0207b787..b5e9884b 100644
...
@@ -43,3 +52,6 @@ index 0207b787..b5e9884b 100644
// for now the matrix-matrix multiplication kernel only works on A14+/M1+ SoCs
// for now the matrix-matrix multiplication kernel only works on A14+/M1+ SoCs
// AMD GPU and older A-chips will reuse matrix-vector multiplication kernel
// AMD GPU and older A-chips will reuse matrix-vector multiplication kernel
--
2.46.0
llm/patches/05-default-pretokenizer.
diff
→
llm/patches/
00
05-default-pretokenizer.
patch
View file @
72962c6e
From b298ac8614d1e38da28f760eb1d2ae8af0fbbe62 Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:13 -0700
Subject: [PATCH] 05-default-pretokenizer.diff
---
src/llama.cpp | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/src/llama.cpp b/src/llama.cpp
diff --git a/src/llama.cpp b/src/llama.cpp
index
883559
71..d
d7d41ed
100644
index
926bb
71
a
..d
1e959fc
100644
--- a/src/llama.cpp
--- a/src/llama.cpp
+++ b/src/llama.cpp
+++ b/src/llama.cpp
@@ -6083,16 +6083,7 @@
static void llm_load_vocab(
@@ -6083,16 +6083,7 @@
static void llm_load_vocab(
...
@@ -30,3 +39,6 @@ index 88355971..dd7d41ed 100644
...
@@ -30,3 +39,6 @@ index 88355971..dd7d41ed 100644
}
}
} else if (vocab.type == LLAMA_VOCAB_TYPE_SPM) {
} else if (vocab.type == LLAMA_VOCAB_TYPE_SPM) {
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
--
2.46.0
llm/patches/06-embeddings.
diff
→
llm/patches/
00
06-embeddings.
patch
View file @
72962c6e
From c9a6ca9fc039233dee746a4da9705762cd9e515d Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:14 -0700
Subject: [PATCH] 06-embeddings.diff
---
src/llama.cpp | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/llama.cpp b/src/llama.cpp
diff --git a/src/llama.cpp b/src/llama.cpp
index
88355971..d7db689b
100644
index
d1e959fc..f79bd782
100644
--- a/src/llama.cpp
--- a/src/llama.cpp
+++ b/src/llama.cpp
+++ b/src/llama.cpp
@@ -15
906
,7 +15
906
,7 @@
static size_t llama_output_reserve(llama_context & lctx, size_t n_outputs) {
@@ -15
898
,7 +15
898
,7 @@
static size_t llama_output_reserve(llama_context & lctx, size_t n_outputs) {
const auto n_embd = hparams.n_embd;
const auto n_embd = hparams.n_embd;
// TODO: use a per-batch flag for logits presence instead
// TODO: use a per-batch flag for logits presence instead
...
@@ -11,7 +20,7 @@ index 88355971..d7db689b 100644
...
@@ -11,7 +20,7 @@ index 88355971..d7db689b 100644
const bool has_embd = cparams.embeddings && (cparams.pooling_type == LLAMA_POOLING_TYPE_NONE);
const bool has_embd = cparams.embeddings && (cparams.pooling_type == LLAMA_POOLING_TYPE_NONE);
const size_t logits_size = has_logits ? n_vocab*n_outputs_max : 0;
const size_t logits_size = has_logits ? n_vocab*n_outputs_max : 0;
@@ -1617
5
,20 +1617
5
,23 @@
static int llama_decode_internal(
@@ -161
6
7,20 +161
6
7,23 @@
static int llama_decode_internal(
// no output
// no output
res = nullptr;
res = nullptr;
embd = nullptr;
embd = nullptr;
...
@@ -41,3 +50,6 @@ index 88355971..d7db689b 100644
...
@@ -41,3 +50,6 @@ index 88355971..d7db689b 100644
// LLAMA_LOG_INFO("graph build time: %.3f ms (%d nodes, %d leafs)\n", (ggml_time_us() - t_start_us)/1000.0, gf->n_nodes, gf->n_leafs);
// LLAMA_LOG_INFO("graph build time: %.3f ms (%d nodes, %d leafs)\n", (ggml_time_us() - t_start_us)/1000.0, gf->n_nodes, gf->n_leafs);
ggml_backend_sched_alloc_graph(lctx.sched, gf);
ggml_backend_sched_alloc_graph(lctx.sched, gf);
--
2.46.0
llm/patches/07-clip-unicode.
diff
→
llm/patches/
00
07-clip-unicode.
patch
View file @
72962c6e
From ae2b188a679c83ce105aa1e823499441dfab3c57 Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:15 -0700
Subject: [PATCH] 07-clip-unicode.diff
---
examples/llava/clip.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
index
95fbe
3d
0
..
5a02a6ec
100644
index
cb5179
3d..
8716472b
100644
--- a/examples/llava/clip.cpp
--- a/examples/llava/clip.cpp
+++ b/examples/llava/clip.cpp
+++ b/examples/llava/clip.cpp
@@ -
32
,6 +
33
,14 @@
@@ -
41
,6 +
41
,14 @@
#include <cinttypes>
#include <cinttypes>
#include <limits>
#include <limits>
...
@@ -17,7 +26,7 @@ index 95fbe3d0..5a02a6ec 100644
...
@@ -17,7 +26,7 @@ index 95fbe3d0..5a02a6ec 100644
//#define CLIP_DEBUG_FUNCTIONS
//#define CLIP_DEBUG_FUNCTIONS
// RGB uint8 image
// RGB uint8 image
@@ -1
055
,7 +1
064
,22 @@
struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
@@ -1
223
,7 +1
231
,22 @@
struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
return nullptr;
return nullptr;
}
}
...
@@ -40,3 +49,6 @@ index 95fbe3d0..5a02a6ec 100644
...
@@ -40,3 +49,6 @@ index 95fbe3d0..5a02a6ec 100644
if (!fin) {
if (!fin) {
LOG_TEE("cannot open model file for loading tensors\n");
LOG_TEE("cannot open model file for loading tensors\n");
clip_free(new_clip);
clip_free(new_clip);
--
2.46.0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment