-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pan-x-c/feature/ee_tune
Release EE-Tuning
- Loading branch information
Showing
29 changed files
with
1,252 additions
and
131 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
|
||
LOAD_DIR= # path to the converted llama checkpoint in megatron format | ||
SAVE_DIR= # path to save the converted EE LLM checkpoint | ||
|
||
LOAD_ITER=1 | ||
CUR_DIR=$(cd $(dirname "$0") && pwd) | ||
MEGATRON_ROOT_PATH=$(cd "$CUR_DIR/../../.." && pwd) | ||
|
||
# For llama2 13B model (40 layers) | ||
|
||
## add an embedding only exit every 1/8 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 5 10 15 20 25 30 35 40 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
## add an embedding-norm exit every 1/8 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 5 10 15 20 25 30 35 40 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
## add an embedding-norm-mlp exit every 1/8 depth | ||
python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
--load-dir $LOAD_DIR \ | ||
--save-dir $SAVE_DIR \ | ||
--load-iteration $LOAD_ITER \ | ||
--use-exit-norm \ | ||
--use-exit-mlp \ | ||
--conversion-type add-exit \ | ||
--add-exit-layer-nums 5 10 15 20 25 30 35 40 \ | ||
--megatron-path $MEGATRON_ROOT_PATH | ||
|
||
## add an embedding-norm-layer exit every 1/8 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --use-exit-norm \ | ||
# --use-exit-block \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 5 10 15 20 25 30 35 40 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
## add an embedding-norm-mlp exit at 1/4 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --use-exit-norm \ | ||
# --use-exit-mlp \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 10 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
## add an random init embedding-norm-mlp exit at 1/4 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --use-exit-norm \ | ||
# --use-exit-mlp \ | ||
# --random-init \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 10 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
# For llama2 70B model (80 layers) | ||
|
||
## add an embedding-norm-mlp exit every 1/8 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --use-exit-norm \ | ||
# --use-exit-mlp \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 10 20 30 40 50 60 70 80 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH | ||
|
||
# For llama2 7B model (32 layers) | ||
|
||
## add an embedding-norm-mlp exit every 1/8 depth | ||
# python ${MEGATRON_ROOT_PATH}/tools/checkpoint/checkpoint_converter.py \ | ||
# --load-dir $LOAD_DIR \ | ||
# --save-dir $SAVE_DIR \ | ||
# --load-iteration $LOAD_ITER \ | ||
# --use-exit-norm \ | ||
# --use-exit-mlp \ | ||
# --conversion-type add-exit \ | ||
# --add-exit-layer-nums 4 8 12 16 20 24 28 32 \ | ||
# --megatron-path $MEGATRON_ROOT_PATH |
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,22 @@ | ||
#!/bin/bash | ||
|
||
LOAD_DIR= # path to the llama2 huggingface checkpoint dir | ||
SAVE_DIR= # path to save the converted megatron checkpoint | ||
TP=1 # target tensor parallel size | ||
PP=4 # target pipeline parallel size | ||
|
||
TOKENIZER_PATH=${LOAD_DIR}/tokenizer.model | ||
|
||
CUR_DIR=$(cd $(dirname "$0") && pwd) | ||
MEGATRON_ROOT_PATH=$(cd "$CUR_DIR/../../.." && pwd) | ||
|
||
python $MEGATRON_ROOT_PATH/tools/checkpoint/util.py \ | ||
--model-type EarlyExitGPT \ | ||
--load-dir $LOAD_DIR \ | ||
--save-dir $SAVE_DIR \ | ||
--loader llama2_hf \ | ||
--saver megatron \ | ||
--target-tensor-parallel-size $TP \ | ||
--target-pipeline-parallel-size $PP \ | ||
--megatron-path $MEGATRON_ROOT_PATH \ | ||
--tokenizer-model $TOKENIZER_PATH |
Oops, something went wrong.