Skip to content

Commit 8445732

Browse files
committed
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.
1 parent 5f2d4e6 commit 8445732

File tree

3 files changed

+122
-4
lines changed

3 files changed

+122
-4
lines changed

Makefile

+35-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ TEST_TARGETS = \
6363
tests/test-tokenizer-1-spm
6464

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

70+
# 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.
71+
# We don't want to clutter things too much, so we only build replacements for the most commonly used binaries.
72+
LEGACY_TARGETS_BUILD = main quantize perplexity embedding server finetune
73+
7074
# Deprecation aliases
7175
ifdef LLAMA_CUBLAS
7276
$(error LLAMA_CUBLAS is removed. Use GGML_CUDA instead.)
@@ -192,7 +196,7 @@ ifdef GGML_RPC
192196
BUILD_TARGETS += rpc-server
193197
endif
194198

195-
default: $(BUILD_TARGETS)
199+
default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
196200

197201
test: $(TEST_TARGETS)
198202
@failures=0; \
@@ -227,7 +231,7 @@ test: $(TEST_TARGETS)
227231
fi
228232
@echo 'All tests passed.'
229233

230-
all: $(BUILD_TARGETS) $(TEST_TARGETS)
234+
all: $(BUILD_TARGETS) $(TEST_TARGETS) $(LEGACY_TARGETS_BUILD)
231235

232236
ifdef RISCV_CROSS_COMPILE
233237
CC := riscv64-unknown-linux-gnu-gcc
@@ -1091,7 +1095,7 @@ clean:
10911095
rm -vrf ggml/src/ggml-cuda/template-instances/*.o
10921096
rm -rvf $(BUILD_TARGETS)
10931097
rm -rvf $(TEST_TARGETS)
1094-
rm -rvf $(LEGACY_TARGETS)
1098+
rm -rvf $(LEGACY_TARGETS_CLEAN)
10951099
find examples pocs -type f -name "*.o" -delete
10961100

10971101
#
@@ -1470,3 +1474,30 @@ llama-q8dot: pocs/vdot/q8dot.cpp ggml/src/ggml.o \
14701474
$(OBJ_GGML)
14711475
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
14721476
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1477+
1478+
#
1479+
# Deprecated binaries that we want to keep around long enough for people to migrate to the new filenames, then these can be removed.
1480+
#
1481+
main: examples/deprecation-warning/deprecation-warning.cpp
1482+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1483+
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1484+
1485+
quantize: examples/deprecation-warning/deprecation-warning.cpp
1486+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1487+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1488+
1489+
perplexity: examples/deprecation-warning/deprecation-warning.cpp
1490+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1491+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1492+
1493+
embedding: examples/deprecation-warning/deprecation-warning.cpp
1494+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1495+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1496+
1497+
server: examples/deprecation-warning/deprecation-warning.cpp
1498+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1499+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1500+
1501+
finetune: examples/deprecation-warning/deprecation-warning.cpp
1502+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1503+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
+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 is long-overdue, but it is a breaking change that may not always be immediately obvious.
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,36 @@
1+
// Warns users that this filename was deprecated, and provides a link for more information.
2+
// If the name of the file matches a name in a lookup table, then provide the replacement name as well.
3+
4+
#include <cstdio>
5+
#include <string>
6+
#include <unordered_map>
7+
8+
// Main
9+
int main(int argc, char** argv) {
10+
std::string filename = "main";
11+
if (argc >= 1) {
12+
filename = argv[0];
13+
}
14+
15+
// Get only the program name from the full path
16+
auto pos = filename.find_last_of('/');
17+
if (pos != std::string::npos) {
18+
filename = filename.substr(pos+1);
19+
}
20+
21+
// Append "llama-" to the beginning of filename to get the replacemnt filename
22+
auto replacement_filename = "llama-" + filename;
23+
24+
// If filename is "main", then our replacement filename is llama-cli
25+
if (filename == "main") {
26+
replacement_filename = "llama-cli";
27+
}
28+
29+
fprintf(stdout, "\n");
30+
fprintf(stdout, "WARNING: The binary '%s' is deprecated.\n", filename.c_str());
31+
fprintf(stdout, " Please use '%s' instead.\n", replacement_filename.c_str());
32+
fprintf(stdout, " See https://github.com/ggerganov/llama.cpp/tree/master/examples/deprecation-warning for more information.\n");
33+
fprintf(stdout, "\n");
34+
35+
return EXIT_FAILURE;
36+
}

0 commit comments

Comments
 (0)