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

Conversion to HF checkpoint should generate a checkpoint format that can be loaded directly #1359

Open
awaelchli opened this issue Apr 25, 2024 · 1 comment
Labels
conversion For model weight-map conversions enhancement New feature or request

Comments

@awaelchli
Copy link
Member

awaelchli commented Apr 25, 2024

The conversion we have with litgpt convert to a huggingface checkpoint creates a model.pth file. But then you have to load it like so as described in the tutorial:

import torch
from transformers import AutoModel

state_dict = torch.load("output_dir/model.pth")
model = AutoModel.from_pretrained(
    "output_dir/", local_files_only=True, state_dict=state_dict
)

But we should make it work like this:

model = AutoModel.from_pretrained("output_dir")

The only blocker for this is that from_pretrained requires the pytorch_model.bin to be loaded with weights_only=True. Our checkpoints don't satisfy this constraint, because we save checkpoints using the incremental pickle save. See #1357 for more context where we had to work around this.

@rasbt
Copy link
Collaborator

rasbt commented Apr 25, 2024

Yes I agree, there were a few people on Discord recently struggling with this

@carmocca carmocca added enhancement New feature or request conversion For model weight-map conversions labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conversion For model weight-map conversions enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants