From 50c82114188322d0cd37089083d4c3ac0f2c4852 Mon Sep 17 00:00:00 2001 From: "serge[bot]" Date: Wed, 1 Jul 2026 15:41:12 +0000 Subject: [PATCH 1/2] [serge] Fix 10 integration tests for model `gemma3` failing with `output_mismatch` (list output differs (8), other (2)) --- src/transformers/generation/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/generation/utils.py b/src/transformers/generation/utils.py index fbbff776713f..64e132b73c4a 100644 --- a/src/transformers/generation/utils.py +++ b/src/transformers/generation/utils.py @@ -1763,7 +1763,7 @@ def _prepare_generation_config( # `cache_implementation="hybrid"` (the static sliding window cache). For these models, we now want to use # the dynamic sliding window cache by default, so we UNSET `cache_implementation` if it is a default value. # (if we're inside this branch, then it is because we're using default values from the Hub) - if generation_config.cache_implementation == "hybrid": + if generation_config.cache_implementation == "hybrid" and "cache_implementation" not in kwargs: generation_config.cache_implementation = None # It doesn't make sense to allow kwargs and `generation_config`, that should be mutually exclusive From d59aa6e675579a349bbc99551f683bc81ce9ae19 Mon Sep 17 00:00:00 2001 From: "serge[bot]" Date: Thu, 2 Jul 2026 01:49:47 +0000 Subject: [PATCH 2/2] [serge] Fix 10 integration tests for model `gemma3` failing with `output_mismatch` (list output differs (8), other (2)) --- src/transformers/generation/utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/transformers/generation/utils.py b/src/transformers/generation/utils.py index 64e132b73c4a..6e4c53f2105f 100644 --- a/src/transformers/generation/utils.py +++ b/src/transformers/generation/utils.py @@ -1756,16 +1756,17 @@ def _prepare_generation_config( generation_config.update(**self.generation_config.to_dict(), defaults_only=True, allow_custom_entries=True) generation_config.update(**global_defaults, defaults_only=True) - # Finally, if there are any kwargs, update config with it -> highest priority at the end - model_kwargs = generation_config.update(**kwargs) - # Related to #40039: prior to this PR, models with sliding window attention were forced to have # `cache_implementation="hybrid"` (the static sliding window cache). For these models, we now want to use - # the dynamic sliding window cache by default, so we UNSET `cache_implementation` if it is a default value. - # (if we're inside this branch, then it is because we're using default values from the Hub) - if generation_config.cache_implementation == "hybrid" and "cache_implementation" not in kwargs: + # the dynamic sliding window cache by default, so we UNSET `cache_implementation` if it is a default value + # from the Hub. This must happen before applying user kwargs, so that explicit `cache_implementation` + # passed by the user is still respected. + if not generation_config_provided and generation_config.cache_implementation == "hybrid": generation_config.cache_implementation = None + # Finally, if there are any kwargs, update config with it -> highest priority at the end + model_kwargs = generation_config.update(**kwargs) + # It doesn't make sense to allow kwargs and `generation_config`, that should be mutually exclusive if generation_config_provided and set(kwargs.keys()) - set(model_kwargs.keys()): generation_kwargs = set(kwargs.keys()) - set(model_kwargs.keys())