|
1 | | -# /bin/bash -x |
| 1 | +#!/bin/bash -x |
2 | 2 |
|
3 | | -if [ "X$1" == "X" ]; then |
| 3 | +# Check if an argument was provided |
| 4 | +if [ -z "$1" ]; then |
4 | 5 | echo "Must specify document to run" |
5 | 6 | exit 1 |
6 | 7 | fi |
7 | 8 |
|
8 | | -if [ "$1" == "readme" ]; then |
9 | | - echo "::group::Create script to run README" |
10 | | - python3 torchchat/utils/scripts/updown.py --create-sections --file README.md --replace 'llama3.1:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-readme.sh |
11 | | - # for good measure, if something happened to updown processor, |
12 | | - # and it did not error out, fail with an exit 1 |
13 | | - echo "exit 1" >> ./run-readme.sh |
14 | | - echo "::endgroup::" |
15 | | - |
16 | | - echo "::group::Run README" |
17 | | - echo "*******************************************" |
18 | | - cat ./run-readme.sh |
19 | | - echo "*******************************************" |
20 | | - . ./run-readme.sh |
21 | | - echo "::endgroup::" |
22 | | - |
23 | | - exit 0 |
24 | | -fi |
25 | | - |
26 | | -if [ "$1" == "quantization" ]; then |
27 | | - echo "::group::Create script to run quantization" |
28 | | - python3 torchchat/utils/scripts/updown.py --create-sections --file docs/quantization.md --replace llama3:stories15M --suppress huggingface-cli,HF_TOKEN > ./run-quantization.sh |
29 | | - # for good measure, if something happened to updown processor, |
30 | | - # and it did not error out, fail with an exit 1 |
31 | | - echo "exit 1" >> ./run-quantization.sh |
32 | | - echo "::endgroup::" |
33 | | - |
34 | | - echo "::group::Run quantization" |
35 | | - echo "*******************************************" |
36 | | - cat ./run-quantization.sh |
37 | | - echo "*******************************************" |
38 | | - . ./run-quantization.sh |
39 | | - echo "::endgroup::" |
40 | | - |
41 | | - exit 0 |
42 | | -fi |
43 | | - |
44 | | -if [ "$1" == "gguf" ]; then |
45 | | - echo "::group::Create script to run gguf" |
46 | | - python3 torchchat/utils/scripts/updown.py --file docs/GGUF.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-gguf.sh |
47 | | - # for good measure, if something happened to updown processor, |
48 | | - # and it did not error out, fail with an exit 1 |
49 | | - echo "exit 1" >> ./run-gguf.sh |
50 | | - echo "::endgroup::" |
51 | | - |
52 | | - echo "::group::Run gguf" |
53 | | - echo "*******************************************" |
54 | | - cat ./run-gguf.sh |
55 | | - echo "*******************************************" |
56 | | - . ./run-gguf.sh |
57 | | - echo "::endgroup::" |
58 | | -fi |
59 | | - |
60 | | - |
61 | | -if [ "$1" == "advanced" ]; then |
62 | | - echo "::group::Create script to run advanced" |
63 | | - python3 torchchat/utils/scripts/updown.py --file docs/ADVANCED-USERS.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-advanced.sh |
64 | | - # for good measure, if something happened to updown processor, |
65 | | - # and it did not error out, fail with an exit 1 |
66 | | - echo "exit 1" >> ./run-advanced.sh |
67 | | - echo "::endgroup::" |
68 | | - |
69 | | - echo "::group::Run advanced" |
70 | | - echo "*******************************************" |
71 | | - cat ./run-advanced.sh |
72 | | - echo "*******************************************" |
73 | | - . ./run-advanced.sh |
74 | | - echo "::endgroup::" |
75 | | -fi |
76 | | - |
77 | | -if [ "$1" == "evaluation" ]; then |
78 | | - echo "::group::Create script to run evaluation" |
79 | | - python3 torchchat/utils/scripts/updown.py --file torchchat/utils/docs/evaluation.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-evaluation.sh |
80 | | - # for good measure, if something happened to updown processor, |
81 | | - # and it did not error out, fail with an exit 1 |
82 | | - echo "exit 1" >> ./run-evaluation.sh |
83 | | - echo "::endgroup::" |
84 | | - |
85 | | - echo "::group::Run evaluation" |
86 | | - echo "*******************************************" |
87 | | - cat ./run-evaluation.sh |
88 | | - echo "*******************************************" |
89 | | - . ./run-evaluation.sh |
90 | | -fi |
91 | | - |
92 | | -if [ "$1" == "multimodal" ]; then |
93 | | - |
94 | | - # Expecting that this might fail this test as-is, because |
95 | | - # it's the first on-pr test depending on github secrets for access with HF token access |
96 | | - |
97 | | - echo "::group::Create script to run multimodal" |
98 | | - python3 torchchat/utils/scripts/updown.py --file docs/multimodal.md > ./run-multimodal.sh |
99 | | - # for good measure, if something happened to updown processor, |
100 | | - # and it did not error out, fail with an exit 1 |
101 | | - echo "exit 1" >> ./run-multimodal.sh |
102 | | - echo "::endgroup::" |
103 | | - |
104 | | - echo "::group::Run multimodal" |
105 | | - echo "*******************************************" |
106 | | - cat ./run-multimodal.sh |
107 | | - echo "*******************************************" |
108 | | - . ./run-multimodal.sh |
109 | | - echo "::endgroup::" |
110 | | -fi |
111 | | - |
112 | | -if [ "$1" == "native" ]; then |
113 | | - |
114 | | - echo "::group::Create script to run native-execution" |
115 | | - python3 torchchat/utils/scripts/updown.py --file docs/native-execution.md > ./run-native.sh |
116 | | - # for good measure, if something happened to updown processor, |
117 | | - # and it did not error out, fail with an exit 1 |
118 | | - echo "exit 1" >> ./run-native.sh |
119 | | - echo "::endgroup::" |
120 | | - |
121 | | - echo "::group::Run native-execution" |
122 | | - echo "*******************************************" |
123 | | - cat ./run-native.sh |
124 | | - echo "*******************************************" |
125 | | - . ./run-native.sh |
126 | | - echo "::endgroup::" |
127 | | -fi |
128 | | - |
129 | | -if [ "$1" == "distributed" ]; then |
130 | | - |
131 | | - echo "::group::Create script to run distributed" |
132 | | - python3 torchchat/utils/scripts/updown.py --file docs/distributed.md --replace 'llama3.1:stories110M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-distributed.sh |
133 | | - python3 torchchat/utils/scripts/updown.py --file docs/distributed.md --suppress huggingface-cli,HF_TOKEN > ./run-distributed.sh |
134 | | - # for good measure, if something happened to updown processor, |
135 | | - # and it did not error out, fail with an exit 1 |
136 | | - echo "exit 1" >> ./run-distributed.sh |
137 | | - echo "::endgroup::" |
138 | | - |
139 | | - echo "::group::Run distributed" |
140 | | - echo "*******************************************" |
141 | | - cat ./run-distributed.sh |
142 | | - echo "*******************************************" |
143 | | - . ./run-distributed.sh |
144 | | - echo "::endgroup::" |
145 | | -fi |
| 9 | +# Pre-initialize variables |
| 10 | +filepath="" |
| 11 | +parameters="--replace 'llama3:stories15M,-l3:-l2,mobile.json:mobile-32.json,cuda.json:cuda-32.json' --suppress huggingface-cli,HF_TOKEN" |
| 12 | +script_name="./run-${1}.sh" # Dynamically initialize script name |
| 13 | + |
| 14 | +# Use a case statement to handle the $1 argument |
| 15 | +case "$1" in |
| 16 | + "readme") |
| 17 | + filepath="README.md" |
| 18 | + ;; |
| 19 | + "quantization") |
| 20 | + filepath="docs/quantization.md" |
| 21 | + ;; |
| 22 | + "gguf") |
| 23 | + filepath="docs/GGUF.md" |
| 24 | + ;; |
| 25 | + "advanced") |
| 26 | + filepath="docs/ADVANCED-USERS.md" |
| 27 | + ;; |
| 28 | + "evaluation") |
| 29 | + filepath="torchchat/utils/docs/evaluation.md" |
| 30 | + ;; |
| 31 | + "multimodal") |
| 32 | + filepath="docs/multimodal.md" |
| 33 | + parameters="" # Clear parameters |
| 34 | + ;; |
| 35 | + "native") |
| 36 | + filepath="docs/native-execution.md" |
| 37 | + parameters="" # Clear parameters |
| 38 | + ;; |
| 39 | + "distributed") |
| 40 | + filepath="docs/distributed.md" |
| 41 | + parameters="--replace 'llama3.1:stories110M,-l3:-l2' --suppress huggingface-cli,HF_TOKEN" # Use stories110M to avoid need for authentication |
| 42 | + ;; |
| 43 | + "local") |
| 44 | + filepath="docs/local-model.md" |
| 45 | + parameters="" # Clear parameters |
| 46 | + ;; |
| 47 | + |
| 48 | + *) |
| 49 | + echo "Unknown option: $1" |
| 50 | + exit 1 |
| 51 | + ;; |
| 52 | +esac |
| 53 | + |
| 54 | +# Generate the script |
| 55 | +echo "::group::Create script to run $1" |
| 56 | +python3 torchchat/utils/scripts/updown.py --file "$filepath" $parameters > "$script_name" |
| 57 | +# if something happened to updown processor, and it did not error out, fail with an exit 1 |
| 58 | +echo "exit 1" >> "$script_name" |
| 59 | +echo "::endgroup::" |
| 60 | + |
| 61 | +# Run the script |
| 62 | +echo "::group::Run $1" |
| 63 | +echo "*******************************************" |
| 64 | +cat "$script_name" |
| 65 | +echo "*******************************************" |
| 66 | +. "$script_name" |
| 67 | +echo "::endgroup::" |
0 commit comments