single.sh 3.2 KB
Newer Older
liangjing's avatar
v1  
liangjing committed
1
#!/bin/bash
liangjing's avatar
liangjing committed
2
3

# Runs the "7B" parameter model
liangjing's avatar
v1  
liangjing committed
4
5
export HSA_FORCE_FINE_GRAIN_PCIE=1
export OMP_NUM_THREADS=1
liangjing's avatar
liangjing committed
6
7
8
9
10
11
12
export NCCL_P2P_LEVEL=SYS

export NCCL_ALGO=Ring
export NCCL_NCHANNELS_PER_PEER=16
export NCCL_MIN_NCHANNELS=20
export NCCL_IB_TIMEOUT=22
export CUDA_DEVICE_MAX_CONNECTIONS=1
liangjing's avatar
v1  
liangjing committed
13

liangjing's avatar
liangjing committed
14
15
export NCCL_NET_GDR_LEVEL=SYS
export NCCL_NET_GDR_READ=0
liangjing's avatar
v1  
liangjing committed
16
17
18
19
20

lrank=$OMPI_COMM_WORLD_LOCAL_RANK
RANK=$OMPI_COMM_WORLD_RANK
WORLD_SIZE=$OMPI_COMM_WORLD_SIZE

liangjing's avatar
liangjing committed
21
22
23
24
25
CHECKPOINT_PATH=./tmp #$1 #<Specify path>
TENSORBOARD_LOGS_PATH=./tmp  #$2 #<Specify path>
DATA_PATH="./dataset/my-gpt2_text_document" #<Specify path and file prefix>_text_document
VOCAB_PATH=./gpt2-vocab.json
MERGE_PATH=./gpt2-merges.txt
liangjing's avatar
v1  
liangjing committed
26

liangjing's avatar
liangjing committed
27
28
29
30
31
32
33
34
GPT_MODEL_ARGS=(
    --num-layers 32 
    --hidden-size 4096
    --num-attention-heads 32
    --ffn-hidden-size 11008
    --seq-length 4096 
    --max-position-embeddings 4096
)
liangjing's avatar
v1  
liangjing committed
35

liangjing's avatar
liangjing committed
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
TRAINING_ARGS=(
    --log-throughput
    --transformer-impl local
    --use-legacy-models 
    --micro-batch-size 1 
    --global-batch-size 240 
    --train-iters 5 
    --weight-decay 0.1 
    --adam-beta1 0.9 
    --adam-beta2 0.95 
    --init-method-std 0.006 
    --clip-grad 1.0 
    --bf16
    --use-distributed-optimizer 
    --use-flash-attn-triton
    --disable-bias-linear
    --attention-dropout 0
    --hidden-dropout 0
    --no-gradient-accumulation-fusion
    --swiglu
    --lr 3.0e-5 
    --lr-decay-style cosine 
    --min-lr 3.0e-6
    --lr-warmup-iters 1
    --use-fast-rms-layernorm
    --use-fast-cross-entropy-loss
)
MODEL_PARALLEL_ARGS=(
        --sequence-parallel
	--tensor-model-parallel-size 1 
	--pipeline-model-parallel-size 4 
)
liangjing's avatar
v1  
liangjing committed
68

liangjing's avatar
liangjing committed
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
DATA_ARGS=(
    --data-path $DATA_PATH 
    --split 949,50,1
    --untie-embeddings-and-output-weights
    --use-rotary-position-embeddings 
    --normalization RMSNorm 
    --no-position-embedding
    --vocab-file $VOCAB_PATH 
    --merge-file $MERGE_PATH
    --tokenizer-type GPT2BPETokenizer 
)

EVAL_AND_LOGGING_ARGS=(
    --log-interval 1
    --save-interval 10000 
    --eval-interval 1000 
    --save $CHECKPOINT_PATH 
    --load $CHECKPOINT_PATH 
    --eval-iters 10
    --tensorboard-dir $TENSORBOARD_LOGS_PATH 
)

APP="python3  -u pretrain_gpt.py \
     ${GPT_MODEL_ARGS[@]} \
     ${TRAINING_ARGS[@]} \
     ${MODEL_PARALLEL_ARGS[@]} \
     ${DATA_ARGS[@]} \
     ${EVAL_AND_LOGGING_ARGS[@]}
     --rank ${RANK} \
     --world_size ${WORLD_SIZE} \
     --dist_url tcp://${1}:34566 \
    "
liangjing's avatar
v1  
liangjing committed
101

liangjing's avatar
liangjing committed
102
#for hygon cpu
liangjing's avatar
v1  
liangjing committed
103
104
case ${lrank} in
[0])
liangjing's avatar
liangjing committed
105
106
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=0 --membind=0 ${APP}
liangjing's avatar
v1  
liangjing committed
107
108
  ;;
[1])
liangjing's avatar
liangjing committed
109
110
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=1 --membind=1 ${APP}
liangjing's avatar
v1  
liangjing committed
111
112
  ;;
[2])
liangjing's avatar
liangjing committed
113
114
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=2 --membind=2 ${APP}
liangjing's avatar
v1  
liangjing committed
115
116
  ;;
[3])
liangjing's avatar
liangjing committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=3 --membind=3 ${APP}
  ;;
[4])
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=4 --membind=4 ${APP}
  ;;
[5])
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=5 --membind=5 ${APP}
  ;;
[6])
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=6 --membind=6 ${APP}
  ;;
[7])
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
  numactl --cpunodebind=7 --membind=7 ${APP}
liangjing's avatar
v1  
liangjing committed
135
136
  ;;
esac
liangjing's avatar
liangjing committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156