Skip to content

Commit 6d5a1eb

Browse files
authored
Enhance document and scripts (#92)
1. fix instructions in readme 2. allow users to specify their own MLC_LLM_HOME path
1 parent 9d048b3 commit 6d5a1eb

File tree

8 files changed

+44
-66
lines changed

8 files changed

+44
-66
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,23 @@ Besides supporting WebGPU, this project also provides the harness for other kind
5555
Currently we support LLaMA and Vicuna.
5656

5757
1. Get the original LLaMA weights in the huggingface format by following the instructions [here](https://huggingface.co/docs/transformers/main/model_doc/llama).
58-
2. Use instructions [here](https://github.com/lm-sys/FastChat#vicuna-weights) to get vicuna weights.
59-
3. Create a soft link to the model path under dist/models
58+
2. Use instructions [here](https://github.com/lm-sys/FastChat#vicuna-weights) to get vicuna weights
59+
3. Create a soft link to the model path under mlc-llm/dist/models.
6060
```shell
61-
mkdir -p dist/models
62-
ln -s your_model_path dist/models/model_name
61+
mkdir -p mlc-llm/dist/models
62+
ln -s your_model_path mlc-llm/dist/models/model_name
6363
6464
# For example:
65-
# ln -s path/to/vicuna-7b-v1 dist/models/vicuna-7b-v1
65+
# ln -s path/to/vicuna-7b-v1 mlc-llm/dist/models/vicuna-7b-v1
6666
```
67-
* Optimize and build model to webgpu backend and export the executable to disk in the WebAssembly file format.
68-
6967

68+
If you want to use your own mlc-llm branch, set `MLC_LLM_HOME` to that path and link weights under `$MLC_LLM_HOME/dist/models/model_name`
69+
* Optimize and build model to webgpu backend and export the executable to disk in the WebAssembly file format.
7070
```shell
71-
python3 build.py --target webgpu
72-
```
73-
By default `build.py` takes `vicuna-7b-v1` as model name. You can also specify model name as
74-
```shell
75-
python3 build.py --target webgpu --model llama-7b
71+
./build.sh --quantization q4f32_0
7672
```
73+
By default `build.sh` takes `vicuna-7b-v1` as model name
74+
7775
Note: build.py can be run on MacOS with 32GB memory and other OS with at least 50GB CPU memory. We are currently optimizing the memory usage to enable more people to try out locally.
7876

7977
4. Deploy the model on web with WebGPU runtime

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MLC_LLM_HOME_SET="${MLC_LLM_HOME:-}"
2+
3+
if [ -z ${MLC_LLM_HOME_SET} ]; then
4+
export MLC_LLM_HOME="${MLC_LLM_HOME:-mlc-llm}"
5+
fi
6+
7+
8+
cd ${MLC_LLM_HOME}
9+
python build.py --target webgpu ${@}
10+
cd -

mlc-llm

Submodule mlc-llm updated 1 file

scripts/build_site.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ cp web/llm_chat.html site/_includes
1515
cp web/llm_chat.js site/dist/
1616
cp web/llm_chat.css site/dist/
1717

18-
cp mlc-llm/dist/tvmjs_runtime.wasi.js site/dist
19-
cp mlc-llm/dist/tvmjs.bundle.js site/dist
20-
cp -r mlc-llm/dist/sentencepiece site/dist
18+
cp $MLC_LLM_HOME/dist/tvmjs_runtime.wasi.js site/dist
19+
cp $MLC_LLM_HOME/dist/tvmjs.bundle.js site/dist
20+
cp -r $MLC_LLM_HOME/dist/sentencepiece site/dist
2121

22-
if [ -d "mlc-llm/dist/vicuna-v1-7b-q4f32_0/params" ]; then
22+
if [ -d "$MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/params" ]; then
2323
mkdir -p site/dist/vicuna-v1-7b-q4f32_0
24-
cp -rf mlc-llm/dist/vicuna-v1-7b-q4f32_0/tokenizer.model site/dist/vicuna-v1-7b-q4f32_0/
25-
cp -rf mlc-llm/dist/vicuna-v1-7b-q4f32_0/vicuna-v1-7b-q4f32_0-webgpu.wasm site/dist/vicuna-v1-7b-q4f32_0/
24+
cp -rf $MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/tokenizer.model site/dist/vicuna-v1-7b-q4f32_0/
25+
cp -rf $MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/vicuna-v1-7b-q4f32_0-webgpu.wasm site/dist/vicuna-v1-7b-q4f32_0/
2626
fi
27-
if [ -d "mlc-llm/dist/wizardlm-7b/params" ]; then
27+
if [ -d "$MLC_LLM_HOME/dist/wizardlm-7b/params" ]; then
2828
mkdir -p site/dist/wizardlm-7b
29-
cp -rf mlc-llm/dist/wizardlm-7b/tokenizer.model site/dist/wizardlm-7b/
30-
cp -rf mlc-llm/dist/wizardlm-7b/wizardlm-7b-webgpu.wasm site/dist/wizardlm-7b/
29+
cp -rf $MLC_LLM_HOME/dist/wizardlm-7b/tokenizer.model site/dist/wizardlm-7b/
30+
cp -rf $MLC_LLM_HOME/dist/wizardlm-7b/wizardlm-7b-webgpu.wasm site/dist/wizardlm-7b/
3131
fi
3232

3333
cd site && jekyll b && cd ..

scripts/local_deploy_site.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4+
MLC_LLM_HOME_SET="${MLC_LLM_HOME:-}"
5+
6+
if [ -z ${MLC_LLM_HOME_SET} ]; then
7+
export MLC_LLM_HOME="${MLC_LLM_HOME:-mlc-llm}"
8+
fi
9+
410
scripts/build_site.sh web/global_config.json
511

612
echo "symlink parameter location to site.."
713

8-
if [ -d "mlc-llm/dist/vicuna-v1-7b-q4f32_0/params" ]; then
14+
if [ -d "$MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/params" ]; then
915
rm -rf site/_site/dist/vicuna-v1-7b-q4f32_0-params
10-
ln -s `pwd`/mlc-llm/dist/vicuna-v1-7b-q4f32_0/params site/_site/dist/vicuna-v1-7b-q4f32_0/params
16+
ln -s $MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/params site/_site/dist/vicuna-v1-7b-q4f32_0/params
1117
ls site/_site/dist/vicuna-v1-7b-q4f32_0
1218
fi
13-
if [ -d "mlc-llm/dist/wizardlm-7b/params" ]; then
19+
if [ -d "$MLC_LLM_HOME/dist/wizardlm-7b/params" ]; then
1420
rm -rf site/_site/dist/wizardlm-7b-params
15-
ln -s `pwd`/mlc-llm/dist/wizardlm-7b/params site/_site/dist/wizardlm-7b-params
21+
ln -s $MLC_LLM_HOME/dist/wizardlm-7b/params site/_site/dist/wizardlm-7b-params
1622
fi
1723

1824

scripts/prep_deps.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ cd ${TVM_HOME}/web && make && npm install && npm run bundle && cd -
2222
git submodule update --init --recursive
2323
cd ${SENTENCEPIECE_JS_HOME} && npm install && npm run build && cd -
2424
git submodule update --init --recursive
25-
rm -rf mlc-llm/dist/sentencepiece
26-
cp -r ${SENTENCEPIECE_JS_HOME}/dist mlc-llm/dist/sentencepiece
25+
rm -rf dist/sentencepiece
26+
cp -r ${SENTENCEPIECE_JS_HOME}/dist dist/sentencepiece
2727

2828
echo "Exporting tvmjs runtime dist files"
29-
python3 -c "from tvm.contrib import tvmjs; tvmjs.export_runtime(\"mlc-llm/dist\")"
29+
python -c "from tvm.contrib import tvmjs; tvmjs.export_runtime(\"dist\")"

scripts/rpc_debug_deploy.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

web/llm_chat.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<form>
2626
<select id="model-name">
2727
<option selected="selected">vicuna-v1-7b-q4f32_0</option>
28-
<option >dolly-v1-3b-q4f32_0</option>
28+
<!-- <option >dolly-v1-3b-q4f32_0</option> -->
2929
</select>
3030
</form>
3131

0 commit comments

Comments
 (0)