diff --git a/src/transformers/generation/utils.py b/src/transformers/generation/utils.py index 87293e622513..2f0f17633007 100644 --- a/src/transformers/generation/utils.py +++ b/src/transformers/generation/utils.py @@ -2403,7 +2403,12 @@ def typeerror(): should_convert_cache = True if should_convert_cache: result.past_key_values = result.past_key_values.to_legacy_cache() - if self.config.no_token_latency: + no_token_latency = ( + self.config.no_token_latency + if hasattr(self.config, "no_token_latency") + else False + ) + if no_token_latency: return result else: return result, latency_list