Add warning message for beta and gamma parameters
What does this PR do?
This adds a warning message to notify about the renaming of gamma and beta parameters during initialisation and also during loading.
Fixes #29554
Before submitting
- [x] Did you read the contributor guideline, Pull Request section?
- [x] Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
- [X] Did you write any new necessary tests?
Who can review?
@amyeroberts
Hi @OmarManzoor,
Thanks for addressing this! We want to make sure we catch any place where the renaming happens, so any place where
if gamma in keyandif beta in keyare True (so key can be a longer string that contains beta or gamma). As you've added, this would be in_load_pretrained_modelbut also in _load_state_dict_into_model
Hi @amyeroberts Thanks for the feedback. Should we remove it during initialization? I added it in post init because during the main init we might not have the parameters declared.
Given the diff, I'm slightly confused, were there no warnings being triggered before? It seems like they were from the tests and logging messages
I basically removed the warning code that I added in the post init method. Should that be kept?
@OmarManzoor Ah, OK. I think the diff was rendering funny on github. Should be OK.
Looks great - thanks for adding and iterating on this!
Thank you.
Why have you added warnings only for the initialization process and not for renaming during loading as well? The model I'm using is timm's convnext (which is even the companion framework to transformers), which would have the parameter gamma. When loading he just tells me that I didn't successfully load the gamma function without telling me why, and I think the user should be informed when renaming the state_dict, otherwise it will cause unnecessary confusion.