fancier Makefile
Browse files- .gitignore +1 -1
- Makefile +19 -17
.gitignore
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
convert.py
|
2 |
-
llama.cpp
|
3 |
pytorch_model.bin
|
4 |
*.sha
|
5 |
*.tar.gz
|
|
|
1 |
convert.py
|
2 |
+
llama.cpp*/
|
3 |
pytorch_model.bin
|
4 |
*.sha
|
5 |
*.tar.gz
|
Makefile
CHANGED
@@ -2,38 +2,40 @@ MODEL_NAME= open-llama-3b
|
|
2 |
PYTHON?= python
|
3 |
LLAMA_TAG= 5c64a09
|
4 |
LLAMA_TAR= master-$(LLAMA_TAG).tar.gz
|
|
|
5 |
HF_REPO= openlm-research/open_llama_3b
|
6 |
HF_REF= main
|
7 |
-
HF_FILES= pytorch_model.bin tokenizer.model
|
8 |
-
$(HF_FILES): SITE= https://huggingface.co/$(HF_REPO)/resolve/$(HF_REF)
|
9 |
-
$(LLAMA_TAR): SITE= https://github.com/ggerganov/llama.cpp/archive/refs/tags
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
QUANTS= f16 q4_0 q4_1 q5_0 q5_1 q8_0
|
14 |
-
MODEL_FILES= $(
|
15 |
|
16 |
.PHONY: all
|
17 |
all: $(MODEL_FILES) SHA256SUMS
|
18 |
|
19 |
-
$(FILES)
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
tar -xf $< --strip-components=1 -C $@
|
25 |
|
26 |
-
|
27 |
-
$(MAKE) -C
|
28 |
|
29 |
-
convert.py: convert.py.diff |
|
30 |
-
patch -ru
|
31 |
|
32 |
-
$(MODEL_NAME)-f16.bin: $(
|
33 |
$(PYTHON) convert.py --outtype f16 --outfile $@ .
|
34 |
|
35 |
-
$(MODEL_NAME)-q%.bin: $(MODEL_NAME)-f16.bin |
|
36 |
-
|
37 |
|
38 |
%.sha: %
|
39 |
sha256sum $< > $@
|
|
|
2 |
PYTHON?= python
|
3 |
LLAMA_TAG= 5c64a09
|
4 |
LLAMA_TAR= master-$(LLAMA_TAG).tar.gz
|
5 |
+
LLAMA_DIR= llama.cpp-master-$(LLAMA_TAG)
|
6 |
HF_REPO= openlm-research/open_llama_3b
|
7 |
HF_REF= main
|
|
|
|
|
|
|
8 |
|
9 |
+
DISTS= gh hf
|
10 |
+
SITES.gh= https://github.com/ggerganov/llama.cpp/archive/refs/tags
|
11 |
+
FILES.gh= $(LLAMA_TAR)
|
12 |
+
SITES.hf= https://huggingface.co/$(HF_REPO)/resolve/$(HF_REF)
|
13 |
+
FILES.hf= pytorch_model.bin tokenizer.model
|
14 |
|
15 |
QUANTS= f16 q4_0 q4_1 q5_0 q5_1 q8_0
|
16 |
+
MODEL_FILES= $(foreach q,$(QUANTS),$(MODEL_NAME)-$(q).bin)
|
17 |
|
18 |
.PHONY: all
|
19 |
all: $(MODEL_FILES) SHA256SUMS
|
20 |
|
21 |
+
DISTFILES= $(foreach d,$(DISTS),$(FILES.$(d)))
|
22 |
+
$(DISTFILES) &:
|
23 |
+
curl --location $(foreach d,$(DISTS), $(foreach f,$(FILES.$(d)), -o $(f) -z $(f) --url $(SITES.$(d))/$(f)))
|
24 |
|
25 |
+
$(LLAMA_DIR): | $(LLAMA_TAR)
|
26 |
+
tar -xf $(LLAMA_TAR)
|
|
|
27 |
|
28 |
+
$(LLAMA_DIR)/quantize: | $(LLAMA_DIR)
|
29 |
+
$(MAKE) -C $(LLAMA_DIR) quantize
|
30 |
|
31 |
+
convert.py: convert.py.diff | $(LLAMA_DIR)
|
32 |
+
patch -ru $(LLAMA_DIR)/convert.py -i $< -o $@
|
33 |
|
34 |
+
$(MODEL_NAME)-f16.bin: $(FILES.hf) convert.py
|
35 |
$(PYTHON) convert.py --outtype f16 --outfile $@ .
|
36 |
|
37 |
+
$(MODEL_NAME)-q%.bin: $(MODEL_NAME)-f16.bin | $(LLAMA_DIR)/quantize
|
38 |
+
$(LLAMA_DIR)/quantize $< $@ q$*
|
39 |
|
40 |
%.sha: %
|
41 |
sha256sum $< > $@
|