Skip to content

Commit e500d61

Browse files
authored
Deprecation warning to assist with migration to new binary names (#8283)
* Adding a simple program to provide a deprecation warning that can exist to help people notice the binary name change from #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 a03e8dd commit e500d61

File tree

3 files changed

+160
-4
lines changed

3 files changed

+160
-4
lines changed

Makefile

+74-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ TEST_TARGETS = \
6464
tests/test-tokenizer-1-spm
6565

6666
# Legacy build targets that were renamed in #7809, but should still be removed when the project is cleaned
67-
LEGACY_TARGETS = main quantize quantize-stats perplexity imatrix embedding vdot q8dot train-text-from-scratch convert-llama2c-to-ggml \
67+
LEGACY_TARGETS_CLEAN = main quantize quantize-stats perplexity imatrix embedding vdot q8dot train-text-from-scratch convert-llama2c-to-ggml \
6868
simple batched batched-bench save-load-state server gguf gguf-split eval-callback llama-bench libllava.a llava-cli baby-llama \
6969
retrieval speculative infill tokenize benchmark-matmult parallel finetune export-lora lookahead lookup passkey gritlm
7070

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+
7175
# Deprecation aliases
7276
ifdef LLAMA_CUBLAS
7377
$(error LLAMA_CUBLAS is removed. Use GGML_CUDA instead.)
@@ -193,7 +197,7 @@ ifdef GGML_RPC
193197
BUILD_TARGETS += rpc-server
194198
endif
195199

196-
default: $(BUILD_TARGETS)
200+
default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
197201

198202
test: $(TEST_TARGETS)
199203
@failures=0; \
@@ -228,7 +232,7 @@ test: $(TEST_TARGETS)
228232
fi
229233
@echo 'All tests passed.'
230234

231-
all: $(BUILD_TARGETS) $(TEST_TARGETS)
235+
all: $(BUILD_TARGETS) $(TEST_TARGETS) $(LEGACY_TARGETS_BUILD)
232236

233237
ifdef RISCV_CROSS_COMPILE
234238
CC := riscv64-unknown-linux-gnu-gcc
@@ -1098,7 +1102,7 @@ clean:
10981102
rm -vrf ggml/src/ggml-cuda/template-instances/*.o
10991103
rm -rvf $(BUILD_TARGETS)
11001104
rm -rvf $(TEST_TARGETS)
1101-
rm -rvf $(LEGACY_TARGETS)
1105+
rm -rvf $(LEGACY_TARGETS_CLEAN)
11021106
find examples pocs -type f -name "*.o" -delete
11031107

11041108
#
@@ -1494,3 +1498,69 @@ llama-q8dot: pocs/vdot/q8dot.cpp ggml/src/ggml.o \
14941498
$(OBJ_GGML)
14951499
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
14961500
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1501+
1502+
#
1503+
# Deprecated binaries that we want to keep around long enough for people to migrate to the new filenames, then these can be removed.
1504+
#
1505+
# Mark legacy binary targets as .PHONY so that they are always checked.
1506+
.PHONY: main quantize perplexity embedding server finetune
1507+
1508+
main: examples/deprecation-warning/deprecation-warning.cpp
1509+
ifneq (,$(wildcard main))
1510+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1511+
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1512+
@echo "#########"
1513+
@echo "WARNING: The 'main' binary is deprecated. Please use 'llama-cli' instead."
1514+
@echo " Remove the 'main' binary to remove this warning."
1515+
@echo "#########"
1516+
endif
1517+
1518+
quantize: examples/deprecation-warning/deprecation-warning.cpp
1519+
ifneq (,$(wildcard quantize))
1520+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1521+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1522+
@echo "#########"
1523+
@echo "WARNING: The 'quantize' binary is deprecated. Please use 'llama-quantize' instead."
1524+
@echo " Remove the 'quantize' binary to remove this warning."
1525+
@echo "#########"
1526+
endif
1527+
1528+
perplexity: examples/deprecation-warning/deprecation-warning.cpp
1529+
ifneq (,$(wildcard perplexity))
1530+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1531+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1532+
@echo "#########"
1533+
@echo "WARNING: The 'perplexity' binary is deprecated. Please use 'llama-perplexity' instead."
1534+
@echo " Remove the 'perplexity' binary to remove this warning."
1535+
@echo "#########"
1536+
endif
1537+
1538+
embedding: examples/deprecation-warning/deprecation-warning.cpp
1539+
ifneq (,$(wildcard embedding))
1540+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1541+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1542+
@echo "#########"
1543+
@echo "WARNING: The 'embedding' binary is deprecated. Please use 'llama-embedding' instead."
1544+
@echo " Remove the 'embedding' binary to remove this warning."
1545+
@echo "#########"
1546+
endif
1547+
1548+
server: examples/deprecation-warning/deprecation-warning.cpp
1549+
ifneq (,$(wildcard server))
1550+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1551+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1552+
@echo "#########"
1553+
@echo "WARNING: The 'server' binary is deprecated. Please use 'llama-server' instead."
1554+
@echo " Remove the 'server' binary to remove this warning."
1555+
@echo "#########"
1556+
endif
1557+
1558+
finetune: examples/deprecation-warning/deprecation-warning.cpp
1559+
ifneq (,$(wildcard finetune))
1560+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1561+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1562+
@echo "#########"
1563+
@echo "WARNING: The 'finetune' binary is deprecated. Please use 'llama-finetune' instead."
1564+
@echo " Remove the 'finetune' binary to remove this warning."
1565+
@echo "#########"
1566+
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)