-
Notifications
You must be signed in to change notification settings - Fork 281
add examples for GPTJ #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+894
−0
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b7100d
add examples for GPTJ and GPTneo
changwangss 8c57ebe
remove neo and timeout
changwangss 9e7dd14
update benchmark
changwangss 323deef
add benchmark info
changwangss ff1cdaf
remove exit
changwangss 14d59df
update benchmark code
changwangss adf00b9
add example for README
changwangss 9f7cd10
fix pyspelling
changwangss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -696,6 +696,7 @@ Goyal | |
| gpg | ||
| GPG | ||
| gpt | ||
| GPTJ | ||
| gpu | ||
| gpus | ||
| GPUs | ||
|
|
||
This file contains hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
...h/nlp/huggingface_models/language-modeling/quantization/ptq_static/fx/README.md
This file contains hidden or 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,38 @@ | ||
| Step-by-Step | ||
| ============ | ||
|
|
||
| This document is used to list steps of reproducing PyTorch BERT tuning zoo result. | ||
|
|
||
| # Prerequisite | ||
|
|
||
| ## 1. Installation | ||
|
|
||
| The dependent packages are all in requirements, please install as following. | ||
|
|
||
| ``` | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| ## 2. Run | ||
|
|
||
| If the automatic download from modelhub fails, you can download [EleutherAI/gpt-j-6B](https://huggingface.co/EleutherAI/gpt-j-6B?text=My+name+is+Clara+and+I+am) offline. | ||
|
|
||
| ```shell | ||
|
|
||
| python run_clm.py \ | ||
| --model_name_or_path EleutherAI/gpt-j-6B \ | ||
| --dataset_name wikitext\ | ||
| --dataset_config_name wikitext-2-raw-v1 \ | ||
| --do_train \ | ||
| --do_eval \ | ||
| --tune \ | ||
| --output_dir /path/to/checkpoint/dir | ||
| ``` | ||
|
|
||
|
|
||
| ## 3. Command | ||
|
|
||
| ``` | ||
| bash run_tuning.sh --topology=gpt_j_wikitext | ||
| bash run_benchmark.sh --topology=gpt_j_wikitext --mode=performance --int8=true | ||
| ``` |
31 changes: 31 additions & 0 deletions
31
...les/pytorch/nlp/huggingface_models/language-modeling/quantization/ptq_static/fx/conf.yaml
This file contains hidden or 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,31 @@ | ||
| # | ||
| # Copyright (c) 2021 Intel Corporation | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| version: 1.0 | ||
|
|
||
| model: # mandatory. used to specify model specific information. | ||
| name: bert | ||
| framework: pytorch_fx # mandatory. possible values are tensorflow, mxnet, pytorch, pytorch_ipex, onnxrt_integerops and onnxrt_qlinearops. | ||
|
|
||
| quantization: # optional. tuning constraints on model-wise for advance user to reduce tuning space. | ||
| approach: post_training_static_quant | ||
|
|
||
| tuning: | ||
| accuracy_criterion: | ||
| relative: 0.5 # optional. default value is relative, other value is absolute. this example allows relative accuracy loss: 1%. | ||
| higher_is_better: False | ||
| exit_policy: | ||
| max_trials: 600 | ||
| random_seed: 9527 # optional. random seed for deterministic tuning. |
5 changes: 5 additions & 0 deletions
5
...orch/nlp/huggingface_models/language-modeling/quantization/ptq_static/fx/requirements.txt
This file contains hidden or 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,5 @@ | ||
| sentencepiece != 0.1.92 | ||
| protobuf | ||
| evaluate | ||
| datasets | ||
| transformers >= 4.22.0 | ||
91 changes: 91 additions & 0 deletions
91
...orch/nlp/huggingface_models/language-modeling/quantization/ptq_static/fx/run_benchmark.sh
This file contains hidden or 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,91 @@ | ||
| #!/bin/bash | ||
| set -x | ||
|
|
||
| function main { | ||
|
|
||
| init_params "$@" | ||
| run_benchmark | ||
|
|
||
| } | ||
|
|
||
| # init params | ||
| function init_params { | ||
| iters=100 | ||
| batch_size=16 | ||
| tuned_checkpoint=saved_results | ||
| max_eval_samples=`expr ${iters} \* ${batch_size}` | ||
| echo ${max_eval_samples} | ||
| for var in "$@" | ||
| do | ||
| case $var in | ||
| --topology=*) | ||
| topology=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| --dataset_location=*) | ||
| dataset_location=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| --input_model=*) | ||
| input_model=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| --mode=*) | ||
| mode=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| --batch_size=*) | ||
| batch_size=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| --iters=*) | ||
| iters=$(echo ${var} |cut -f2 -d=) | ||
| ;; | ||
| --int8=*) | ||
| int8=$(echo ${var} |cut -f2 -d=) | ||
| ;; | ||
| --config=*) | ||
| tuned_checkpoint=$(echo $var |cut -f2 -d=) | ||
| ;; | ||
| *) | ||
| echo "Error: No such parameter: ${var}" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| } | ||
|
|
||
|
|
||
| # run_benchmark | ||
| function run_benchmark { | ||
| extra_cmd='' | ||
|
|
||
| if [[ ${mode} == "accuracy" ]]; then | ||
| mode_cmd=" --accuracy_only " | ||
| elif [[ ${mode} == "benchmark" ]]; then | ||
| mode_cmd=" --benchmark " | ||
| extra_cmd=$extra_cmd" --max_eval_samples ${max_eval_samples}" | ||
| else | ||
| echo "Error: No such mode: ${mode}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "${topology}" = "gpt_j_wikitext" ]; then | ||
| TASK_NAME='wikitext' | ||
| model_name_or_path=$input_model | ||
| extra_cmd='--dataset_config_name=wikitext-2-raw-v1' | ||
| fi | ||
|
|
||
| if [[ ${int8} == "true" ]]; then | ||
| extra_cmd=$extra_cmd" --int8" | ||
| fi | ||
| echo $extra_cmd | ||
|
|
||
| python -u run_clm.py \ | ||
| --model_name_or_path ${model_name_or_path} \ | ||
| --dataset_name ${TASK_NAME} \ | ||
| --do_eval \ | ||
| --per_device_eval_batch_size ${batch_size} \ | ||
| --output_dir ${tuned_checkpoint} \ | ||
| ${mode_cmd} \ | ||
| ${extra_cmd} | ||
|
|
||
| } | ||
|
|
||
| main "$@" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.