Skip to content

Commit

Permalink
add freeze all on init
Browse files Browse the repository at this point in the history
  • Loading branch information
YizhenJia committed Dec 24, 2024
1 parent ffd2b1d commit 18f5888
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lmflow/pipeline/utils/lisa_trainer_fsdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def __init__(
self.active_layers_indices = []
self.histroy_layers_indices = []
self.active_layers_names = []

layers = self._get_all_body_layers()
for layer in layers:
for param in layer.parameters():
param.requires_grad = False


def _get_all_body_layers(self) -> List[nn.Module]:
Expand Down Expand Up @@ -112,7 +117,8 @@ def _switch_active_layers(self):
param.requires_grad = True


def maybe_switch_active_layers(self):
def maybe_switch_active_layers(self):
print('maybe_switch')
if (
self.state.global_step == 0 # skip since already initialized in `create_optimizer`
or
Expand Down

0 comments on commit 18f5888

Please sign in to comment.