Skip to content

Distribute and run LLMs with a single file.

Do more post synchronization cleanup

Justine Tunney5f58779d46b0
diff --git a/llama.cpp/ggml-metal.m b/llama.cpp/ggml-metal.m
index 81d19be2..c46cebea 100644
--- a/llama.cpp/ggml-metal.m
+++ b/llama.cpp/ggml-metal.m
@@ -238,6 +238,8 @@ struct ggml_metal_context {
@end
static void ggml_metal_default_log_callback(enum ggml_log_level level, const char * msg, void * user_data) {
+ if (FLAG_log_disable) return; // [jart]
+
fprintf(stderr, "%s", msg);
UNUSED(level);
diff --git a/llama.cpp/imatrix/imatrix.cpp b/llama.cpp/imatrix/imatrix.cpp
index cdf31f03..cdba2408 100644
--- a/llama.cpp/imatrix/imatrix.cpp
+++ b/llama.cpp/imatrix/imatrix.cpp
@@ -497,7 +497,6 @@ int main(int argc, char ** argv) {
__builtin_unreachable();
}
- llamafile_init();
llamafile_check_cpu();
StatParams sparams;
diff --git a/llama.cpp/llama.cpp b/llama.cpp/llama.cpp
index f2dc674b..dd1da6f8 100644
--- a/llama.cpp/llama.cpp
+++ b/llama.cpp/llama.cpp
@@ -1,6 +1,7 @@
// -*- mode:c++;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-
// vi: set et ft=c++ ts=4 sts=4 sw=4 fenc=utf-8 :vi
#define LLAMA_API_INTERNAL
+#include "llamafile/log.h"
#include "llama.h"
#include "unicode.h"
@@ -14552,7 +14553,7 @@ const std::vector<std::pair<std::string, struct ggml_tensor *>> & llama_internal
void llama_log_set(ggml_log_callback log_callback, void * user_data) {
g_state.log_callback = log_callback ? log_callback : llama_log_callback_default;
g_state.log_callback_user_data = user_data;
- ggml_backend_metal_log_set_callback(g_state.log_callback, g_state.log_callback_user_data);
+ // ggml_backend_metal_log_set_callback(g_state.log_callback, g_state.log_callback_user_data); [jart]
}
static void llama_log_internal_v(ggml_log_level level, const char * format, va_list args) {
@@ -14573,6 +14574,7 @@ static void llama_log_internal_v(ggml_log_level level, const char * format, va_l
}
static void llama_log_internal(ggml_log_level level, const char * format, ...) {
+ if (FLAG_log_disable) return; // [jart]
va_list args;
va_start(args, format);
llama_log_internal_v(level, format, args);
@@ -14580,6 +14582,7 @@ static void llama_log_internal(ggml_log_level level, const char * format, ...) {
}
static void llama_log_callback_default(ggml_log_level level, const char * text, void * user_data) {
+ if (FLAG_log_disable) return; // [jart]
(void) level;
(void) user_data;
fputs(text, stderr);
diff --git a/llama.cpp/llava/llava-quantize.cpp b/llama.cpp/llava/llava-quantize.cpp
index 27fd1d24..f84c7c9e 100644
--- a/llama.cpp/llava/llava-quantize.cpp
+++ b/llama.cpp/llava/llava-quantize.cpp
@@ -22,7 +22,6 @@ int main(int argc, char *argv[]) {
__builtin_unreachable();
}
- llamafile_init();
llamafile_check_cpu();
if (argc != 4) {
diff --git a/llama.cpp/main/main.cpp b/llama.cpp/main/main.cpp
index 069c7bad..160f8349 100644
--- a/llama.cpp/main/main.cpp
+++ b/llama.cpp/main/main.cpp
@@ -124,7 +124,6 @@ int main(int argc, char ** argv) {
__builtin_unreachable();
}
- llamafile_init();
llamafile_check_cpu();
ShowCrashReports();
LoadZipArgs(&argc, &argv);
diff --git a/llama.cpp/perplexity/perplexity.cpp b/llama.cpp/perplexity/perplexity.cpp
index 0837e8b1..3e396516 100644
--- a/llama.cpp/perplexity/perplexity.cpp
+++ b/llama.cpp/perplexity/perplexity.cpp
@@ -1824,7 +1824,6 @@ int main(int argc, char ** argv) {
__builtin_unreachable();
}
- llamafile_init();
llamafile_check_cpu();
gpt_params params;
diff --git a/llama.cpp/quantize/quantize.cpp b/llama.cpp/quantize/quantize.cpp
index 9b7b9cae..76ed165b 100644
--- a/llama.cpp/quantize/quantize.cpp
+++ b/llama.cpp/quantize/quantize.cpp
@@ -211,7 +211,6 @@ int main(int argc, char ** argv) {
__builtin_unreachable();
}
- llamafile_init();
llamafile_check_cpu();
if (argc < 3) {
diff --git a/llamafile/init.c b/llamafile/init.c
deleted file mode 100644
index 626a9b74..00000000
--- a/llamafile/init.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// -*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-
-// vi: set et ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
-//
-// Copyright 2023 Mozilla Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-void llamafile_init(void) {
-}
diff --git a/llamafile/sgemm.cpp b/llamafile/sgemm.cpp
index 54ba1b21..3430e6dc 100644
--- a/llamafile/sgemm.cpp
+++ b/llamafile/sgemm.cpp
@@ -15,7 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifdef __x86_64__
#include "sgemm.h"
#include "llamafile.h"
#include <cosmo.h>
@@ -111,5 +110,3 @@ bool llamafile_sgemm(int m, int n, int k, const void *A, int lda, const void *B,
return false;
}
}
-
-#endif // __x86_64__
diff --git a/llamafile/simple.cpp b/llamafile/simple.cpp
index 474e2436..123d75b0 100644
--- a/llamafile/simple.cpp
+++ b/llamafile/simple.cpp
@@ -53,9 +53,13 @@ static bool eval_string(struct llama_context *ctx_llama, const char *str, int n_
}
int main(int argc, char **argv) {
+
+ llamafile_check_cpu();
+ ShowCrashReports();
+ log_disable();
+
gpt_params params;
params.n_ctx = 0;
- FLAG_log_disable = true;
if (!gpt_params_parse(argc, argv, params))
return 1;