2023-09-18 08:31:06 +00:00
|
|
|
from colossalai.legacy.amp import AMP_TYPE
|
2022-11-11 09:08:17 +00:00
|
|
|
|
|
|
|
# hyperparameters
|
|
|
|
# BATCH_SIZE is as per GPU
|
|
|
|
# global batch size = BATCH_SIZE x data parallel size
|
2023-01-11 07:17:17 +00:00
|
|
|
BATCH_SIZE = 4
|
2022-11-11 09:08:17 +00:00
|
|
|
LEARNING_RATE = 3e-3
|
|
|
|
WEIGHT_DECAY = 0.3
|
2023-01-10 03:26:19 +00:00
|
|
|
NUM_EPOCHS = 2
|
|
|
|
WARMUP_EPOCHS = 1
|
2022-11-11 09:08:17 +00:00
|
|
|
|
|
|
|
# model config
|
|
|
|
IMG_SIZE = 224
|
|
|
|
PATCH_SIZE = 16
|
2023-01-11 07:17:17 +00:00
|
|
|
HIDDEN_SIZE = 128
|
2022-11-11 09:08:17 +00:00
|
|
|
DEPTH = 4
|
|
|
|
NUM_HEADS = 4
|
|
|
|
MLP_RATIO = 2
|
2023-01-11 07:17:17 +00:00
|
|
|
NUM_CLASSES = 10
|
2022-11-11 09:08:17 +00:00
|
|
|
CHECKPOINT = False
|
2023-09-19 06:20:26 +00:00
|
|
|
SEQ_LENGTH = (IMG_SIZE // PATCH_SIZE) ** 2 + 1 # add 1 for cls token
|
2022-11-11 09:08:17 +00:00
|
|
|
|
|
|
|
# parallel setting
|
|
|
|
TENSOR_PARALLEL_SIZE = 2
|
2023-09-19 06:20:26 +00:00
|
|
|
TENSOR_PARALLEL_MODE = "1d"
|
2022-11-11 09:08:17 +00:00
|
|
|
|
|
|
|
parallel = dict(
|
|
|
|
pipeline=2,
|
|
|
|
tensor=dict(mode=TENSOR_PARALLEL_MODE, size=TENSOR_PARALLEL_SIZE),
|
|
|
|
)
|
|
|
|
|
|
|
|
fp16 = dict(mode=AMP_TYPE.NAIVE)
|
|
|
|
clip_grad_norm = 1.0
|
|
|
|
|
|
|
|
# pipeline config
|
2023-09-19 06:20:26 +00:00
|
|
|
NUM_MICRO_BATCHES = parallel["pipeline"]
|