|
| 1 | +name: Run compile tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-cuda: |
| 12 | + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main |
| 13 | + with: |
| 14 | + runner: linux.g5.4xlarge.nvidia.gpu |
| 15 | + gpu-arch-type: cuda |
| 16 | + gpu-arch-version: "12.1" |
| 17 | + script: | |
| 18 | + echo "::group::Print machine info" |
| 19 | + uname -a |
| 20 | + if [ $(uname -s) == Darwin ]; then |
| 21 | + sysctl machdep.cpu.brand_string |
| 22 | + sysctl machdep.cpu.core_count |
| 23 | + fi |
| 24 | + echo "::endgroup::" |
| 25 | +
|
| 26 | + echo "::group::Download checkpoints" |
| 27 | + # Install requirements |
| 28 | + pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121 |
| 29 | + pip install -r requirements.txt |
| 30 | + echo "::endgroup::" |
| 31 | +
|
| 32 | + echo "::group::Download checkpoints" |
| 33 | + mkdir -p checkpoints/stories15M |
| 34 | + pushd checkpoints/stories15M |
| 35 | + wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.pt |
| 36 | + wget https://github.com/karpathy/llama2.c/raw/master/tokenizer.model |
| 37 | + popd |
| 38 | + echo "::endgroup::" |
| 39 | +
|
| 40 | + echo "::group::Run inference" |
| 41 | + export MODEL_PATH=checkpoints/stories15M/stories15M.pt |
| 42 | + export MODEL_NAME=stories15M |
| 43 | + export MODEL_DIR=/tmp |
| 44 | +
|
| 45 | + for DTYPE in bfloat16 float16 float32; do |
| 46 | +
|
| 47 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 48 | + cat ./output_eager |
| 49 | + python generate.py --dtype ${DTYPE} --device cuda --compile --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 50 | + cat ./output_compiled |
| 51 | + python export.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 52 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 53 | + cat ./output_aoti |
| 54 | +
|
| 55 | + echo "******************************************" |
| 56 | + echo "******* Emb: channel-wise quantized ******" |
| 57 | + echo "******************************************" |
| 58 | + python generate.py --dtype ${DTYPE} --device cuda --quant '{"embedding" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 59 | + cat ./output_eager |
| 60 | + python generate.py --dtype ${DTYPE} --device cuda --compile --quant '{"embedding" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 61 | + cat ./output_compiled |
| 62 | + python export.py --dtype ${DTYPE} --device cuda --quant '{"embedding" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 63 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 64 | + cat ./output_aoti |
| 65 | +
|
| 66 | + echo "******************************************" |
| 67 | + echo "******** Emb: group-wise quantized *******" |
| 68 | + echo "******************************************" |
| 69 | + python generate.py --dtype ${DTYPE} --device cuda --quant '{"embedding" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 70 | + cat ./output_eager |
| 71 | + python generate.py --dtype ${DTYPE} --device cuda --compile --quant '{" embedding" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 72 | + cat ./output_compiled |
| 73 | + python export.py --dtype ${DTYPE} --device cuda --quant '{"embedding" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 74 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 75 | + cat ./output_aoti |
| 76 | +
|
| 77 | + echo "******************************************" |
| 78 | + echo "******* INT8 channel-wise quantized ******" |
| 79 | + echo "******************************************" |
| 80 | + python generate.py --dtype ${DTYPE} --device cuda --quant '{"linear:int8" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 81 | + cat ./output_eager |
| 82 | + python generate.py --dtype ${DTYPE} --device cuda --compile --quant '{" linear:int8" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 83 | + cat ./output_compiled |
| 84 | + python export.py --dtype ${DTYPE} --device cuda --quant '{"linear:int8" : {"bitwidth": 8, "groupsize": 0}}' --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 85 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 86 | + cat ./output_aoti |
| 87 | +
|
| 88 | + echo "******************************************" |
| 89 | + echo "******** INT8 group-wise quantized *******" |
| 90 | + echo "******************************************" |
| 91 | + python generate.py --dtype ${DTYPE} --device cuda --quant '{"linear:int8" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 92 | + cat ./output_eager |
| 93 | + python generate.py --dtype ${DTYPE} --device cuda --compile --quant '{"linear:int8" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 94 | + cat ./output_compiled |
| 95 | + python export.py --dtype ${DTYPE} --device cuda --quant '{"linear:int8" : {"bitwidth": 8, "groupsize": 8}}' --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 96 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 97 | + cat ./output_aoti |
| 98 | +
|
| 99 | + echo "******************************************" |
| 100 | + echo "******** INT4 group-wise quantized *******" |
| 101 | + echo "******************************************" |
| 102 | + python generate.py --dtype ${DTYPE} --device cuda --quant '{"linear:int4" : {"groupsize": 32}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_eager |
| 103 | + cat ./output_eager |
| 104 | + python generate.py --dtype ${DTYPE} --device cuda --compile --quant '{"linear:int4" : {"groupsize": 32}}' --checkpoint-path ${MODEL_PATH} --temperature 0 > ./output_compiled |
| 105 | + cat ./output_compiled |
| 106 | + python export.py --dtype ${DTYPE} --device cuda --quant '{"linear:int4" : {"groupsize": 32}}' --checkpoint-path ${MODEL_PATH} --output-dso-path ${MODEL_DIR}/${MODEL_NAME}.so |
| 107 | + python generate.py --dtype ${DTYPE} --device cuda --checkpoint-path ${MODEL_PATH} --temperature 0 --dso-path ${MODEL_DIR}/${MODEL_NAME}.so > ./output_aoti |
| 108 | + cat ./output_aoti |
| 109 | +
|
| 110 | + done |
| 111 | +
|
| 112 | + echo "tests complete" |
| 113 | + echo "******************************************" |
| 114 | + echo "::endgroup::" |
| 115 | +
|
0 commit comments