Skip to content
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

Stop requiring CacheConfig in GenerationConfig with StaticCache #35026

Open
poedator opened this issue Nov 30, 2024 · 3 comments
Open

Stop requiring CacheConfig in GenerationConfig with StaticCache #35026

poedator opened this issue Nov 30, 2024 · 3 comments

Comments

@poedator
Copy link
Contributor

poedator commented Nov 30, 2024

I have an observation that in some common use cases, configuring StaticCache during GenerationConfig initialisation is unnecessary.
it was introduced in #32830

Specifically, when the model is used with .generate, only the cache_implementation config option is relevant. The rest of the cache config is determined inside generate(), specifically in transformers.generation.utils::GenerationMixin._get_cache(). In that function, StaticCache is created based on the requested generation parameters, ignoring cache_config entirely.

Suggestion:

  • do not require StaticCache config in GenerationConfig.init
  • have some custom logic for ExecuTorch, that does not affect other use cases
  • have default arguments for StaticCache.init() so that it would quietly get created with some default parameters (not a good idea though).
  • have tests in transformers that set just cache_implementation="static" and then call .generate()

current workaround:

do not set cache_implementation in GenerationConfig constructor, but set it afterwards with:
model.generation_config.cache_implementation = "static"

system info
applies to transformers from september 2024 up to the current 4.46.3

Who can help?

@gante

@Rocketknight1
Copy link
Member

cc @zucchini-nlp as well!

Copy link

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@poedator
Copy link
Contributor Author

up
@zucchini-nlp @gante

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants