-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mengni Wang <[email protected]>
- Loading branch information
1 parent
f0d51c2
commit 7fbcf54
Showing
23 changed files
with
542 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
...t/nlp/huggingface_model/text_generation/llama/quantization/ptq_static/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Step-by-Step | ||
============ | ||
|
||
This example confirms llama's accuracy and speed based on [lambada](https://huggingface.co/datasets/lambada). | ||
|
||
# Prerequisite | ||
|
||
## 1. Environment | ||
```shell | ||
pip install neural-compressor | ||
pip install -r requirements.txt | ||
``` | ||
> Note: Validated ONNX Runtime [Version](/docs/source/installation_guide.md#validated-software-environment). | ||
## 2. Prepare Model | ||
|
||
```bash | ||
optimum-cli export onnx --model decapoda-research/llama-7b-hf --task text-generation-with-past ./llama_7b | ||
optimum-cli export onnx --model decapoda-research/llama-13b-hf --task text-generation-with-past ./llama_13b | ||
``` | ||
|
||
# Run | ||
|
||
## 1. Quantization | ||
|
||
```bash | ||
bash run_quant.sh --input_model=/path/to/model \ # folder path of onnx model | ||
--output_model=/path/to/model_tune \ # folder path to save onnx model | ||
--batch_size=batch_size # optional \ | ||
--dataset NeelNanda/pile-10k \ | ||
--alpha 0.6 \ # 0.6 for llama-7b, 0.8 for llama-13b | ||
--tokenizer=decapoda-research/llama-7b-hf \ # model name or folder path containing all relevant files for model's tokenizer | ||
--quant_format="QOperator" # or QDQ, optional | ||
``` | ||
|
||
## 2. Benchmark | ||
|
||
Accuracy: | ||
|
||
```bash | ||
bash run_benchmark.sh --input_model=path/to/model \ # folder path of onnx model | ||
--batch_size=batch_size \ # optional | ||
--mode=accuracy \ | ||
--tokenizer=decapoda-research/llama-7b-hf \ # model name or folder path containing all relevant files for model's tokenizer | ||
--tasks=lambada_openai | ||
``` | ||
|
||
Performance: | ||
```bash | ||
numactl -m 0 -C 0-3 bash run_benchmark.sh --input_model=path/to/model \ # folder path of onnx model | ||
--mode=performance \ | ||
--batch_size=batch_size # optional \ | ||
--tokenizer=decapoda-research/llama-7b-hf \ # model name or folder path containing all relevant files for model's tokenizer | ||
--intra_op_num_threads=4 | ||
``` |
Oops, something went wrong.