Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Update _utils.py

Daniel Han63e3a85efb18
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index af7e1eb293f..309c0d913e2 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
# =============================================
# =============================================