-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
135 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import requests | ||
from tqdm import tqdm | ||
|
||
if __name__ == "__main__": | ||
url = "http://localhost:8000/v1/chat/completions" | ||
headers = {"Content-Type": "application/json", "Authorization": "Bearer common"} | ||
data = {"messages": [{"role": "user", "content": "Hello, how are you?"}]} | ||
# warm-up | ||
response = requests.post(url, headers=headers, json=data) | ||
|
||
cost_time_list = [] | ||
for _ in tqdm(range(10)): | ||
response = requests.post(url, headers=headers, json=data) | ||
cost_time_list.append(response.json()["cost_time"]) | ||
# 去掉最大值和最小值 | ||
cost_time_list = sorted(cost_time_list)[1:-1] | ||
test_tokens = 20 | ||
print("cost time: ", sum(cost_time_list) / len(cost_time_list)) | ||
print("token/s: ", test_tokens / (sum(cost_time_list) / len(cost_time_list))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,67 @@ | ||
#!/bin/bash | ||
MASTER_PORT=29501 | ||
GRPC_PORT=25001 | ||
BASE_PATH=/Users/lujianghu/Documents/ | ||
MODE_SIZE=$1 | ||
TP=$2 | ||
PP=$3 | ||
PP_IDX=$3 | ||
|
||
# PP 当前仅限于 0 和 1 | ||
if [ $PP != "0" ] && [ $PP != "1" ]; then | ||
# PP_IDX 当前仅限于 0 和 1 | ||
# MODEL_PATH 当前仅限于 1 3 8 70 | ||
if [ $PP_IDX != "0" ] && [ $PP_IDX != "1" ]; then | ||
echo "Invalid pp size" | ||
exit 1 | ||
fi | ||
|
||
if [ $MODE_SIZE == "1.1" ]; then | ||
MODEL_PATH=/Users/lujianghu/Documents/TinyLlama-1.1B-Chat-v1.0 | ||
if [ $PP == "0" ]; then | ||
START_LAYER_IDX=0 | ||
END_LAYER_IDX=11 | ||
elif [ $PP == "1" ]; then | ||
START_LAYER_IDX=11 | ||
END_LAYER_IDX=22 | ||
else | ||
echo "Invalid pp size" | ||
exit 1 | ||
fi | ||
elif [ $MODE_SIZE == "1" ]; then | ||
MODEL_PATH=/Users/lujianghu/Documents/Llama-3.2-1B-Instruct | ||
if [ $PP == "0" ]; then | ||
|
||
if [ $MODE_SIZE == "1" ]; then | ||
MODEL_PATH=$BASE_PATH/Llama-3.2-1B-Instruct | ||
if [ $PP_IDX == "0" ]; then | ||
START_LAYER_IDX=0 | ||
END_LAYER_IDX=8 | ||
elif [ $PP == "1" ]; then | ||
elif [ $PP_IDX == "1" ]; then | ||
START_LAYER_IDX=8 | ||
END_LAYER_IDX=16 | ||
else | ||
echo "Invalid pp size" | ||
exit 1 | ||
fi | ||
elif [ $MODE_SIZE == "3" ]; then | ||
MODEL_PATH=/Users/lujianghu/Documents/Llama-3.2-3B-Instruct | ||
if [ $PP == "0" ]; then | ||
MODEL_PATH=$BASE_PATH/Llama-3.2-3B-Instruct | ||
if [ $PP_IDX == "0" ]; then | ||
START_LAYER_IDX=0 | ||
END_LAYER_IDX=14 | ||
elif [ $PP == "1" ]; then | ||
elif [ $PP_IDX == "1" ]; then | ||
START_LAYER_IDX=14 | ||
END_LAYER_IDX=28 | ||
else | ||
echo "Invalid pp size" | ||
exit 1 | ||
fi | ||
elif [ $MODE_SIZE == "8" ]; then | ||
MODEL_PATH=/Users/lujianghu/Documents/Meta-Llama-3-8B-Instruct | ||
if [ $PP == "0" ]; then | ||
MODEL_PATH=$BASE_PATH/Meta-Llama-3-8B-Instruct | ||
if [ $PP_IDX == "0" ]; then | ||
START_LAYER_IDX=0 | ||
END_LAYER_IDX=16 | ||
elif [ $PP == "1" ]; then | ||
elif [ $PP_IDX == "1" ]; then | ||
START_LAYER_IDX=16 | ||
END_LAYER_IDX=32 | ||
else | ||
echo "Invalid pp size" | ||
exit 1 | ||
fi | ||
elif [ $MODE_SIZE == "70" ]; then | ||
MODEL_PATH=/Users/lujianghu/Documents/Meta-Llama-3-70B-Instruct | ||
MODEL_PATH=$BASE_PATH/Meta-Llama-3-70B-Instruct | ||
else | ||
echo "Invalid mode size" | ||
exit 1 | ||
fi | ||
|
||
export OMP_NUM_THREADS=8; | ||
export PYTHONPATH="./tllm":$PYTHONPATH; | ||
export PYTHONPATH="./":$PYTHONPATH; | ||
|
||
if [ $PP == "0" ]; then | ||
if [ $PP_IDX == "0" ]; then | ||
torchrun --nproc_per_node=$TP --master_port=$MASTER_PORT tllm/rpc/client.py --port=$GRPC_PORT --start_layer_idx=$START_LAYER_IDX --end_layer_idx=$END_LAYER_IDX --model_path $MODEL_PATH | ||
elif [ $PP == "1" ]; then | ||
elif [ $PP_IDX == "1" ]; then | ||
torchrun --nproc_per_node=$TP --master_port=$(($MASTER_PORT+1)) tllm/rpc/client.py --port=$(($GRPC_PORT+1)) --start_layer_idx=$START_LAYER_IDX --end_layer_idx=$END_LAYER_IDX --model_path $MODEL_PATH | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
transformers>=4.41.2 | ||
transformers==4.36.2 | ||
torch | ||
grpcio | ||
grpcio-tools | ||
protobuf | ||
grpcio==1.66.2 | ||
grpcio-tools==1.66.2 | ||
protobuf==5.28.0 | ||
requests | ||
fastapi | ||
tiktoken | ||
tqdm | ||
uvicorn | ||
uvicorn | ||
accelerate | ||
sentencepiece |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.