Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Make server.o build 2x faster
Justine Tunneybc267084fe8d
diff --git a/llama.cpp/server/BUILD.mk b/llama.cpp/server/BUILD.mkindex a302f57c..ae58f440 100644--- a/llama.cpp/server/BUILD.mk+++ b/llama.cpp/server/BUILD.mk@@ -8,6 +8,8 @@ LLAMA_CPP_SERVER_ASSETS := $(wildcard llama.cpp/server/public/*)LLAMA_CPP_SERVER_HDRS = $(filter %.h,$(LLAMA_CPP_SERVER_FILES))LLAMA_CPP_SERVER_SRCS = $(filter %.cpp,$(LLAMA_CPP_SERVER_FILES))+o/$(MODE)/llama.cpp/server/server.o: private CXXFLAGS += -O1+o/$(MODE)/llama.cpp/server/server: \o/$(MODE)/llama.cpp/server/server.o \o/$(MODE)/llama.cpp/llava/llava.a \diff --git a/llamafile/BUILD.mk b/llamafile/BUILD.mkindex 618592b6..87b2f9da 100644--- a/llamafile/BUILD.mk+++ b/llamafile/BUILD.mk@@ -22,4 +22,5 @@ o/$(MODE)/llamafile/zipcheck: \o/$(MODE)/llamafile: \$(LLAMAFILE_OBJS) \o/$(MODE)/llamafile/zipalign \- o/$(MODE)/llamafile/zipcheck+ o/$(MODE)/llamafile/zipcheck \+ o/$(MODE)/llamafile/addnldiff --git a/llamafile/addnl.c b/llamafile/addnl.cnew file mode 100644index 00000000..86f5b142--- /dev/null+++ b/llamafile/addnl.c@@ -0,0 +1,52 @@+// -*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-+// vi: set net 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.++#include <time.h>+#include <stdio.h>+#include <string.h>+#include <unistd.h>++// example usage+//+// /opt/cosmocc/bin/x86_64-linux-cosmo-g+++// -oo//llama.cpp/server/server.o -D__COSMOPOLITAN__ -D__COSMOCC__+// -D__FATCOSMOCC__ -include libc/integral/normalize.inc -fportcosmo+// -fno-dwarf2-cfi-asm -fno-unwind-tables+// -fno-asynchronous-unwind-tables -fno-semantic-interposition+// -fno-optimize-sibling-calls -mno-omit-leaf-frame-pointer -fno-rtti+// -fno-exceptions -fuse-cxa-atexit -mno-tls-direct-seg-refs+// -fpatchable-function-entry=18,16 -fno-pie -nostdinc -fno-math-errno+// -isystem /opt/cosmocc/bin/../include -mno-red-zone -D_COSMO_SOURCE -g+// -O3 -iquote. -c -c llama.cpp/server/server.cpp -mssse3+// -fno-omit-frame-pointer -Q |& o//llamafile/addnl++int main(int argc, char *argv[]) {+ char tbuf[128];+ static char buf[134217728];+ struct timespec t = timespec_real();+ for (;;) {+ ssize_t rc = read(0, buf, sizeof(buf));+ if (!rc) break;+ struct timespec u = timespec_real();+ struct timespec d = timespec_sub(u, t);+ t = u;+ snprintf(tbuf, sizeof(tbuf), "%012ld ", timespec_tomicros(d));+ write(1, tbuf, strlen(tbuf));+ write(1, buf, rc);+ write(1, "\n", 1);+ }+}