#!/bin/bash
#SBATCH -p AI4Phys
#SBATCH --job-name=random
#SBATCH --output=save_yield_pred_random.output
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=32
#SBATCH --gres=gpu:1

source activate llama-factory


# MASTER_ADDR=`scontrol show hostname $SLURM_JOB_NODELIST | head -n1`
# MASTER_PORT=$((RANDOM % 101 + 20000))

# export MASTER_ADDR=$MASTER_ADDR
# export MASTER_PORT=$MASTER_PORT
# echo $MASTER_ADDR
# echo $MASTER_PORT

# function makehostfile() {
# perl -e '$slots=split /,/, $ENV{"SLURM_STEP_GPUS"};
# $slots=8 if $slots==0; # workaround 8 gpu machines
# @nodes = split /\n/, qx[scontrol show hostnames $ENV{"SLURM_JOB_NODELIST"}];
# print map { "$b$_ slots=$slots\n" } @nodes'
# }
# makehostfile > hostfile
# hostfile=""


# --include='localhost' \
srun deepspeed --launcher SLURM \
export_from_ds_data.py \
   --pretrained_model_path '/mnt/hwfile/ai4chem/share/step1_llama3_8b_0916_yearly_pistachio_ep3' \
   --lora_adapter_path "/mnt/hwfile/ai4chem/chenjianpeng/train_regression/llama_ep3_1115-18/lora_adapter" \
   --save_root '/mnt/hwfile/ai4chem/handong/suzuki_miyaura_fg_changes_random' \
   --gradient_accumulation_steps 4 \
   --use_lora 1 \
   --log_file "training_ds.log" \
   --deepspeed_config 'yield_ft_ds_config.json' \
   --load_ds_dir "/mnt/hwfile/ai4chem/handong/suzuki_miyaura_fg_changes_random/final" \
   --load_ds_ckpt_id final

