Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ydli-ai committed Dec 15, 2023
1 parent fa766f9 commit 45c39bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions pretrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def main():
help="The buffer size of instances in memory.")
parser.add_argument("--dropout", type=float, default=0.1, help="Dropout value.")
parser.add_argument("--seed", type=int, default=7, help="Random seed.")
parser.add_argument("--train_embedding_only", action="store_true")

# Preprocess options.
tokenizer_opts(parser)
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_model_into_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
state_dict = collections.OrderedDict()
filename = f"tencentpretrain_model-0.bin"
for k, v in input_model.items():
state_dict[k] = v
state_dict[k] = v.bfloat16()
index_dict["weight_map"][k] = filename
param_count += v.numel()
file_count += v.numel()
Expand Down
10 changes: 10 additions & 0 deletions tencentpretrain/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,16 @@ def worker(local_rank, gpu_ranks, args, model_for_training, model_for_dataloader

# Build optimizer.
param_optimizer = list(model_for_training.named_parameters())
if args.train_embedding_only:
optimizer_grouped_parameters = [
{"params": [p for n, p in param_optimizer if 'embedding' in n or "output_layer" in n]},
#{"params": [p for n, p in param_optimizer if 'embedding' not in n and "output_layer" not in n], "lr": 0}
]
#print(optimizer_grouped_parameters)
for n, p in list(model_for_training.named_parameters()):
if 'embedding' not in n and "output_layer" not in n:
p.requires_grad = False

if args.use_lora:
optimizer_grouped_parameters = [
{"params": [p for n, p in param_optimizer if 'lora' in n]}
Expand Down

0 comments on commit 45c39bc

Please sign in to comment.