Skip to content

Commit ee280db

Browse files
metascroymalfet
authored andcommitted
rename executable in runner-et to run to align with AOTI (#382)
* rename executable in runner-et to run to align with AOTI * add missing quote * download tokenizer.bin * add -O
1 parent 4ff89d1 commit ee280db

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

.github/workflows/pull.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -734,28 +734,24 @@ jobs:
734734
python3 -c 'import torch;print(f"torch: {torch.__version__, torch.version.git_version}")'
735735
python3 -c 'import torchvision;print(f"torchvision: {torchvision.__version__, torchvision.version.git_version}")'
736736
python3 -c 'import torchaudio;print(f"torchaudio: {torchaudio.__version__, torchaudio.version.git_version}")'
737-
cmake -S ./runner-et -B et-build/cmake-out -G Ninja
738-
cmake --build ./et-build/cmake-out
737+
cmake -S ./runner-et -B ./runner-et/cmake-out -G Ninja
738+
cmake --build ./runner-et/cmake-out
739739
- name: Download checkpoints
740740
run: |
741-
mkdir -p checkpoints/stories15M
742-
pushd checkpoints/stories15M
743-
wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.pt
744-
wget https://github.com/karpathy/llama2.c/raw/master/tokenizer.model
745-
wget https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin
746-
popd
741+
747742
- name: Run inference
748743
run: |
749-
export MODEL_DIR=${PWD}/checkpoints/stories15M
750-
export PROMPT="Once upon a time in a land far away"
744+
python torchchat.py download stories15M
745+
wget -O ./tokenizer.bin https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin
751746
752-
python torchchat.py generate --checkpoint-path ${MODEL_DIR}/stories15M.pt --temperature 0 --prompt "${PROMPT}" > ${PWD}/output_eager
753-
cat ${PWD}/output_eager
747+
export PRMT="Once upon a time in a land far away"
754748
755-
python torchchat.py export --checkpoint-path ${MODEL_DIR}/stories15M.pt --output-pte-path ${PWD}/stories15M.pte
749+
python torchchat.py generate stories15M --temperature 0 --prompt "${PRMT}" > ./output_eager
750+
cat ./output_eager
756751
757-
./et-build/cmake-out/runner_et ${PWD}/stories15M.pte -z ${MODEL_DIR}/tokenizer.bin -i "${PROMPT}" > ${PWD}/output_et
758-
cat ${PWD}/output_et
752+
python torchchat.py export stories15M --output-pte-path ./model.pte
753+
./runner-et/cmake-out/run ./model.pte -z ./tokenizer.bin -t 0 -i "${PRMT}" > ./output_et
754+
cat ./output_et
759755
760756
echo "Tests complete."
761757
runner-aoti:

docs/runner_build.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Building runner-aoti and runner-et
2-
Building the runners is straightforward and is covered in the next sections.
2+
Building the runners is straightforward and is covered in the next sections. We will showcase the runners using stories15M.
3+
4+
The runners accept the following CLI arguments:
5+
6+
```
7+
Options:
8+
-t <float> temperature in [0,inf], default 1.0
9+
-p <float> p value in top-p (nucleus) sampling in [0,1] default 0.9
10+
-s <int> random seed, default time(NULL)
11+
-n <int> number of steps to run for, default 256. 0 = max_seq_len
12+
-i <string> input prompt
13+
-z <string> optional path to custom tokenizer
14+
-m <string> mode: generate|chat, default: generate
15+
-y <string> (optional) system prompt in chat mode
16+
```
317

418
## Building and running runner-aoti
519
To build runner-aoti, run the following commands *from the torchchat root directory*
@@ -16,19 +30,14 @@ We first download stories15M and export it to AOTI.
1630

1731
```
1832
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
33+
python torchchat.py export stories15M --output-dso-path ./model.so
2634
```
2735

2836
We can now execute the runner with:
2937

3038
```
31-
./runner-aoti/cmake-out/run ./model.dso -z ./tokenizer.bin -i "Once upon a time"
39+
wget -O ./tokenizer.bin https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin
40+
./runner-aoti/cmake-out/run ./model.so -z ./tokenizer.bin -i "Once upon a time"
3241
```
3342

3443
## Building and running runner-et
@@ -43,7 +52,7 @@ cmake -S ./runner-et -B ./runner-et/cmake-out -G Ninja
4352
cmake --build ./runner-et/cmake-out
4453
```
4554

46-
After running these, the runner-et binary is located at ./runner-et/cmake-out/runner-et.
55+
After running these, the runner-et binary is located at ./runner-et/cmake-out/run.
4756

4857
Let us try using it with an example.
4958
We first download stories15M and export it to ExecuTorch.
@@ -53,14 +62,9 @@ python torchchat.py download stories15M
5362
python torchchat.py export stories15M --output-pte-path ./model.pte
5463
```
5564

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-
6265
We can now execute the runner with:
6366

6467
```
65-
./runner-et/cmake-out/runner_et ./model.pte -z ./tokenizer.bin -i "Once upon a time"
68+
wget -O ./tokenizer.bin https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin
69+
./runner-et/cmake-out/run ./model.pte -z ./tokenizer.bin -i "Once upon a time"
6670
```

runner-et/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ set(_common_include_directories ${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/src)
3434
cmake_print_variables(_common_include_directories)
3535

3636
target_include_directories(executorch INTERFACE ${_common_include_directories}) # Ideally ExecuTorch installation process would do this
37-
add_executable(runner_et run.cpp)
37+
add_executable(run run.cpp)
3838

3939
# Link ET runtime + extensions
4040
target_link_libraries(
41-
runner_et PRIVATE
41+
run PRIVATE
4242
executorch
4343
extension_module
4444
${TORCHCHAT_ROOT}/et-build/src/executorch/${CMAKE_OUT_DIR}/lib/libextension_data_loader.a # This one gets installed in build directory by ExecuTorch
@@ -59,4 +59,4 @@ target_link_options_shared_lib(XNNPACK)
5959
target_link_options_shared_lib(pthreadpool)
6060
target_link_options_shared_lib(cpuinfo)
6161
target_link_options_shared_lib(executorch)
62-
target_link_libraries(runner_et PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,${TORCHCHAT_ROOT}/et-build/src/executorch/${CMAKE_OUT_DIR}/examples/models/llama2/custom_ops/libcustom_ops.a>")
62+
target_link_libraries(run PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,${TORCHCHAT_ROOT}/et-build/src/executorch/${CMAKE_OUT_DIR}/examples/models/llama2/custom_ops/libcustom_ops.a>")

0 commit comments

Comments
 (0)