From f00eaf1b09620528e362eb3a828699d0c2a65fc4 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Sep 2024 22:56:41 -0700 Subject: [PATCH] Update _utils.py --- unsloth/models/_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index af7e1eb293..309c0d913e 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -306,6 +306,14 @@ if Version(xformers_version) >= Version("0.0.27"): accelerate_new_send_to_device = _fixed_send_to_device pass pass + +# Transformers 4.46 breaks dynamic caching. This is a hack +import transformers.generation.configuration_utils +if hasattr(transformers.generation.configuration_utils, "ALL_CACHE_IMPLEMENTATIONS"): + if type(transformers.generation.configuration_utils.ALL_CACHE_IMPLEMENTATIONS) is list: + transformers.generation.configuration_utils.ALL_CACHE_IMPLEMENTATIONS.append("dynamic") + pass +pass # ============================================= # =============================================