Skip to content

Distribute and run LLMs with a single file.

Add --version flag

Justine Tunneyd4e23880ddd1
diff --git a/llama.cpp/common.h b/llama.cpp/common.h
index bebe5b82..e9e1093f 100644
--- a/llama.cpp/common.h
+++ b/llama.cpp/common.h
@@ -3,8 +3,8 @@
#pragma once
#include "llama.h"
-
#include "sampling.h"
+#include "llamafile/version.h"
#define LOG_NO_FILE_LINE_FUNCTION
#include "log.h"
@@ -26,9 +26,8 @@
#define die(msg) do { fputs("error: " msg "\n", stderr); exit(1); } while (0)
#define die_fmt(fmt, ...) do { fprintf(stderr, "error: " fmt "\n", __VA_ARGS__); exit(1); } while (0)
-#define print_build_info() do { \
- fprintf(stderr, "%s: build = %d (%s)\n", __func__, LLAMA_BUILD_NUMBER, LLAMA_COMMIT); \
- fprintf(stderr, "%s: built with %s for %s\n", __func__, LLAMA_COMPILER, LLAMA_BUILD_TARGET); \
+#define print_build_info() do { \
+ fprintf(stderr, "%s: llamafile version " LLAMAFILE_VERSION_STRING "\n", __func__, LLAMA_BUILD_NUMBER, LLAMA_COMMIT); \
} while(0)
// build info
diff --git a/llama.cpp/main/main.cc b/llama.cpp/main/main.cc
index 801891b1..f3760935 100644
--- a/llama.cpp/main/main.cc
+++ b/llama.cpp/main/main.cc
@@ -4,6 +4,7 @@
#include <cosmo.h>
#include "llama.cpp/ggml-metal.h"
#include "llama.cpp/ggml-cuda.h"
+#include "llamafile/version.h"
#include "tool/args/args.h"
#include "llama.cpp/common.h"
@@ -105,6 +106,11 @@ static int Eval(struct llama_context * ctx, struct llama_batch batch) {
}
int main(int argc, char ** argv) {
+ if (argc == 2 && !strcmp(argv[1], "--version")) {
+ printf("llamafile v" LLAMAFILE_VERSION_STRING " main\n");
+ exit(0);
+ }
+
llamafile_check_cpu();
ShowCrashReports();
LoadZipArgs(&argc, &argv);
@@ -184,8 +190,7 @@ int main(int argc, char ** argv) {
LOG_TEE("%s: warning: scaling RoPE frequency by %g.\n", __func__, params.rope_freq_scale);
}
- LOG_TEE("%s: build = %d (%s)\n", __func__, LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
- LOG_TEE("%s: built with %s for %s\n", __func__, LLAMA_COMPILER, LLAMA_BUILD_TARGET);
+ print_build_info();
if (params.seed == LLAMA_DEFAULT_SEED) {
params.seed = time(NULL);
diff --git a/llama.cpp/quantize/quantize.cpp b/llama.cpp/quantize/quantize.cpp
index fce263b2..975d590f 100644
--- a/llama.cpp/quantize/quantize.cpp
+++ b/llama.cpp/quantize/quantize.cpp
@@ -2,6 +2,7 @@
// vi: set net ft=c++ ts=4 sts=4 sw=4 fenc=utf-8 :vi
#include "llama.cpp/common.h"
#include "llama.cpp/llama.h"
+#include "llamafile/version.h"
#include <cstdio>
#include <cstring>
@@ -94,6 +95,11 @@ static void usage(const char * executable) {
}
int main(int argc, char ** argv) {
+ if (argc == 2 && !strcmp(argv[1], "--version")) {
+ printf("llamafile v" LLAMAFILE_VERSION_STRING " quantize\n");
+ exit(0);
+ }
+
llamafile_check_cpu();
if (argc < 3) {
diff --git a/llama.cpp/server/server.cpp b/llama.cpp/server/server.cpp
index 9919534b..01c0ca17 100644
--- a/llama.cpp/server/server.cpp
+++ b/llama.cpp/server/server.cpp
@@ -10,6 +10,7 @@
#include "llama.cpp/ggml-metal.h"
#include "llama.cpp/ggml-cuda.h"
#include "llamafile/llamafile.h"
+#include "llamafile/version.h"
#define CPPHTTPLIB_NO_EXCEPTIONS 1
@@ -2628,6 +2629,11 @@ static void append_to_generated_text_from_generated_token_probs(llama_server_con
int main(int argc, char **argv)
{
+ if (argc == 2 && !strcmp(argv[1], "--version")) {
+ printf("llamafile v" LLAMAFILE_VERSION_STRING " server\n");
+ exit(0);
+ }
+
llamafile_check_cpu();
LoadZipArgs(&argc, &argv);
diff --git a/llamafile/version.h b/llamafile/version.h
new file mode 100644
index 00000000..54841db1
--- /dev/null
+++ b/llamafile/version.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#define LLAMAFILE_MAJOR 0
+#define LLAMAFILE_MINOR 2
+#define LLAMAFILE_PATCH 1
+#define LLAMAFILE_VERSION (100000000 * LLAMAFILE_MAJOR + 1000000 * LLAMAFILE_MINOR + LLAMAFILE_PATCH)
+
+#define MKVERSION__(x, y, z) #x "." #y "." #z
+#define MKVERSION_(x, y, z) MKVERSION__(x, y, z)
+#define LLAMAFILE_VERSION_STRING MKVERSION_(LLAMAFILE_MAJOR, LLAMAFILE_MINOR, LLAMAFILE_PATCH)