-
Notifications
You must be signed in to change notification settings - Fork 581
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
ModelHubMixin config support throws error #2379
Comments
Hi @joelburget, the problem in your example is that you are serializing the In general, I'm not sure to understand what you are trying to achieve. |
Hi @Wauplin, thanks for looking into this.
I first tried
You're right, I was basing this off the fact that all |
For anyone else trying to do something similar: hf_model = AutoModel.from_pretrained("EleutherAI/gpt-neo-125M")
class MyModel(GPTNeoModel):
def __init__(self, config):
super().__init__(config)
self.h = nn.ModuleList([GPTNeoBlock(config, 0)])
config = AutoConfig.from_pretrained("EleutherAI/gpt-neo-125M")
config.num_layers = 1
config.attention_layers = config.attention_layers[:1]
config.attention_types = [[['global'], 1]]
model = MyModel(config)
model.push_to_hub("joelb/my-awesome-model", config=config) |
Glad you've found a workaround for your use case @joelburget :) Just for your info, this issue tells you that the mixin don't know how to serialize your GPTNeoConfig object as a JSON. What you can do is to provide an encoder and a decoder methods when defining your class as explained in this section of the guide. However your solution that do not involve |
Describe the bug
I created a notebook which tries to use
PyTorchModelHubMixin
in a way very similar to that described in the docs and #2001. As you can see, when I try to instantiate it withMyModel.from_pretrained
I getAttributeError: 'dict' object has no attribute 'hidden_size'
.AutoModel.from_pretrained
fails withAttributeError: 'NoneType' object has no attribute 'get'
. It's not clear with either error what the root cause is.Reproduction
https://gist.github.com/joelburget/623a13c71129044c661009a56b2cf46d is self-contained
Logs
No response
System info
The text was updated successfully, but these errors were encountered: