|
| 1 | +# Building runner-aoti and runner-et |
| 2 | +Building the runners is straightforward and is covered in the next sections. |
| 3 | + |
| 4 | +## Building and running runner-aoti |
| 5 | +To build runner-aoti, run the following commands *from the torchchat root directory* |
| 6 | + |
| 7 | +``` |
| 8 | +cmake -S ./runner-aoti -B ./runner-aoti/cmake-out -G Ninja -DCMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'` |
| 9 | +cmake --build ./runner-aoti/cmake-out |
| 10 | +``` |
| 11 | + |
| 12 | +After running these, the runner-aoti binary is located at ./runner-aoti/cmake-out/run. |
| 13 | + |
| 14 | +Let us try using it with an example. |
| 15 | +We first download stories15M and export it to AOTI. |
| 16 | + |
| 17 | +``` |
| 18 | +python torchchat.py download stories15M |
| 19 | +python torchchat.py export --output-dso-path ./model.dso |
| 20 | +``` |
| 21 | + |
| 22 | +We also need a tokenizer.bin file for the stories15M model: |
| 23 | + |
| 24 | +``` |
| 25 | +wget ./tokenizer.bin https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin |
| 26 | +``` |
| 27 | + |
| 28 | +We can now execute the runner with: |
| 29 | + |
| 30 | +``` |
| 31 | +./runner-aoti/cmake-out/run ./model.dso -z ./tokenizer.bin -i "Once upon a time" |
| 32 | +``` |
| 33 | + |
| 34 | +## Building and running runner-et |
| 35 | +Before building runner-et, you must first set-up ExecuTorch by following [Set-up Executorch](executorch_setup.md). |
| 36 | + |
| 37 | + |
| 38 | +To build runner-et, run the following commands *from the torchchat root directory* |
| 39 | + |
| 40 | +``` |
| 41 | +export TORCHCHAT_ROOT=${PWD} |
| 42 | +cmake -S ./runner-et -B ./runner-et/cmake-out -G Ninja |
| 43 | +cmake --build ./runner-et/cmake-out |
| 44 | +``` |
| 45 | + |
| 46 | +After running these, the runner-et binary is located at ./runner-et/cmake-out/runner-et. |
| 47 | + |
| 48 | +Let us try using it with an example. |
| 49 | +We first download stories15M and export it to ExecuTorch. |
| 50 | + |
| 51 | +``` |
| 52 | +python torchchat.py download stories15M |
| 53 | +python torchchat.py export stories15M --output-pte-path ./model.pte |
| 54 | +``` |
| 55 | + |
| 56 | +We also need a tokenizer.bin file for the stories15M model: |
| 57 | + |
| 58 | +``` |
| 59 | +wget ./tokenizer.bin https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin |
| 60 | +``` |
| 61 | + |
| 62 | +We can now execute the runner with: |
| 63 | + |
| 64 | +``` |
| 65 | +./runner-et/cmake-out/runner_et ./model.pte -z ./tokenizer.bin -i "Once upon a time" |
| 66 | +``` |
0 commit comments