-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix: correctly encode/decode config in ModelHubMixin if custom coders #2337
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
provided_config = passed_values.get("config") | ||
if isinstance(provided_config, dict): | ||
init_config.update(provided_config) | ||
if isinstance(passed_config, dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should change this one, a counter-example would be
class Model(nn.Module,PyTorchModelHubMixin):
def __init__(self,config):
super().__init__()
# other stuff here maybe load config file number 2
self.layer = nn.Linear(config,config)
model = Model(2)
model._hub_mixin_config
>>> None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'd prefer not to update the lib' for this corner case. This PR is meant to fix real-world issue (reported by @NielsRogge for https://github.com/hamadichihaoui/BIRD/) but having a int
config seems pretty unusual.
Co-authored-by: Hafedh <70411813+not-lain@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that @Wauplin!
Thanks both for the quick review! 🤗 |
…#2337) * Fix: correctly encode/decode config in ModelHubMixin if custom coders * make style * make quality * Update tests/test_hub_mixin_pytorch.py Co-authored-by: Hafedh <70411813+not-lain@users.noreply.github.com> --------- Co-authored-by: Hafedh <70411813+not-lain@users.noreply.github.com>
Fix #2334.
Thanks to @not-lain's investigation (see #2334 (comment)), I have been able to reproduce the error with a simple example. The problem was that custom encoders/decoders were not used for the special attribute
config
. This PR fixes it. I also added a regression test inspired by the reproducible example.Once merged, I'll make a hot-fix release with this fix.
(failing tests are unrelated)