forked from FlagOpen/FlagScale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pretrain_aquila_34b_distributed_A100_64n_40g.sh
executable file
·152 lines (137 loc) · 3.8 KB
/
pretrain_aquila_34b_distributed_A100_64n_40g.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# Please change the following envrioment variables
# base on the cluster configuration
export CUDA_DEVICE_MAX_CONNECTIONS=1
export NCCL_SOCKET_IFNAME=eth0
export NCCL_IB_DISABLE=0
export NCCL_IB_CUDA_SUPPORT=1
export NCCL_IB_GID_INDEX=0
export NCCL_IB_HCA=mlx5_2,mlx5_5
export NCCL_IB_TIMEOUT=23
export NCCL_IB_RETRY_CNT=7
export NCCL_DEBUG=DEBUG
export OMP_NUM_THREADS=4
export CUDA_DEVICE_MAX_CONNECTIONS=1
export GLOO_SOCKET_IFNAME=eth0
set -u
PROJ_HOME=$1
EXPNAME=$2
HOSTFILE=$3
DATA_PATH=$4
set +u
CHECKPOINT_PATH=$PROJ_HOME/checkpoints/$EXPNAME
mkdir -p $CHECKPOINT_PATH
VOCAB_FILE=../examples/aquila/tokenizer/vocab.json
MERGE_FILE=../examples/aquila/tokenizer/merges.txt
SPECIAL_TOKENS_FILE=../examples/aquila/tokenizer/special_tokens.txt
LOG_PATH=$PROJ_HOME/logs/$EXPNAME
mkdir -p $LOG_PATH
cp $0 $LOG_PATH/
TB_PATH=$PROJ_HOME/tboard/$EXPNAME
mkdir -p $TB_PATH
WB_PATH=$PROJ_HOME/wandb/$EXPNAME
mkdir -p $WB_PATH
export NODE_ADDR=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2;}'|tr -d "addr:"|head -n 1)
export GPUS_PER_NODE=$(awk '{$1=$1;print}' $HOSTFILE|awk -F" |=" '{ranks[$1]=$NF;}END{print ranks["'$NODE_ADDR'"];}')
export NNODES=$(cat $HOSTFILE | wc -l)
export MASTER_ADDR=$(head -n1 $HOSTFILE | awk '{print $1;}')
export NODE_RANK=$(awk '{ranks[$1]=(FNR-1);}END{print ranks["'$NODE_ADDR'"];}' $HOSTFILE)
export MASTER_PORT=12345
WORLD_SIZE=$(($GPUS_PER_NODE * $NNODES))
DISTRIBUTED_ARGS="
--nproc_per_node $GPUS_PER_NODE \
--nnodes $NNODES \
--node_rank $NODE_RANK \
--master_addr $MASTER_ADDR \
--master_port $MASTER_PORT
"
TRAINING_ARGS="
--train-samples 488281250 \
--rampup-batch-size 32 32 2000000 \
--eval-iters 0 \
--eval-interval 2000 \
--tensor-model-parallel-size 4 \
--pipeline-model-parallel-size 4 \
--make-vocab-size-divisible-by 64 \
--micro-batch-size 1 \
--global-batch-size 1024 \
--disable-bias-linear \
--use-flash-attn \
--sequence-parallel \
--use-distributed-optimizer
"
MIXED_PRECISION_ARGS="
--bf16 \
--attention-softmax-in-fp32 \
--accumulate-allreduce-grads-in-fp32
"
DATA_ARGS="
--data-path $DATA_PATH \
--tokenizer-type AquilaTokenizer \
--vocab-file $VOCAB_FILE \
--vocab-size 100008\
--merge-file $MERGE_FILE \
--special-tokens-file $SPECIAL_TOKENS_FILE \
--split 1
"
NETWORK_ARGS="
--num-layers 60 \
--hidden-size 6144 \
--num-attention-heads 48 \
--group-query-attention \
--num-query-groups 8 \
--hidden-dim-multiplier 1.3 \
--seq-length 4096 \
--max-position-embeddings 4096 \
--norm-epsilon 1e-5 \
--norm-init-weight 0.3 \
--use-rotary-position-embeddings \
--no-position-embedding \
--swiglu \
--multiple-of 4096 \
--normalization RMSNorm \
--untie-embeddings-and-output-weights
"
INITIALIZATION_ARGS="
--init-method-std 0.0165 \
--seed 42
"
REGULARIZATION_ARGS="
--attention-dropout 0.0 \
--hidden-dropout 0.0 \
--weight-decay 0.1 \
--adam-beta1 0.9 \
--adam-beta2 0.95 \
--clip-grad 1.0
"
LEARNING_RATE_ARGS="
--lr 1.5e-4 \
--lr-decay-style cosine \
--lr-warmup-samples 500000 \
--min-lr 1.5e-5
"
CHECKPOINTING_ARGS="
--save-interval 1000 \
--rampup-save-interval 5000 \
--save $CHECKPOINT_PATH \
--load $CHECKPOINT_PATH
"
LOGGING_ARGS="
--log-interval 1 \
--tensorboard-dir $TB_PATH \
--tensorboard-log-interval 1 \
--wandb-save-dir $WB_PATH
"
cmd="torchrun $DISTRIBUTED_ARGS pretrain_gpt.py \
$TRAINING_ARGS \
$MIXED_PRECISION_ARGS \
$DATA_ARGS \
$NETWORK_ARGS \
$INITIALIZATION_ARGS \
$REGULARIZATION_ARGS \
$LEARNING_RATE_ARGS \
$CHECKPOINTING_ARGS \
$LOGGING_ARGS
"
echo $cmd
eval $cmd