🚨 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.
Sound good to me but with a nit question. Would like to hear from @NielsRogge too.
Thanks!
a1e1e50 to
66a0096
Compare
ArthurZucker
left a comment
There was a problem hiding this comment.
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
What does this PR do?
Recent updates to timm changed the type of the attribute
model.feature_info.out_indices. Previously,out_indiceswould reflect the input type ofout_indiceson thecreate_modelcall i.e. eithertupleorlist. 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_indicesto always be a list.This has the possibility of being a slight breaking change if users are creating models and relying on
out_indiceson 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: