From 0ac7d7135f80175054fc25e5353e553f9eb89bff Mon Sep 17 00:00:00 2001 From: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:48:33 +0200 Subject: [PATCH] Fix for None layer_types --- 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 d07cf05b1ed7..0ee06a3dd389 100644 --- a/src/transformers/generation/utils.py +++ b/src/transformers/generation/utils.py @@ -1852,7 +1852,7 @@ def _prepare_cache_for_generation( # linear attention models always need to pass the config, otherwise it will use an Attention cache for the LinearAttention layers is_linear_attention = any( x in ("mamba", "conv", "linear_attention") - for x in getattr(self.config.get_text_config(decoder=True), "layer_types", []) + for x in (getattr(self.config.get_text_config(decoder=True), "layer_types", []) or []) ) if generation_config.cache_implementation != "dynamic_full" or is_linear_attention: dynamic_cache_kwargs["config"] = self.config.get_text_config(decoder=True)