Skip to content

Commit

Permalink
Fix selective restore by explicitly verifying keys (#11377)
Browse files Browse the repository at this point in the history
Signed-off-by: Hemil Desai <[email protected]>
  • Loading branch information
hemildesai authored Nov 25, 2024
1 parent 8f779ba commit 82d9dd2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nemo/lightning/pytorch/strategies/megatron_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,13 @@ def load_checkpoint(self, checkpoint_path: Union[str, Path], selective_restore:

checkpoint = self.checkpoint_io.load_checkpoint(checkpoint_path, sharded_state_dict=sharded_state_dict)

if selective_restore:
final_checkpoint = {}
for key in sharded_state_dict.keys():
final_checkpoint[key] = checkpoint[key]

return final_checkpoint

return checkpoint

def selective_restore(self) -> None:
Expand Down

0 comments on commit 82d9dd2

Please sign in to comment.