Skip to content

Commit 6738215

Browse files
authored
add tests.sh
1 parent 1d86bd8 commit 6738215

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

examples/gguf-split/tests.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
if [ $# -lt 1 ]
6+
then
7+
echo "usage: $0 path_to_build_binary [path_to_temp_folder]"
8+
echo "example: $0 ../../build/bin ../../tmp"
9+
exit 1
10+
fi
11+
12+
if [ $# -gt 1 ]
13+
then
14+
TMP_DIR=$2
15+
else
16+
TMP_DIR=/tmp
17+
fi
18+
19+
set -x
20+
21+
SPLIT=$1/gguf-split
22+
MAIN=$1/main
23+
WORK_PATH=$TMP_DIR
24+
CUR_DIR=$(pwd)
25+
26+
# 1. Get a model
27+
(
28+
cd $WORK_PATH
29+
"$CUR_DIR"/../../scripts/hf.sh --repo ggml-org/gemma-1.1-2b-it-Q8_0-GGUF --file gemma-1.1-2b-it.Q8_0.gguf
30+
)
31+
echo PASS
32+
33+
# 2. Split with max tensors strategy
34+
$SPLIT --split-max-tensors 28 $WORK_PATH/gemma-1.1-2b-it.Q8_0.gguf $WORK_PATH/ggml-model-split
35+
echo PASS
36+
echo
37+
38+
# 2b. Test the sharded model is loading properly
39+
$MAIN --model $WORK_PATH/ggml-model-split-00001-of-00006.gguf --random-prompt --n-predict 32
40+
echo PASS
41+
echo
42+
43+
# 3. Merge
44+
$SPLIT --merge $WORK_PATH/ggml-model-split-00001-of-00006.gguf $WORK_PATH/ggml-model-merge.gguf
45+
echo PASS
46+
echo
47+
48+
# 3b. Test the merged model is loading properly
49+
$MAIN --model $WORK_PATH/ggml-model-merge.gguf --random-prompt --n-predict 32
50+
echo PASS
51+
echo
52+
53+
# 4. Split with no tensor in metadata
54+
#$SPLIT --split-max-tensors 32 --no-tensor-in-metadata $WORK_PATH/ggml-model-merge.gguf $WORK_PATH/ggml-model-split-32-tensors
55+
#echo PASS
56+
#echo
57+
58+
# 4b. Test the sharded model is loading properly
59+
#$MAIN --model $WORK_PATH/ggml-model-split-32-tensors-00001-of-00006.gguf --random-prompt --n-predict 32
60+
#echo PASS
61+
#echo
62+
63+
# 5. Merge
64+
#$SPLIT --merge $WORK_PATH/ggml-model-split-32-tensors-00001-of-00006.gguf $WORK_PATH/ggml-model-merge-2.gguf
65+
#echo PASS
66+
#echo
67+
68+
# 5b. Test the merged model is loading properly
69+
#$MAIN --model $WORK_PATH/ggml-model-merge-2.gguf --random-prompt --n-predict 32
70+
#echo PASS
71+
#echo
72+
73+
# 6. Split with size strategy
74+
$SPLIT --split-max-size 2G $WORK_PATH/ggml-model-merge.gguf $WORK_PATH/ggml-model-split-2G
75+
echo PASS
76+
echo
77+
78+
# 6b. Test the sharded model is loading properly
79+
$MAIN --model $WORK_PATH/ggml-model-split-2G-00001-of-00002.gguf --random-prompt --n-predict 32
80+
echo PASS
81+
echo

0 commit comments

Comments
 (0)