Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Improve process loading time
Justine Tunney73810a4c9e6e
diff --git a/llama.cpp/README.llamafile b/llama.cpp/README.llamafileindex a4f3ec5f..6321af81 100644--- a/llama.cpp/README.llamafile+++ b/llama.cpp/README.llamafile@@ -14,6 +14,7 @@ ORIGINLOCAL MODIFICATIONS+ - Remove MAP_POPULATE because it makes mmap(tinyllama) block for 100ms- Refactor ggml.c, llama.cpp, and llava to use llamafile_open() APIs- Unify main, server, and llava-cli into single llamafile program- Make cuBLAS / hipBLAS optional by introducing tinyBLAS librarydiff --git a/llama.cpp/llama.cpp b/llama.cpp/llama.cppindex dd1da6f8..cefe2f2a 100644--- a/llama.cpp/llama.cpp+++ b/llama.cpp/llama.cpp@@ -1067,7 +1067,7 @@ struct llama_mmap {}// prefetch/readahead impairs performance on NUMA systemsif (numa) { prefetch = 0; }- addr = mmap(NULL, size, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0);+ addr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);if (addr == MAP_FAILED) {throw std::runtime_error(format("mmap failed: %s", strerror(errno)));}diff --git a/llamafile/float.h b/llamafile/float.hindex 3157d0be..76a52b6d 100644--- a/llamafile/float.h+++ b/llamafile/float.h@@ -29,7 +29,7 @@ inline bool isnormal(float f) {return expo && expo != 0x7f800000;}-template <typename T> inline bool isdenormal(T f) {+inline bool isdenormal(float f) {return f && !isnormal(f) && !isnan(f) && !isinf(f);}diff --git a/llamafile/half.h b/llamafile/half.hindex c1563bca..ac6545bb 100644--- a/llamafile/half.h+++ b/llamafile/half.h@@ -35,4 +35,8 @@ inline bool isnormal(half f) {return expo && expo != 0x7c00;}+inline bool isdenormal(half f) {+ return f && !isnormal(f) && !isnan(f) && !isinf(f);+}+} // namespace fltdiff --git a/llamafile/sgemm.cpp b/llamafile/sgemm.cppindex 12b9c383..5f62b721 100644--- a/llamafile/sgemm.cpp+++ b/llamafile/sgemm.cpp@@ -55,6 +55,9 @@ bool llamafile_sgemm(int m, int n, int k, const void *A, int lda, const void *B,assert(m >= 0);assert(n >= 0);assert(k >= 0);+ assert(lda >= k);+ assert(ldb >= k);+ assert(ldc >= m);assert(nth > 0);assert(ith < nth);diff --git a/llamafile/tester.cu b/llamafile/tester.cuindex 8f5f8974..3947c440 100644--- a/llamafile/tester.cu+++ b/llamafile/tester.cu@@ -21,6 +21,10 @@#include <atomic>#include <iostream>+#ifndef _WIN32+#include <unistd.h>+#endif+#ifdef __HIP__#define VENDOR "AMD"#else