This commit is contained in:
Sourab Mangrulkar
2022-12-01 21:15:01 +05:30
parent 5f2062e90b
commit e63f47ca52
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -46,10 +46,10 @@ class PETModel(torch.nn.Module):
num_transformer_submodules = 0
transformer_backbone = None
for name, module in self.base_model.named_children():
for param in module.parameters():
param.requires_grad = False
if isinstance(module, PreTrainedModel):
# Make sure to freeze Tranformers model
for param in module.parameters():
param.requires_grad = False
if transformer_backbone is None:
transformer_backbone = module
self.transformer_backbone_name = name
+12
View File
@@ -44,3 +44,15 @@ def _set_trainable(model):
param.requires_grad = True
else:
param.requires_grad = False
# def fsdp_auto_wrap_policy():
# from torch.distributed.fsdp.wrap import transformer_auto_wrap_policy, lambda_auto_wrap_policy, _or_policy
# def lambda_policy(module):
# if len(module.named_children()) != 0 and
# return True
# return False
# pass