Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor checkpoint loading for fine-tuning for new NeMo2 workflow #132

Open
jstjohn opened this issue Sep 4, 2024 · 0 comments
Open

Refactor checkpoint loading for fine-tuning for new NeMo2 workflow #132

jstjohn opened this issue Sep 4, 2024 · 0 comments

Comments

@jstjohn
Copy link
Collaborator

jstjohn commented Sep 4, 2024

This PR: NVIDIA/NeMo-Run#28 will change how checkpoint IO is handled. Roughly after the change, instead of relying on self.__io__ we will have to use a different mechanism to get at the metadata associated with a particular checkpoint. Now there will be a io.ckpt_context global variable that stores the captured hyper-parameters for a particular config object which we need to modify instead. The following provides some rough psuedo-code for how this might look:

@dataclass
class ModelConfig(TransformerConfig):
  other_ckpt:str = "path/to/checkpoint"
  def configure_model(self, tokenizer):
    other_settings = io.load(self.other_ckpt).model.config
    my_cfg = io.ckpt_context.model.config # pointer to global config that will be saved
    for setting in dir(other_settings):
      #1 update self with settings from other
      setattr(self, setting, getattr(other_settings, setting))
      # 2 update what will be saved (post init) with settings from other
      setattr(my_cfg, setting, getattr(other_settings, setting))
      model = init_model(self)
    load_model_weights(model, self.other_ckpt)
    return model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant