Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deepspeed-chat: fix weight decay configuration #755

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions applications/DeepSpeed-Chat/training/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,18 @@ def get_optimizer_grouped_parameters(
model,
weight_decay,
lora_lr=5e-4,
no_decay_name_list=["bias", "LayerNorm.weight"],
lekurile marked this conversation as resolved.
Show resolved Hide resolved
no_decay_name_list=[
"bias", "layer_norm.weight", "layernorm.weight", "norm.weight",
"ln_f.weight"
],
lora_name_list=["lora_right_weight", "lora_left_weight"],
):
optimizer_grouped_parameters = [
{
"params": [
p for n, p in model.named_parameters()
if (not any(nd in n for nd in no_decay_name_list)
and p.requires_grad and not any(nd in n
if (not any(nd in n.lower() for nd in no_decay_name_list)
and p.requires_grad and not any(nd in n.lower()
for nd in lora_name_list))
],
"weight_decay":
Expand All @@ -204,8 +207,8 @@ def get_optimizer_grouped_parameters(
{
"params": [
p for n, p in model.named_parameters()
if (not any(nd in n for nd in no_decay_name_list)
and p.requires_grad and any(nd in n
if (not any(nd in n.lower() for nd in no_decay_name_list)
and p.requires_grad and any(nd in n.lower()
for nd in lora_name_list))
],
"weight_decay":
Expand All @@ -216,7 +219,7 @@ def get_optimizer_grouped_parameters(
{
"params": [
p for n, p in model.named_parameters()
if (any(nd in n
if (any(nd in n.lower()
for nd in no_decay_name_list) and p.requires_grad)
],
"weight_decay":
Expand Down
Loading