Skip to content

Commit 6d23493

Browse files
authored
chore: Make help (#25)
Add `help` target to Makefile which extracts `##` help-comments from the Makefile itself, and add help text for common targets.
1 parent d091bda commit 6d23493

File tree

2 files changed

+53
-15
lines changed

2 files changed

+53
-15
lines changed

Makefile

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,99 @@ TEST_IMAGE_NAME ?= 'cpu-tests:0'
55
SERVER_IMAGE_NAME ?= 'text-gen-server:0'
66
GIT_COMMIT_HASH := $(shell git rev-parse --short HEAD)
77

8-
build:
8+
.PHONY: all
9+
all: help
10+
11+
.PHONY: help
12+
help: ## Display this help
13+
@awk 'BEGIN{FS=":.*##"; printf("\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n")} /^[-a-zA-Z_0-9\\.]+:.*?##/ {t=$$1; if(!(t in p)){p[t]; printf(" \033[36m%-20s\033[0m %s\n", t, $$2)}}' $(MAKEFILE_LIST)
14+
15+
.PHONY: build
16+
build: ## Build server release image
917
docker build --progress=plain --target=server-release --build-arg GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) -t $(SERVER_IMAGE_NAME) .
1018
docker images
1119

12-
all: help
13-
20+
.PHONY: install-server
1421
install-server:
1522
cd server && make install
1623

24+
.PHONY: install-custom-kernels
1725
install-custom-kernels:
18-
if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need to set the BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
19-
26+
if [ "$$BUILD_EXTENSIONS" = "True" ]; then \
27+
cd server/custom_kernels && \
28+
python setup.py install; \
29+
else \
30+
echo "Custom kernels are disabled, you need to set the BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; \
31+
fi
32+
33+
.PHONY: install-router
2034
install-router:
2135
cd router && cargo install --path .
2236

37+
.PHONY: install-launcher
2338
install-launcher:
2439
cd launcher && env GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) cargo install --path .
2540

2641
.PHONY: install-launcher-linux
2742
install-launcher-linux:
2843
cd launcher && env GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc cargo install --path . --target=x86_64-unknown-linux-gnu
2944

30-
install: install-server install-router install-launcher install-custom-kernels
45+
.PHONY: install
46+
install: install-server install-router install-launcher install-custom-kernels ## Install server, router, launcher, and custom kernels
3147

48+
.PHONY: server-dev
3249
server-dev:
3350
cd server && make run-dev
3451

52+
.PHONY: router-dev
3553
router-dev:
3654
cd router && cargo run
3755

56+
.PHONY: run-bloom-560m
3857
run-bloom-560m:
3958
text-generation-launcher --model-name bigscience/bloom-560m --num-shard 2
4059

60+
.PHONY: run-bloom-560m-quantize
4161
run-bloom-560m-quantize:
4262
text-generation-launcher --model-name bigscience/bloom-560m --num-shard 2 --dtype-str int8
4363

64+
.PHONY: download-bloom
4465
download-bloom:
4566
text-generation-server download-weights bigscience/bloom
4667

68+
.PHONY: run-bloom
4769
run-bloom:
4870
text-generation-launcher --model-name bigscience/bloom --num-shard 8
4971

72+
.PHONY: run-bloom-quantize
5073
run-bloom-quantize:
5174
text-generation-launcher --model-name bigscience/bloom --num-shard 8 --dtype-str int8
5275

53-
build-test-image:
76+
.PHONY: build-test-image
77+
build-test-image: ## Build the test image
5478
docker build --progress=plain --target=cpu-tests -t $(TEST_IMAGE_NAME) .
5579

80+
.PHONY: check-test-image
5681
check-test-image:
5782
@docker image inspect $(TEST_IMAGE_NAME) >/dev/null 2>&1 || $(MAKE) build-test-image
5883

59-
integration-tests: check-test-image
84+
.PHONY: integration-tests
85+
integration-tests: check-test-image ## Run integration tests
6086
mkdir -p /tmp/transformers_cache
6187
docker run --rm -v /tmp/transformers_cache:/transformers_cache \
6288
-e HUGGINGFACE_HUB_CACHE=/transformers_cache \
6389
-e TRANSFORMERS_CACHE=/transformers_cache \
6490
-w /usr/src/integration_tests \
6591
$(TEST_IMAGE_NAME) make test
6692

67-
python-tests: check-test-image
93+
.PHONY: python-tests
94+
python-tests: check-test-image ## Run Python tests
6895
mkdir -p /tmp/transformers_cache
6996
docker run --rm -v /tmp/transformers_cache:/transformers_cache \
7097
-e HUGGINGFACE_HUB_CACHE=/transformers_cache \
7198
-e TRANSFORMERS_CACHE=/transformers_cache \
7299
$(TEST_IMAGE_NAME) pytest -sv --ignore=server/tests/test_utils.py server/tests
73100

101+
.PHONY: clean
74102
clean:
75103
rm -rf target
76-
77-
.PHONY: build build-test-image integration-tests python-tests

server/Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
1+
.PHONY: all
2+
all: install run-dev
3+
4+
.PHONY: gen-server
15
gen-server:
26
# Compile protos
37
pip install grpcio-tools==1.60.0 mypy-protobuf==3.5.0 'types-protobuf>=3.20.4' --no-cache-dir
4-
mkdir text_generation_server/pb || true
5-
python -m grpc_tools.protoc -I../proto --python_out=text_generation_server/pb \
6-
--grpc_python_out=text_generation_server/pb --mypy_out=text_generation_server/pb ../proto/generate.proto
8+
mkdir -p text_generation_server/pb
9+
python -m grpc_tools.protoc -I../proto \
10+
--python_out=text_generation_server/pb \
11+
--grpc_python_out=text_generation_server/pb \
12+
--mypy_out=text_generation_server/pb \
13+
../proto/generate.proto
714
find text_generation_server/pb/ -type f -name "*.py" -print0 -exec sed -i -e 's/^\(import.*pb2\)/from . \1/g' {} \;
815
touch text_generation_server/pb/__init__.py
916

1017
TORCH_URL := https://download.pytorch.org/whl/cu118
1118
TORCH_VERSION := 2.0.0+cu118
1219

20+
.PHONY: install-torch
1321
install-torch:
1422
# Install specific version of torch
1523
pip install ninja==1.11.1.1 torch==$(TORCH_VERSION) --extra-index-url $(TORCH_URL) --no-cache-dir
1624

25+
.PHONY: install-deepspeed
1726
install-deepspeed:
1827
# Install specific version of deepspeed
1928
pip install deepspeed==0.7.6 --no-cache-dir
2029

30+
.PHONY: install
2131
install: gen-server install-torch
2232
pip install pip --upgrade
2333
pip install -e . --no-cache-dir
2434

35+
.PHONY: run-dev
2536
run-dev:
26-
SAFETENSORS_FAST_GPU=1 python -m torch.distributed.run --nproc_per_node=2 text_generation_server/cli.py serve bigscience/bloom-560m
37+
SAFETENSORS_FAST_GPU=1 python -m torch.distributed.run --nproc_per_node=2 \
38+
text_generation_server/cli.py serve bigscience/bloom-560m hf_transformers

0 commit comments

Comments
 (0)