add runner-et.cpp CI #48
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
name: Compile main | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
run-tinystories: | |
strategy: | |
matrix: | |
runner: [32-core-ubuntu] | |
runs-on: ${{matrix.runner}} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Print machine info | |
run: | | |
uname -a | |
if [ $(uname -s) == Darwin ]; then | |
sysctl machdep.cpu.brand_string | |
sysctl machdep.cpu.core_count | |
fi | |
- name: Install requirements | |
run: | | |
echo "Intalling pip packages" | |
pip install wheel | |
pip install cmake | |
pip install ninja | |
pip install zstd | |
pip install -r requirements.txt | |
echo "Install executorch: cloning" | |
mkdir build | |
cd build | |
git clone https://github.com/pytorch/executorch.git | |
cd executorch | |
echo "Install executorch: submodule update" | |
git submodule sync | |
git submodule update --init | |
echo "Applying fixes" | |
cp ../../scripts/fixes_et/module.h ${PWD}/extension/module/module.h | |
cp ../../scripts/fixes_et/module.cpp ${PWD}/extension/module/module.cpp | |
echo "Install executorch: running pip install" | |
./install_requirements.sh --pybind xnnpack | |
echo "Install executorch: building C++ libraries" | |
mkdir cmake-out | |
cmake -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON -DEXECUTORCH_BUILD_XNNPACK=ON -S . -B cmake-out -G Ninja | |
cmake --build cmake-out | |
export ET_DIR="${PWD}/build/executorch" | |
echo "executorch directory: ${ET_DIR}" | |
cd ../.. | |
echo "current directory: ${PWD}" | |
echo "Building runner-et" | |
mkdir -p runner-et/cmake-out | |
cmake -DET_DIR:STRING=$ET_DIR -DCMAKE_BUILD_TYPE=Release -S runner-et -B runner-et/cmake-out | |
cmake --build runner-et/cmake-out | |
- name: Download checkpoints | |
run: | | |
mkdir -p checkpoints/stories15M | |
pushd checkpoints/stories15M | |
wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.pt | |
wget https://github.com/karpathy/llama2.c/raw/master/tokenizer.model | |
wget https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin | |
popd | |
- name: Run inference | |
run: | | |
export CHECKPOINT_PATH=${PWD}/checkpoints/stories15M | |
export MODEL_NAME=stories15M | |
python generate.py --checkpoint-path ${CHECKPOINT_PATH}/stories15M.pt --temperature 0 --prompt "Once upon a time" > ${PWD}/output_eager | |
cat ${PWD}/output_eager | |
python export.py --checkpoint-path ${CHECKPOINT_PATH}/stories15M.pt --output-pte-path ${PWD}/stories15M.pte | |
python generate.py --checkpoint-path ${CHECKPOINT_PATH}/stories15M.pt --temperature 0 --prompt "Once upon a time" --pte-path ${PWD}/stories15M.pte > ${PWD}/output_et | |
cat ${PWD}/output_et | |
./runner-et/cmake-out/runner_et run ${PWD}/stories15M.pte -z ${CHECKPOINT_PATH}/tokenizer.bin -i "Once upon a time" > ${PWD}/output_runner_et | |
echo "eager out:" | |
cat ${PWD}/output_eager | |
echo "et out:" | |
cat ${PWD}/output_et | |
echo "runner-et out:" | |
cat ${PWD}/output_runner_et | |
echo "Tests complete." |