Skip to content

Commit bfad39b

Browse files
authored
Handle transformers rename from PretrainedConfig to PreTrainedConfig (#3445)
1 parent 45d0ff5 commit bfad39b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

unsloth/models/_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,12 @@ def patch_mistral_nemo_config(config):
432432
except:
433433
pass
434434
from transformers import __version__ as transformers_version
435-
from transformers import PretrainedConfig
435+
436+
try:
437+
from transformers import PreTrainedConfig
438+
except:
439+
from transformers import PretrainedConfig
440+
436441
model_architectures = ["llama", "mistral", "gemma", "gemma2", "qwen2", "granite", "qwen3", "qwen3_moe", "falcon_h1"]
437442

438443
for model_name in model_architectures:

unsloth/models/vision.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@
9292
"gpt_oss",
9393
]
9494

95-
from transformers import GenerationConfig, CompileConfig, HybridCache, AutoConfig, PretrainedConfig
95+
from transformers import GenerationConfig, CompileConfig, HybridCache, AutoConfig
96+
try:
97+
from transformers import PreTrainedConfig
98+
PretrainedConfig = PreTrainedConfig
99+
except:
100+
from transformers import PretrainedConfig
101+
96102
HAS_TORCH_DTYPE = "torch_dtype" in PretrainedConfig.__doc__
97103

98104
from transformers import GenerationConfig, CompileConfig, HybridCache

0 commit comments

Comments
 (0)