-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.ds_pl.py
39 lines (36 loc) · 1007 Bytes
/
train.ds_pl.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
import torch
from config import LMConfig
from data import YuanDataModule
from model import HFModel
from trainer.lightning import pl_train, DistributedStrategy
if __name__ == '__main__':
config = LMConfig(
vocab_size=53005,
hidden_size=3072,
layer_num=40,
attention_heads=24,
seq_length=2048,
learning_rate=5e-5,
batch_size=16,
)
core_model = HFModel(config)
dm = YuanDataModule(
batch_size=config.batch_size,
processed_data_path='./data/yuan/processed_data.npz'
)
# dm = MockDataModule(
# vocab_size=config.vocab_size,
# seq_length=config.seq_length,
# batch_size=config.batch_size,
# mock_data_size=128
# )
pl_train(
core_model, dm, "model_name",
use_distributed=DistributedStrategy.CUSTOM,
accelerator='gpu',
devices=-1,
precision=16,
max_epochs=1,
# accumulate_grad_batches=16,
seed=config.seed
)