|
@@ -108,17 +108,15 @@ def init_model(lm_config):
|
|
|
return sum(p.numel() for p in model.parameters() if p.requires_grad)
|
|
return sum(p.numel() for p in model.parameters() if p.requires_grad)
|
|
|
|
|
|
|
|
if model_from == 1:
|
|
if model_from == 1:
|
|
|
|
|
+ model = Transformer(lm_config)
|
|
|
moe_path = '_moe' if lm_config.use_moe else ''
|
|
moe_path = '_moe' if lm_config.use_moe else ''
|
|
|
ckp = f'./out/pretrain_{lm_config.dim}{moe_path}.pth'
|
|
ckp = f'./out/pretrain_{lm_config.dim}{moe_path}.pth'
|
|
|
-
|
|
|
|
|
- model = Transformer(lm_config)
|
|
|
|
|
- # state_dict = torch.load(ckp, map_location=device)
|
|
|
|
|
- #
|
|
|
|
|
- # unwanted_prefix = '_orig_mod.'
|
|
|
|
|
- # for k, v in list(state_dict.items()):
|
|
|
|
|
- # if k.startswith(unwanted_prefix):
|
|
|
|
|
- # state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
|
|
|
|
- # model.load_state_dict(state_dict, strict=False)
|
|
|
|
|
|
|
+ state_dict = torch.load(ckp, map_location=device)
|
|
|
|
|
+ unwanted_prefix = '_orig_mod.'
|
|
|
|
|
+ for k, v in list(state_dict.items()):
|
|
|
|
|
+ if k.startswith(unwanted_prefix):
|
|
|
|
|
+ state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
|
|
|
|
+ model.load_state_dict(state_dict, strict=False)
|
|
|
else:
|
|
else:
|
|
|
model = AutoModel.from_pretrained('./minimind', trust_remote_code=True)
|
|
model = AutoModel.from_pretrained('./minimind', trust_remote_code=True)
|
|
|
|
|
|
|
@@ -148,7 +146,7 @@ if __name__ == "__main__":
|
|
|
out_dir = 'out'
|
|
out_dir = 'out'
|
|
|
epochs = 19
|
|
epochs = 19
|
|
|
gradient_accumulation_steps = 1
|
|
gradient_accumulation_steps = 1
|
|
|
- batch_size = 80
|
|
|
|
|
|
|
+ batch_size = 50
|
|
|
learning_rate = 2e-4
|
|
learning_rate = 2e-4
|
|
|
device = 'cuda:0'
|
|
device = 'cuda:0'
|
|
|
dtype = 'bfloat16'
|
|
dtype = 'bfloat16'
|
|
@@ -175,7 +173,7 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
model, tokenizer = init_model(lm_config)
|
|
model, tokenizer = init_model(lm_config)
|
|
|
# -----init dataloader------
|
|
# -----init dataloader------
|
|
|
- df = pd.read_csv('./dataset/sft_data_single.csv')
|
|
|
|
|
|
|
+ df = pd.read_csv('./dataset/sft_data_multi.csv')
|
|
|
df = df.sample(frac=1.0)
|
|
df = df.sample(frac=1.0)
|
|
|
train_ds = SFTDataset(df, tokenizer, max_length=max_seq_len)
|
|
train_ds = SFTDataset(df, tokenizer, max_length=max_seq_len)
|
|
|
train_sampler = DistributedSampler(train_ds) if ddp else None
|
|
train_sampler = DistributedSampler(train_ds) if ddp else None
|