Skip to content

Distribute and run LLMs with a single file.

Add --iq --recompile flag for IQ quant CUDA support

Justine Tunney47ff34f9e3d3
diff --git a/llama.cpp/common.cpp b/llama.cpp/common.cpp
index cbdf18aa..5335def8 100644
--- a/llama.cpp/common.cpp
+++ b/llama.cpp/common.cpp
@@ -214,6 +214,10 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa
FLAG_fast = true;
return true;
}
+ if (arg == "--iq") {
+ FLAG_iq = true;
+ return true;
+ }
if (arg == "--precise") {
FLAG_precise = true;
return true;
diff --git a/llama.cpp/server/server.cpp b/llama.cpp/server/server.cpp
index 66de5c2e..d5c4ccef 100644
--- a/llama.cpp/server/server.cpp
+++ b/llama.cpp/server/server.cpp
@@ -2577,6 +2577,10 @@ static void server_params_parse(int argc, char **argv, server_params &sparams,
{
FLAG_fast = true;
}
+ else if (arg == "--iq")
+ {
+ FLAG_iq = true;
+ }
else if (arg == "--precise")
{
FLAG_precise = true;
diff --git a/llamafile/cuda.c b/llamafile/cuda.c
index d1f8df7e..2d5df274 100644
--- a/llamafile/cuda.c
+++ b/llamafile/cuda.c
@@ -68,7 +68,7 @@ __static_yoink("_Cz_inflateEnd");
"-DGGML_CUDA_DMMV_X=32", "-DK_QUANTS_PER_ITERATION=2", \
"-DGGML_CUDA_PEER_MAX_BATCH_SIZE=128", "-DGGML_CUDA_MMV_Y=1", \
(FLAG_tinyblas ? "-DGGML_USE_TINYBLAS" : "-DGGML_USE_CUBLAS"), \
- (FLAG_flash_attn ? "-DTEHFLASH" : "-DGGML_MINIMIZE_CODE_SIZE")
+ (FLAG_iq || FLAG_flash_attn ? "-DTEHFLASH" : "-DGGML_MINIMIZE_CODE_SIZE")
#define NVCC_FLAGS \
(!IsWindows() ? "-std=c++11" : "-DIGNORE123"), "-O3", "--shared", "--use_fast_math", \
@@ -574,7 +574,7 @@ static bool compile_amd_windows(const char *clangxx, const char *dso, const char
"-DGGML_CUDA_PEER_MAX_BATCH_SIZE=128",
"-DGGML_CUDA_MMV_Y=1",
"-DGGML_USE_TINYBLAS",
- FLAG_flash_attn ? "-DTEHFLASH" : "-DGGML_MINIMIZE_CODE_SIZE",
+ FLAG_iq || FLAG_flash_attn ? "-DTEHFLASH" : "-DGGML_MINIMIZE_CODE_SIZE",
"-o",
(char *)tmpdso,
(char *)src,
diff --git a/llamafile/flags.cpp b/llamafile/flags.cpp
index 613310e2..05ebb309 100644
--- a/llamafile/flags.cpp
+++ b/llamafile/flags.cpp
@@ -33,6 +33,7 @@
bool FLAGS_READY = false;
bool FLAG_fast = false;
+bool FLAG_iq = false;
bool FLAG_log_disable = false;
bool FLAG_mlock = false;
bool FLAG_mmap = true;
@@ -289,6 +290,11 @@ void llamafile_get_flags(int argc, char **argv) {
//////////////////////////////////////////////////////////////////////
// cpu flags
+ if (!strcmp(flag, "--iq")) {
+ FLAG_iq = true;
+ continue;
+ }
+
if (!strcmp(flag, "--fast")) {
FLAG_fast = true;
continue;
diff --git a/llamafile/llamafile.h b/llamafile/llamafile.h
index bc1cf090..af480251 100644
--- a/llamafile/llamafile.h
+++ b/llamafile/llamafile.h
@@ -8,6 +8,7 @@ extern "C" {
extern bool FLAGS_READY;
extern bool FLAG_fast;
+extern bool FLAG_iq;
extern bool FLAG_log_disable;
extern bool FLAG_mlock;
extern bool FLAG_mmap;