-
Notifications
You must be signed in to change notification settings - Fork 26.2k
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
🚨 out_indices always a list #30941
🚨 out_indices always a list #30941
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. |
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.
Sound good to me but with a nit question. Would like to hear from @NielsRogge too.
Thanks!
a1e1e50
to
66a0096
Compare
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.
If we need them to be mutable, cool to cast to list!
@ArthurZucker It's not that we need them to be mutable (in fact, we probably don't), it's to do with consistent typing when saving / loading configs. Previously, we just followed the out_indices from timm, which could be tuples or lists. However, for our models, because they're loaded through the configs, if a model is saved out with out_indices which are a tuple, it'll be cast to a list because of writing as a json. Previously, timm would respect whichever type was used to create the model, but now only uses tuples. This PR enforces a casting to list to make sure:
|
* out_indices always a list * Update src/transformers/utils/backbone_utils.py * Update src/transformers/utils/backbone_utils.py * Move type casting * nit
* out_indices always a list * Update src/transformers/utils/backbone_utils.py * Update src/transformers/utils/backbone_utils.py * Move type casting * nit
* out_indices always a list * Update src/transformers/utils/backbone_utils.py * Update src/transformers/utils/backbone_utils.py * Move type casting * nit
What does this PR do?
Recent updates to timm changed the type of the attribute
model.feature_info.out_indices
. Previously,out_indices
would reflect the input type ofout_indices
on thecreate_model
call i.e. eithertuple
orlist
. Now, this value is always a tuple. This causes the following failure on main:Example CI run: https://app.circleci.com/pipelines/github/huggingface/transformers/93542/workflows/38bfe697-908c-4d2c-a05c-7b99090fb084/jobs/1226834
As list are more useful and consistent for us -- we cannot save tuples in configs, they must be converted to lists first -- we instead choose to cast
out_indices
to always be a list.This has the possibility of being a slight breaking change if users are creating models and relying on
out_indices
on being a tuple. As this property only happens when a new model is created, and not if it's saved and reloaded (because of the config), then I think this has a low chance of having much of an impact.The following tests were run to make sure everything is still OK: