-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Generate: Deprecate returning legacy cache by default; Handle use_cache=False
#32863
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
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. |
use_cache=False
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.
moved up to this documentation section (Parameters that control the generation strategy used), which makes more sense
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.
new cache-related docs section in GenerationConfig, moved all cache-related flags here
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.
(>120 chars/line)
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.
(moved)
src/transformers/generation/utils.py
Outdated
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.
In our docs we often mention that there are two ways to parameterize generate (generation_config or pass arg to generate). I don't think we need to be verbose here.
Also, setting through config is deprecated 😉
src/transformers/generation/utils.py
Outdated
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.
rewrote this one.
The old description was outdated (legacy cache), and we now know that different models have different caches, so we shouldn't be precise here. The model class docs can be more precise, let's redirect users there.
src/transformers/generation/utils.py
Outdated
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.
(These aliases made sense in the past, not anymore. They are, however, hard to deprecate!)
src/transformers/generation/utils.py
Outdated
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.
New function, moving the cache logic from generate. I've organized the logic in blocks, putting the cases where we DON'T prepare a new cache at the top.
It is doing essentially the same, except for the Quick escape route 2, which is new. Added the warning in Quick escape route 3.
src/transformers/generation/utils.py
Outdated
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.
This logic is expanded to handle a deprecation cycle
tests/generation/test_utils.py
Outdated
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.
changes in this file: pass use_cache to generate, instead of relying on model.config.use_cache=False and its side-effects
added a check to confirm that the cache is None when we pass use_cache=False
ArthurZucker
left a comment
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.
Cool! Let's make sure slow tests all pass as well here!
src/transformers/generation/utils.py
Outdated
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.
let's create an issue and leave it up to the community in the mean time!
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.
a442522 to
e8492bf
Compare
What does this PR do?
Another step towards using
Cacheeverywhere 💪This PR makes the following [
Cache+generate]-related changes:use_cache=False(fixes Cache updating when use_cache = False #32843 )generatetests now explicitly passuse_cache, instead of setting it inmodel.config🤢 We were relying on a LOT of side effects, and missing the incorrect case mentioned in Cache updating when use_cache = False #32843generation_configCacheinstance by default ongenerategenerateinto a single function, and reorganize the logic by blocks