mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-22 14:53:56 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e9767093d | ||
|
|
49df03da9a | ||
|
|
0189bdd0b7 | ||
|
|
be3653df11 | ||
|
|
f4711da7bd |
@@ -516,6 +516,7 @@ See the [API documentation](./docs/api.md) for all endpoints.
|
|||||||
- [multi-llm-ts](https://github.com/nbonamy/multi-llm-ts) (A Typescript/JavaScript library allowing access to different LLM in unified API)
|
- [multi-llm-ts](https://github.com/nbonamy/multi-llm-ts) (A Typescript/JavaScript library allowing access to different LLM in unified API)
|
||||||
- [LlmTornado](https://github.com/lofcz/llmtornado) (C# library providing a unified interface for major FOSS & Commercial inference APIs)
|
- [LlmTornado](https://github.com/lofcz/llmtornado) (C# library providing a unified interface for major FOSS & Commercial inference APIs)
|
||||||
- [Ollama for Zig](https://github.com/dravenk/ollama-zig)
|
- [Ollama for Zig](https://github.com/dravenk/ollama-zig)
|
||||||
|
- [Abso](https://github.com/lunary-ai/abso/blob/main/README.md#ollama) (OpenAI-compatible TypeScript SDK for any LLM provider)
|
||||||
|
|
||||||
### Mobile
|
### Mobile
|
||||||
|
|
||||||
|
|||||||
55
llama/patches/0016-remove-sgemm-global-variables.patch
Normal file
55
llama/patches/0016-remove-sgemm-global-variables.patch
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jmorganca <jmorganca@gmail.com>
|
||||||
|
Date: Sun, 9 Feb 2025 17:22:15 -0800
|
||||||
|
Subject: [PATCH] remove sgemm global variables
|
||||||
|
|
||||||
|
removes the 'iq4nlt' global variable in sgemm.cpp that causes
|
||||||
|
a runtime crash when calling dlopen on ggml-cpu libraries as
|
||||||
|
its initialization depends on AVX instructions the host machine
|
||||||
|
may not have
|
||||||
|
---
|
||||||
|
ggml/src/ggml-cpu/llamafile/sgemm.cpp | 17 +++++++++--------
|
||||||
|
1 file changed, 9 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ggml/src/ggml-cpu/llamafile/sgemm.cpp b/ggml/src/ggml-cpu/llamafile/sgemm.cpp
|
||||||
|
index 8fce576c..3f260ce5 100644
|
||||||
|
--- a/ggml/src/ggml-cpu/llamafile/sgemm.cpp
|
||||||
|
+++ b/ggml/src/ggml-cpu/llamafile/sgemm.cpp
|
||||||
|
@@ -279,14 +279,6 @@ template <> inline __m256bh load(const float *p) {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
-// CONSTANTS
|
||||||
|
-
|
||||||
|
-#if defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__)
|
||||||
|
-static const int8_t kvalues_iq4nl[16] = {-127, -104, -83, -65, -49, -35, -22, -10, 1, 13, 25, 38, 53, 69, 89, 113};
|
||||||
|
-static const __m128i iq4nlt = _mm_loadu_si128((const __m128i *) kvalues_iq4nl);
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FLOATING POINT MATRIX MULTIPLICATION
|
||||||
|
|
||||||
|
@@ -613,6 +605,14 @@ class tinyBLAS_Q0_AVX {
|
||||||
|
TC *C, int64_t ldc,
|
||||||
|
int ith, int nth)
|
||||||
|
: A(A), B(B), C(C), k(k), lda(lda), ldb(ldb), ldc(ldc), ith(ith), nth(nth) {
|
||||||
|
+ const int8_t kvalues_iq4nl[16] = {
|
||||||
|
+ -127, -104, -83, -65,
|
||||||
|
+ -49, -35, -22, -10,
|
||||||
|
+ 1, 13, 25, 38,
|
||||||
|
+ 53, 69, 89, 113
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ iq4nlt = _mm_loadu_si128((const __m128i *)kvalues_iq4nl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void matmul(int64_t m, int64_t n) {
|
||||||
|
@@ -1037,6 +1037,7 @@ class tinyBLAS_Q0_AVX {
|
||||||
|
const int64_t ldc;
|
||||||
|
const int ith;
|
||||||
|
const int nth;
|
||||||
|
+ __m128i iq4nlt;
|
||||||
|
};
|
||||||
|
#endif // __AVX__
|
||||||
|
|
||||||
69
llama/patches/0017-try-catch-backend-load.patch
Normal file
69
llama/patches/0017-try-catch-backend-load.patch
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Yang <mxyng@pm.me>
|
||||||
|
Date: Tue, 11 Feb 2025 14:06:36 -0800
|
||||||
|
Subject: [PATCH] try/catch backend load
|
||||||
|
|
||||||
|
---
|
||||||
|
ggml/src/ggml-backend-reg.cpp | 45 ++++++++++++++++++-----------------
|
||||||
|
1 file changed, 23 insertions(+), 22 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp
|
||||||
|
index ac5cda07..374c3b21 100644
|
||||||
|
--- a/ggml/src/ggml-backend-reg.cpp
|
||||||
|
+++ b/ggml/src/ggml-backend-reg.cpp
|
||||||
|
@@ -512,32 +512,33 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
|
||||||
|
}
|
||||||
|
fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied);
|
||||||
|
for (const auto & entry : dir_it) {
|
||||||
|
- if (entry.is_regular_file()) {
|
||||||
|
- std::wstring filename = entry.path().filename().wstring();
|
||||||
|
- std::wstring ext = entry.path().extension().wstring();
|
||||||
|
- if (filename.find(file_prefix) == 0 && ext == backend_filename_suffix()) {
|
||||||
|
- dl_handle_ptr handle { dl_load_library(entry.path().wstring()) };
|
||||||
|
- if (!handle && !silent) {
|
||||||
|
- GGML_LOG_ERROR("%s: failed to load %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
|
- }
|
||||||
|
- if (handle) {
|
||||||
|
+ try {
|
||||||
|
+ if (entry.is_regular_file()) {
|
||||||
|
+ std::wstring filename = entry.path().filename().wstring();
|
||||||
|
+ std::wstring ext = entry.path().extension().wstring();
|
||||||
|
+ if (filename.find(file_prefix) == 0 && ext == backend_filename_suffix()) {
|
||||||
|
+ dl_handle_ptr handle { dl_load_library(entry.path().wstring()) };
|
||||||
|
+ if (!handle) {
|
||||||
|
+ GGML_LOG_ERROR("%s: failed to load %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
auto score_fn = (ggml_backend_score_t) dl_get_sym(handle.get(), "ggml_backend_score");
|
||||||
|
- if (score_fn) {
|
||||||
|
- int s = score_fn();
|
||||||
|
-#ifndef NDEBUG
|
||||||
|
- GGML_LOG_DEBUG("%s: %s score: %d\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), s);
|
||||||
|
-#endif
|
||||||
|
- if (s > best_score) {
|
||||||
|
- best_score = s;
|
||||||
|
- best_path = entry.path().wstring();
|
||||||
|
- }
|
||||||
|
- } else {
|
||||||
|
- if (!silent) {
|
||||||
|
- GGML_LOG_INFO("%s: failed to find ggml_backend_score in %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
|
- }
|
||||||
|
+ if (!score_fn) {
|
||||||
|
+ GGML_LOG_DEBUG("%s: failed to find ggml_backend_score in %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int s = score_fn();
|
||||||
|
+ GGML_LOG_DEBUG("%s: %s score: %d\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), s);
|
||||||
|
+ if (s > best_score) {
|
||||||
|
+ best_score = s;
|
||||||
|
+ best_path = entry.path().wstring();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ } catch (const std::exception & e) {
|
||||||
|
+ GGML_LOG_ERROR("%s: failed to load %s: %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
ml/backend/ggml/ggml/src/ggml-backend-reg.cpp
vendored
45
ml/backend/ggml/ggml/src/ggml-backend-reg.cpp
vendored
@@ -512,32 +512,33 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
|
|||||||
}
|
}
|
||||||
fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied);
|
fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied);
|
||||||
for (const auto & entry : dir_it) {
|
for (const auto & entry : dir_it) {
|
||||||
if (entry.is_regular_file()) {
|
try {
|
||||||
std::wstring filename = entry.path().filename().wstring();
|
if (entry.is_regular_file()) {
|
||||||
std::wstring ext = entry.path().extension().wstring();
|
std::wstring filename = entry.path().filename().wstring();
|
||||||
if (filename.find(file_prefix) == 0 && ext == backend_filename_suffix()) {
|
std::wstring ext = entry.path().extension().wstring();
|
||||||
dl_handle_ptr handle { dl_load_library(entry.path().wstring()) };
|
if (filename.find(file_prefix) == 0 && ext == backend_filename_suffix()) {
|
||||||
if (!handle && !silent) {
|
dl_handle_ptr handle { dl_load_library(entry.path().wstring()) };
|
||||||
GGML_LOG_ERROR("%s: failed to load %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
if (!handle) {
|
||||||
}
|
GGML_LOG_ERROR("%s: failed to load %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
if (handle) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto score_fn = (ggml_backend_score_t) dl_get_sym(handle.get(), "ggml_backend_score");
|
auto score_fn = (ggml_backend_score_t) dl_get_sym(handle.get(), "ggml_backend_score");
|
||||||
if (score_fn) {
|
if (!score_fn) {
|
||||||
int s = score_fn();
|
GGML_LOG_DEBUG("%s: failed to find ggml_backend_score in %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
||||||
#ifndef NDEBUG
|
continue;
|
||||||
GGML_LOG_DEBUG("%s: %s score: %d\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), s);
|
}
|
||||||
#endif
|
|
||||||
if (s > best_score) {
|
int s = score_fn();
|
||||||
best_score = s;
|
GGML_LOG_DEBUG("%s: %s score: %d\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), s);
|
||||||
best_path = entry.path().wstring();
|
if (s > best_score) {
|
||||||
}
|
best_score = s;
|
||||||
} else {
|
best_path = entry.path().wstring();
|
||||||
if (!silent) {
|
|
||||||
GGML_LOG_INFO("%s: failed to find ggml_backend_score in %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (const std::exception & e) {
|
||||||
|
GGML_LOG_ERROR("%s: failed to load %s: %s\n", __func__, utf16_to_utf8(entry.path().wstring()).c_str(), e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,14 +279,6 @@ template <> inline __m256bh load(const float *p) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CONSTANTS
|
|
||||||
|
|
||||||
#if defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__)
|
|
||||||
static const int8_t kvalues_iq4nl[16] = {-127, -104, -83, -65, -49, -35, -22, -10, 1, 13, 25, 38, 53, 69, 89, 113};
|
|
||||||
static const __m128i iq4nlt = _mm_loadu_si128((const __m128i *) kvalues_iq4nl);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FLOATING POINT MATRIX MULTIPLICATION
|
// FLOATING POINT MATRIX MULTIPLICATION
|
||||||
|
|
||||||
@@ -613,6 +605,14 @@ class tinyBLAS_Q0_AVX {
|
|||||||
TC *C, int64_t ldc,
|
TC *C, int64_t ldc,
|
||||||
int ith, int nth)
|
int ith, int nth)
|
||||||
: A(A), B(B), C(C), k(k), lda(lda), ldb(ldb), ldc(ldc), ith(ith), nth(nth) {
|
: A(A), B(B), C(C), k(k), lda(lda), ldb(ldb), ldc(ldc), ith(ith), nth(nth) {
|
||||||
|
const int8_t kvalues_iq4nl[16] = {
|
||||||
|
-127, -104, -83, -65,
|
||||||
|
-49, -35, -22, -10,
|
||||||
|
1, 13, 25, 38,
|
||||||
|
53, 69, 89, 113
|
||||||
|
};
|
||||||
|
|
||||||
|
iq4nlt = _mm_loadu_si128((const __m128i *)kvalues_iq4nl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void matmul(int64_t m, int64_t n) {
|
void matmul(int64_t m, int64_t n) {
|
||||||
@@ -1037,6 +1037,7 @@ class tinyBLAS_Q0_AVX {
|
|||||||
const int64_t ldc;
|
const int64_t ldc;
|
||||||
const int ith;
|
const int ith;
|
||||||
const int nth;
|
const int nth;
|
||||||
|
__m128i iq4nlt;
|
||||||
};
|
};
|
||||||
#endif // __AVX__
|
#endif // __AVX__
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ var OnceLoad = sync.OnceFunc(func() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if abspath != filepath.Dir(exe) && !strings.Contains(abspath, filepath.FromSlash("lib/ollama")) {
|
||||||
|
slog.Debug("skipping path which is not part of ollama", "path", abspath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := visited[abspath]; !ok {
|
if _, ok := visited[abspath]; !ok {
|
||||||
func() {
|
func() {
|
||||||
slog.Debug("ggml backend load all from path", "path", abspath)
|
slog.Debug("ggml backend load all from path", "path", abspath)
|
||||||
|
|||||||
Reference in New Issue
Block a user