-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
193 lines (166 loc) · 5.59 KB
/
utils.py
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import sys
import argparse
def get_argument_parser():
parser = argparse.ArgumentParser()
# Required_parameter
parser.add_argument(
"--local_rank",
type=int,
default=-1,
help="local_rank for distributed training on gpus",
)
# parser.add_argument(
# "--max_seq_length",
# default=512,
# type=int,
# help="The maximum total input sequence length after WordPiece tokenization. Sequences "
# "longer than this will be truncated, and sequences shorter than this will be padded.",
# )
# parser.add_argument(
# "--max_predictions_per_seq",
# "--max_pred",
# default=80,
# type=int,
# help="The maximum number of masked tokens in a sequence to be predicted.",
# )
# parser.add_argument(
# "--do_lower_case",
# default=True,
# action="store_true",
# help="Whether to lower case the input text. True for uncased models, False for cased models.",
# )
# parser.add_argument(
# "--use_pretrain",
# default=False,
# action="store_true",
# help="Whether to use Bert Pretrain Weights or not",
# )
# parser.add_argument(
# "--refresh_bucket_size",
# type=int,
# default=1,
# help="This param makes sure that a certain task is repeated for this time steps to \
# optimise on the back propogation speed with APEX's DistributedDataParallel",
# )
# parser.add_argument(
# "--finetune",
# default=False,
# action="store_true",
# help="Whether to finetune only",
# )
# parser.add_argument(
# "--lr_schedule",
# type=str,
# default="LE",
# help="Choices LE, EE, EP (L: Linear, E: Exponetial, P: Polynomial warmup and decay)",
# )
# parser.add_argument(
# "--lr_offset", type=float, default=0.0, help="Offset added to lr."
# )
# parser.add_argument(
# "--load_training_checkpoint",
# "--load_cp",
# type=str,
# default=None,
# help="This is the path to the TAR file which contains model+opt state_dict() checkpointed.",
# )
# parser.add_argument(
# "--load_checkpoint_id",
# "--load_cp_id",
# type=str,
# default=None,
# help="Checkpoint identifier to load from checkpoint path",
# )
# parser.add_argument(
# "--rewarmup",
# default=False,
# action="store_true",
# help="Rewarmup learning rate after resuming from a checkpoint",
# )
# parser.add_argument(
# "--max_steps",
# type=int,
# default=sys.maxsize,
# help="Maximum number of training steps of effective batch size to complete.",
# )
# parser.add_argument(
# "--max_steps_per_epoch",
# type=int,
# default=sys.maxsize,
# help="Maximum number of training steps of effective batch size within an epoch to complete.",
# )
# parser.add_argument(
# "--print_steps",
# type=int,
# default=100,
# help="Interval to print training details.",
# )
# parser.add_argument(
# "--data_path_prefix",
# type=str,
# default="",
# help="Path to prefix data loading, helpful for AML and other environments",
# )
# parser.add_argument(
# "--validation_data_path_prefix",
# type=str,
# default=None,
# help="Path to prefix validation data loading, helpful if pretraining dataset path is different",
# )
# parser.add_argument(
# "--deepspeed_transformer_kernel",
# default=False,
# action="store_true",
# help="Use DeepSpeed transformer kernel to accelerate.",
# )
# parser.add_argument(
# "--stochastic_mode",
# default=False,
# action="store_true",
# help="Use stochastic mode for high-performance transformer kernel.",
# )
# parser.add_argument(
# "--ckpt_to_save",
# nargs="+",
# type=int,
# help="Indicates which checkpoints to save, e.g. --ckpt_to_save 160 161, by default all checkpoints are saved.",
# )
# parser.add_argument(
# "--attention_dropout_checkpoint",
# default=False,
# action="store_true",
# help="Use DeepSpeed transformer kernel memory optimization to checkpoint dropout output.",
# )
# parser.add_argument(
# "--normalize_invertible",
# default=False,
# action="store_true",
# help="Use DeepSpeed transformer kernel memory optimization to perform invertible normalize backpropagation.",
# )
# parser.add_argument(
# "--gelu_checkpoint",
# default=False,
# action="store_true",
# help="Use DeepSpeed transformer kernel memory optimization to checkpoint GELU activation.",
# )
# parser.add_argument(
# "--deepspeed_sparse_attention",
# default=False,
# action="store_true",
# help="Use DeepSpeed sparse self attention.",
# )
# parser.add_argument(
# "--use_nvidia_dataset",
# default=False,
# action="store_true",
# help="Use Nvidia pretraining dataset.",
# )
# parser.add_argument(
# "--progressive_layer_drop",
# default=False,
# action="store_true",
# help="Whether to enable progressive layer dropping or not",
# )
return parser
def is_time_to_exit(args, epoch_steps=0, global_steps=0):
return (epoch_steps >= args.max_steps_per_epoch) or (global_steps >= args.max_steps)