Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Don't show loading progress with --log_disable
Justine Tunney6e47b0b4b12d
diff --git a/llamafile/schlep.c b/llamafile/schlep.cindex 7db38a53..c9791e66 100644--- a/llamafile/schlep.c+++ b/llamafile/schlep.c@@ -15,14 +15,15 @@// See the License for the specific language governing permissions and// limitations under the License.+#include "llama.cpp/ggml.h"+#include "llamafile/log.h"#include <cosmo.h>-#include <stdio.h>#include <errno.h>-#include <unistd.h>#include <pthread.h>-#include <sys/auxv.h>#include <stdatomic.h>-#include "llama.cpp/ggml.h"+#include <stdio.h>+#include <sys/auxv.h>+#include <unistd.h>#define FPS 24#define THREADS 4@@ -54,8 +55,10 @@ static void *PageFaulter(void *arg) {static void FormatPercent(char sbuf[static 8], double x) {char *p = sbuf;int n = x * 100000.5;- if (n >= 100000) *p++ = '0' + n / 100000 % 10;- if (n >= 10000) *p++ = '0' + n / 10000 % 10;+ if (n >= 100000)+ *p++ = '0' + n / 100000 % 10;+ if (n >= 10000)+ *p++ = '0' + n / 10000 % 10;*p++ = '0' + n / 1000 % 10;*p++ = '.';*p++ = '0' + n / 100 % 10;@@ -69,6 +72,11 @@ static void FormatPercent(char sbuf[static 8], double x) {*/void llamafile_schlep(const void *data, size_t size) {+ // don't bother if logging is disabled+ if (FLAG_log_disable) {+ return;+ }+// don't bother if memory is smallif (size < 128 * 1024 * 1024) {return;@@ -109,7 +117,8 @@ void llamafile_schlep(const void *data, size_t size) {for (;;) {char percent[8];long count = atomic_load_explicit(&faults, memory_order_acquire);- if (count == pages) break;+ if (count == pages)+ break;FormatPercent(percent, (double)count / pages);tinyprint(2, "\rmemory map ", percent, "% loaded...\033[K", NULL);usleep(1. / FPS * 1e6);