Skip to content

Commit

Permalink
fix the bug when the params in shared modules do not require grad
Browse files Browse the repository at this point in the history
  • Loading branch information
HIT-cwh committed Feb 3, 2023
1 parent 6dc1d70 commit bad1c33
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mmengine/optim/optimizer/default_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ def add_params(self,

for name, param in module.named_parameters(recurse=False):
param_group = {'params': [param]}
if not param.requires_grad:
params.append(param_group)
continue
if bypass_duplicate and self._is_in(param_group, params):
warnings.warn(f'{prefix} is duplicate. It is skipped since '
f'bypass_duplicate={bypass_duplicate}')
continue
if not param.requires_grad:
params.append(param_group)
continue

# if the parameter match one of the custom keys, ignore other rules
is_custom = False
for key in sorted_keys:
Expand Down

0 comments on commit bad1c33

Please sign in to comment.