Repository navigation
[loading] tie_weights is finally symmetric - #42507
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. |
molbap
left a comment
There was a problem hiding this comment.
Read through the new logic, thanks! I suggested some changes in the comments for clarity mostly, logic seems sound except the ordering in case of missing both keys but that's it!
| target_param_names = [target_param_name] | ||
| # Both are missing -> check other keys in case more than 2 keys are tied to the same weight | ||
| elif not source_is_there and not target_is_there: | ||
| for target_backup, source_backup in tied_keys[i + 1 :]: |
There was a problem hiding this comment.
maybe dumb question, why do we only search forward here? is there some ordering implied?
There was a problem hiding this comment.
Since they all have the same source, and we tie both source and target if we find it somewhere at the beginning when both are missinf, all later iterations will not enter this branch anymore as the source is now present 👌 But you're definitely right to ask, not necessarily trivial!
There was a problem hiding this comment.
aah got it. Thanks! Yeah all live modifications of iterables are hard to track haha
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks, let's make sure the marian and etc models are fixed !
| # checkpoint -> let's raise a warning and do nothing | ||
| if source_is_there and target_is_there: | ||
| logger.warning( | ||
| f"The tied weights mapping and config for this model specifies to tie {source_param_name} to " |
There was a problem hiding this comment.
very nice and actionnable
|
[For maintainers] Suggested jobs to run (before merge) run-slow: bart, openai |
* symetric tie weights * remove bart ones i added the other day * remove open ai skip i added the other day * style * clarify comments * unfortunately cannot raise now * typo * add flag * typo * add tests * more tests
* symetric tie weights * remove bart ones i added the other day * remove open ai skip i added the other day * style * clarify comments * unfortunately cannot raise now * typo * add flag * typo * add tests * more tests
What does this PR do?
As per the title. This makes
tie_weightswork fully symmetrically, even in cases where one weight is tied between more than 2 keys.This will hopefully end the pain of all models checkpoints having the saved weight in the "wrong" key.
This fixes several opened issues: #42313 (though we still have an issue with the tokenizer here apparently), #42460 and I think others that I lost track of.
Note: for
facebook/bart-largebart checkpoint, all 3 tied weight keys are explicitly present in the safetensors checkpoint. So according to this PR, they are not tied anymore (with a warning), whereas they would be anyway before. IMO this is fine as if they are in the checkpoints, they were not tied when saved. We could introduce a value check if both source and targets are present and still tie if everything is equal, but I think this is too expensive and too niche to add for now. We may consider doing it if we notice this is more frequent so thosebartcheckpoints