Skip to content

Commit 33e3968

Browse files
HanClintoNeo Zhang
authored and
Neo Zhang
committed
Deprecation warning to assist with migration to new binary names (ggml-org#8283)
* Adding a simple program to provide a deprecation warning that can exist to help people notice the binary name change from ggml-org#7809 and migrate to the new filenames. * Build legacy replacement binaries only if they already exist. Check for their existence every time so that they are not ignored.
1 parent 506ff58 commit 33e3968

File tree

3 files changed

+164
-2
lines changed

3 files changed

+164
-2
lines changed

Makefile

+78-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ TEST_TARGETS = \
6363
tests/test-tokenizer-1-bpe \
6464
tests/test-tokenizer-1-spm
6565

66+
# Legacy build targets that were renamed in #7809, but should still be removed when the project is cleaned
67+
LEGACY_TARGETS_CLEAN = main quantize quantize-stats perplexity imatrix embedding vdot q8dot train-text-from-scratch convert-llama2c-to-ggml \
68+
simple batched batched-bench save-load-state server gguf gguf-split eval-callback llama-bench libllava.a llava-cli baby-llama \
69+
retrieval speculative infill tokenize benchmark-matmult parallel finetune export-lora lookahead lookup passkey gritlm
70+
71+
# Legacy build targets that were renamed in #7809, but we want to build binaries that for them that output a deprecation warning if people try to use them.
72+
# We don't want to clutter things too much, so we only build replacements for the most commonly used binaries.
73+
LEGACY_TARGETS_BUILD = main quantize perplexity embedding server finetune
74+
6675
# Deprecation aliases
6776
ifdef LLAMA_CUBLAS
6877
$(error LLAMA_CUBLAS is removed. Use GGML_CUDA instead.)
@@ -188,7 +197,7 @@ ifdef GGML_RPC
188197
BUILD_TARGETS += rpc-server
189198
endif
190199

191-
default: $(BUILD_TARGETS)
200+
default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
192201

193202
test: $(TEST_TARGETS)
194203
@failures=0; \
@@ -223,7 +232,7 @@ test: $(TEST_TARGETS)
223232
fi
224233
@echo 'All tests passed.'
225234

226-
all: $(BUILD_TARGETS) $(TEST_TARGETS)
235+
all: $(BUILD_TARGETS) $(TEST_TARGETS) $(LEGACY_TARGETS_BUILD)
227236

228237
ifdef RISCV_CROSS_COMPILE
229238
CC := riscv64-unknown-linux-gnu-gcc
@@ -1087,6 +1096,7 @@ clean:
10871096
rm -vrf ggml/src/ggml-cuda/template-instances/*.o
10881097
rm -rvf $(BUILD_TARGETS)
10891098
rm -rvf $(TEST_TARGETS)
1099+
rm -rvf $(LEGACY_TARGETS_CLEAN)
10901100
find examples pocs -type f -name "*.o" -delete
10911101

10921102
#
@@ -1482,3 +1492,69 @@ llama-q8dot: pocs/vdot/q8dot.cpp ggml/src/ggml.o \
14821492
$(OBJ_GGML)
14831493
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
14841494
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1495+
1496+
#
1497+
# Deprecated binaries that we want to keep around long enough for people to migrate to the new filenames, then these can be removed.
1498+
#
1499+
# Mark legacy binary targets as .PHONY so that they are always checked.
1500+
.PHONY: main quantize perplexity embedding server finetune
1501+
1502+
main: examples/deprecation-warning/deprecation-warning.cpp
1503+
ifneq (,$(wildcard main))
1504+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1505+
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1506+
@echo "#########"
1507+
@echo "WARNING: The 'main' binary is deprecated. Please use 'llama-cli' instead."
1508+
@echo " Remove the 'main' binary to remove this warning."
1509+
@echo "#########"
1510+
endif
1511+
1512+
quantize: examples/deprecation-warning/deprecation-warning.cpp
1513+
ifneq (,$(wildcard quantize))
1514+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1515+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1516+
@echo "#########"
1517+
@echo "WARNING: The 'quantize' binary is deprecated. Please use 'llama-quantize' instead."
1518+
@echo " Remove the 'quantize' binary to remove this warning."
1519+
@echo "#########"
1520+
endif
1521+
1522+
perplexity: examples/deprecation-warning/deprecation-warning.cpp
1523+
ifneq (,$(wildcard perplexity))
1524+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1525+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1526+
@echo "#########"
1527+
@echo "WARNING: The 'perplexity' binary is deprecated. Please use 'llama-perplexity' instead."
1528+
@echo " Remove the 'perplexity' binary to remove this warning."
1529+
@echo "#########"
1530+
endif
1531+
1532+
embedding: examples/deprecation-warning/deprecation-warning.cpp
1533+
ifneq (,$(wildcard embedding))
1534+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1535+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1536+
@echo "#########"
1537+
@echo "WARNING: The 'embedding' binary is deprecated. Please use 'llama-embedding' instead."
1538+
@echo " Remove the 'embedding' binary to remove this warning."
1539+
@echo "#########"
1540+
endif
1541+
1542+
server: examples/deprecation-warning/deprecation-warning.cpp
1543+
ifneq (,$(wildcard server))
1544+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1545+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1546+
@echo "#########"
1547+
@echo "WARNING: The 'server' binary is deprecated. Please use 'llama-server' instead."
1548+
@echo " Remove the 'server' binary to remove this warning."
1549+
@echo "#########"
1550+
endif
1551+
1552+
finetune: examples/deprecation-warning/deprecation-warning.cpp
1553+
ifneq (,$(wildcard finetune))
1554+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1555+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1556+
@echo "#########"
1557+
@echo "WARNING: The 'finetune' binary is deprecated. Please use 'llama-finetune' instead."
1558+
@echo " Remove the 'finetune' binary to remove this warning."
1559+
@echo "#########"
1560+
endif
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Migration notice for binary filenames
2+
3+
> [!IMPORTANT]
4+
[2024 Jun 12] Binaries have been renamed w/ a `llama-` prefix. `main` is now `llama-cli`, `server` is `llama-server`, etc (https://github.com/ggerganov/llama.cpp/pull/7809)
5+
6+
This migration was important, but it is a breaking change that may not always be immediately obvious to users.
7+
8+
Please update all scripts and workflows to use the new binary names.
9+
10+
| Old Filename | New Filename |
11+
| ---- | ---- |
12+
| main | llama-cli |
13+
| server | llama-server |
14+
| llama-bench | llama-bench |
15+
| embedding | llama-embedding |
16+
| finetune | llama-finetune |
17+
| quantize | llama-quantize |
18+
| tokenize | llama-tokenize |
19+
| export-lora | llama-export-lora |
20+
| libllava.a | libllava.a |
21+
| baby-llama | llama-baby-llama |
22+
| batched | llama-batched |
23+
| batched-bench | llama-batched-bench |
24+
| benchmark-matmult | llama-benchmark-matmult |
25+
| convert-llama2c-to-ggml | llama-convert-llama2c-to-ggml |
26+
| eval-callback | llama-eval-callback |
27+
| gbnf-validator | llama-gbnf-validator |
28+
| gguf | llama-gguf |
29+
| gguf-split | llama-gguf-split |
30+
| gritlm | llama-gritlm |
31+
| imatrix | llama-imatrix |
32+
| infill | llama-infill |
33+
| llava-cli | llama-llava-cli |
34+
| lookahead | llama-lookahead |
35+
| lookup | llama-lookup |
36+
| lookup-create | llama-lookup-create |
37+
| lookup-merge | llama-lookup-merge |
38+
| lookup-stats | llama-lookup-stats |
39+
| parallel | llama-parallel |
40+
| passkey | llama-passkey |
41+
| perplexity | llama-perplexity |
42+
| q8dot | llama-q8dot |
43+
| quantize-stats | llama-quantize-stats |
44+
| retrieval | llama-retrieval |
45+
| save-load-state | llama-save-load-state |
46+
| simple | llama-simple |
47+
| speculative | llama-speculative |
48+
| train-text-from-scratch | llama-train-text-from-scratch |
49+
| vdot | llama-vdot |
50+
| tests/test-c.o | tests/test-c.o |
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Warns users that this filename was deprecated, and provides a link for more information.
2+
3+
#include <cstdio>
4+
#include <string>
5+
#include <unordered_map>
6+
7+
// Main
8+
int main(int argc, char** argv) {
9+
std::string filename = "main";
10+
if (argc >= 1) {
11+
filename = argv[0];
12+
}
13+
14+
// Get only the program name from the full path
15+
auto pos = filename.find_last_of('/');
16+
if (pos != std::string::npos) {
17+
filename = filename.substr(pos+1);
18+
}
19+
20+
// Append "llama-" to the beginning of filename to get the replacemnt filename
21+
auto replacement_filename = "llama-" + filename;
22+
23+
// The exception is if the filename is "main", then our replacement filename is "llama-cli"
24+
if (filename == "main") {
25+
replacement_filename = "llama-cli";
26+
}
27+
28+
fprintf(stdout, "\n");
29+
fprintf(stdout, "WARNING: The binary '%s' is deprecated.\n", filename.c_str());
30+
fprintf(stdout, " Please use '%s' instead.\n", replacement_filename.c_str());
31+
fprintf(stdout, " See https://github.com/ggerganov/llama.cpp/tree/master/examples/deprecation-warning/README.md for more information.\n");
32+
fprintf(stdout, "\n");
33+
34+
return EXIT_FAILURE;
35+
}

0 commit comments

Comments
 (0)