

EPOCH=$1
DATASET_NAME=$2
ITERATION=$3
CHECK_POINT_ROOT_PATH=$4
CONVERTED_CHECK_POINT_ROOT_PATH=$5
MODEL_NAME=$6
MODEL_ORG=$7


FORMATTED_ITERATION=$(printf "iter_%07d" $ITERATION)

CHECK_POINT_PATH=${CHECK_POINT_ROOT_PATH}/${MODEL_NAME}/${DATASET_NAME}_lr_2e-5-minlr_4e-6_GB_64_${EPOCH}epoch/${FORMATTED_ITERATION}/model.pt

OUTPUT_PATH=${CONVERTED_CHECK_POINT_ROOT_PATH}/${MODEL_NAME}/${DATASET_NAME}_lr_2e-5-minlr_4e-6_GB_64_${EPOCH}epoch/${FORMATTED_ITERATION}
mkdir -p $OUTPUT_PATH

HF_BASE_MODEL_CHECKPOINT_PATH=${MODEL_ORG}/${MODEL_NAME}

SEQ_LENGTH=8192

python tools/checkpoint-convert/convert_ckpt.py \
  --hf-base-model-checkpoint-path $HF_BASE_MODEL_CHECKPOINT_PATH \
  --hf-tokenizer-path $HF_BASE_MODEL_CHECKPOINT_PATH \
  --pytorch-model-checkpoint-path $CHECK_POINT_PATH \
  --out $OUTPUT_PATH \
  --sequence-length $SEQ_LENGTH
