Replace past with past_key_values#20944
Merged
ArthurZucker merged 14 commits intohuggingface:mainfrom Jan 8, 2023
Merged
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
…to remove_past_for_past_key
gante
approved these changes
Jan 4, 2023
Contributor
gante
left a comment
There was a problem hiding this comment.
LGTM 👍
Although the change in the failing TF test is weird, we should try to understand it before we merge this PR 🤔
Comment on lines
+1478
to
+1487
| @staticmethod | ||
| def _reorder_cache(past, beam_idx): | ||
| reordered_past = () | ||
| for layer_past in past: | ||
| # cached cross_attention states don't have to be reordered -> they are always the same | ||
| reordered_past += ( | ||
| tuple(tf.gather(past_state, beam_idx, axis=0) for past_state in layer_past[:2]) + layer_past[2:], | ||
| ) | ||
| return reordered_past | ||
|
|
Contributor
There was a problem hiding this comment.
This is no longer needed in the TF side :D (It was used in the code path that existed before the XLA transition)
Collaborator
Author
There was a problem hiding this comment.
Sure, I thought that the failing test might come from this but I was wrong 😉
…to remove_past_for_past_key
Collaborator
Author
|
Ok the failing tests were because I did not pull from main, were the |
Collaborator
|
Yes, good to merge for me! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The argument
pastwas completely replaced withpast_key_valuesthus this PR should fix any problem withkwargsbeing swallowed for old models in generation.Related to #20347