Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/llama2/convert_megatron_checkpoint_from_hf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#/usr/bin/bash
SCRIPT_ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_ROOT=$SCRIPT_ROOT/../..

TP=${TP:-1}
PP=${PP:-1}

MODEL=Llama-2-7b-hf
MODEL_TYPE=llama2-7B

HF_MODEL_DIR=/workspace/models/$MODEL
OUTPUT=/workspace/models/$MODEL-to-megatron-tp$TP-pp$PP
TOKENIZER_MODEL=/workspace/models/$MODEL/tokenizer.model

python $PROJECT_ROOT/tools/checkpoint/convert.py \
--model-type GPT \
--loader llama_mistral \
--model-size $MODEL_TYPE \
--saver megatron \
--target-tensor-parallel-size ${TP} \
--target-pipeline-parallel-size ${PP} \
--checkpoint-type hf \
--load-dir $HF_MODEL_DIR \
--save-dir $OUTPUT \
--tokenizer-model ${TOKENIZER_MODEL} \
--bf16
Loading