|  | 
| 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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./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 |  | -        bash -x ./run-distributed.sh | 
| 144 |  | -        echo "::endgroup::" | 
| 145 |  | -fi | 
|  | 9 | +# Pre-initialize variables | 
|  | 10 | +filepath="" | 
|  | 11 | +# cuda supports padding, so no need to replace quantization for now.   | 
|  | 12 | +# otherwise add: 'cuda.json:cuda-32.json' to replace rules | 
|  | 13 | +parameters="--replace llama3:stories15M,-l3:-l2,mobile.json:mobile-32.json --suppress huggingface-cli,HF_TOKEN" | 
|  | 14 | +script_name="./run-${1}.sh"  # Dynamically initialize script name | 
|  | 15 | + | 
|  | 16 | +# Use a case statement to handle the $1 argument | 
|  | 17 | +case "$1" in | 
|  | 18 | +  "readme") | 
|  | 19 | +    filepath="README.md" | 
|  | 20 | +    parameters="--replace llama3.1:stories15M,-l3:-l2,mobile.json:mobile-32.json --suppress huggingface-cli,HF_TOKEN" | 
|  | 21 | +    ;; | 
|  | 22 | +  "quantization") | 
|  | 23 | +    filepath="docs/quantization.md" | 
|  | 24 | +    ;; | 
|  | 25 | +  "gguf") | 
|  | 26 | +    filepath="docs/GGUF.md" | 
|  | 27 | +    ;; | 
|  | 28 | +  "advanced") | 
|  | 29 | +    filepath="docs/ADVANCED-USERS.md" | 
|  | 30 | +    ;; | 
|  | 31 | +  "evaluation") | 
|  | 32 | +    filepath="torchchat/utils/docs/evaluation.md" | 
|  | 33 | +    ;; | 
|  | 34 | +  "multimodal") | 
|  | 35 | +    filepath="docs/multimodal.md" | 
|  | 36 | +    parameters=""  # Clear parameters | 
|  | 37 | +    ;; | 
|  | 38 | +  "native") | 
|  | 39 | +    filepath="docs/native-execution.md" | 
|  | 40 | +    parameters=""  # Clear parameters | 
|  | 41 | +    ;; | 
|  | 42 | +  "distributed") | 
|  | 43 | +    filepath="docs/distributed.md" | 
|  | 44 | +    parameters="--replace llama3.1:stories110M,-l3:-l2 --suppress huggingface-cli,HF_TOKEN"  # Use stories110M to avoid need for authentication | 
|  | 45 | +    ;; | 
|  | 46 | +  "local") | 
|  | 47 | +    filepath="docs/local-model.md" | 
|  | 48 | +    parameters=""  # Clear parameters | 
|  | 49 | +    ;; | 
|  | 50 | + | 
|  | 51 | +  *) | 
|  | 52 | +    echo "Unknown option: $1" | 
|  | 53 | +    exit 1 | 
|  | 54 | +    ;; | 
|  | 55 | +esac | 
|  | 56 | + | 
|  | 57 | +# Generate the script | 
|  | 58 | +echo "::group::Create script to run $1" | 
|  | 59 | +python3 torchchat/utils/scripts/updown.py --file "$filepath" $parameters > "$script_name" | 
|  | 60 | +# if something happened to updown processor, and it did not error out, fail with an exit 1 | 
|  | 61 | +echo "exit 1" >> "$script_name" | 
|  | 62 | +echo "::endgroup::" | 
|  | 63 | + | 
|  | 64 | +# Run the script | 
|  | 65 | +echo "::group::Run $1" | 
|  | 66 | +echo "*******************************************" | 
|  | 67 | +cat "$script_name" | 
|  | 68 | +echo "*******************************************" | 
|  | 69 | +set -x | 
|  | 70 | +. "$script_name" | 
|  | 71 | +echo "::endgroup::" | 
0 commit comments