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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Silence torch._check_is_size FutureWarning and shim it if torch removes it (#7023)
Daniel Hanb509d47dd742
diff --git a/unsloth/_gpu_init.py b/unsloth/_gpu_init.pyindex e6178e60f38..984057e9f7e 100644--- a/unsloth/_gpu_init.py+++ b/unsloth/_gpu_init.py@@ -26,6 +26,7 @@ already_imported = [mod for mod in critical_modules if mod in sys.modules]# Fix some issues before importing other packagesfrom .import_fixes import (fix_message_factory_issue,+ fix_torch_check_is_size,check_fbgemm_gpu_version,disable_broken_causal_conv1d,disable_broken_vllm,@@ -72,6 +73,7 @@ fix_bitsandbytes_rocm_arch_detection()disable_broken_causal_conv1d()disable_broken_vllm()fix_message_factory_issue()+fix_torch_check_is_size()check_fbgemm_gpu_version()torchvision_compatibility_check()fix_diffusers_warnings()@@ -81,6 +83,7 @@ del fix_bitsandbytes_rocm_arch_detectiondel disable_broken_causal_conv1ddel disable_broken_vllmdel fix_message_factory_issue+del fix_torch_check_is_sizedel check_fbgemm_gpu_versiondel torchvision_compatibility_checkdel fix_diffusers_warningsdiff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.pyindex c5300ed4d0a..09de248c7b8 100644--- a/unsloth/import_fixes.py+++ b/unsloth/import_fixes.py@@ -172,6 +172,10 @@ if not UNSLOTH_ENABLE_LOGGING:# Deprecation warnings from torchaowarnings.filterwarnings("ignore", message = "`int4_weight_only` is deprecated")warnings.filterwarnings("ignore", message = "`int8_weight_only` is deprecated")+ # torch._check_is_size FutureWarning (called by bitsandbytes 4-bit dequant)+ warnings.filterwarnings(+ "ignore", message = r"_check_is_size will be removed", category = FutureWarning+ )# TorchAO deprecated import paths (https://github.com/pytorch/ao/issues/2752)warnings.filterwarnings(@@ -253,6 +257,30 @@ if not UNSLOTH_ENABLE_LOGGING:)+def fix_torch_check_is_size():+ """Shim torch._check_is_size if a future torch removes it (bitsandbytes 4-bit+ dequant calls it). The FutureWarning is silenced in suppress_cuda_printf."""+ try:+ import torch++ if hasattr(torch, "_check_is_size"):+ return++ def _check_is_size(+ i,+ message = None,+ *,+ max = None,+ ):+ torch._check(i >= 0, message)+ if max is not None:+ torch._check(i <= max, message)++ torch._check_is_size = _check_is_size+ except Exception:+ return++# Fix up AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'# MUST do this at the start primarily due to tensorflow causing issuesdef fix_message_factory_issue():