Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/optim/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def train_base(model, opt, data, scheduler, iterations, acc_steps, batch_size, s
if extra_args.grad_clip != 0.0:
torch.nn.utils.clip_grad_norm_(model.parameters(), extra_args.grad_clip)
opt.step()
scheduler.step()
if scheduler != None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if scheduler is not None

(otherwise LGTM)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello, this kind of fix was already proposed in the soap branch,
but we didn't change the sparse.py

thanks for the reminder)

scheduler.step()
opt.zero_grad(set_to_none=True)
itr += 1

Expand Down
3 changes: 2 additions & 1 deletion src/optim/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def train_sparse(model, opt, data, scheduler, iterations, acc_steps, batch_size,
substep += 1

opt.step()
scheduler.step()
if scheduler != None:
scheduler.step()
opt.zero_grad(set_to_none=True)
itr += 1

Expand Down
2 changes: 1 addition & 1 deletion src/optim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def save_checkpoint(distributed_backend, model, opt, scheduler, itr, ckpt_path,
checkpoint = dict({
'model': distributed_backend.get_raw_model(model).state_dict(),
'optimizer': opt.state_dict(),
'scheduler': scheduler.state_dict(),
'scheduler': scheduler.state_dict() if scheduler != None else None,
'itr': itr,
}, **extra_args)

Expand Down