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.

Fix `is_bfloat16_supported` missing (#510)

Daniel Han289b7fcca5ed
diff --git a/unsloth/__init__.py b/unsloth/__init__.py
index 2dcf1e6a437..c8f4ca10411 100644
--- a/unsloth/__init__.py
+++ b/unsloth/__init__.py
@@ -41,6 +41,13 @@ try:
except:
raise ImportError("Pytorch is not installed. Go to https://pytorch.org/.\n"\
"We have some installation instructions on our Github page.")
+pass
+
+# Fix up is_bf16_supported https://github.com/unslothai/unsloth/issues/504
+major_version, minor_version = torch.cuda.get_device_capability()
+SUPPORTS_BFLOAT16 = (major_version >= 8)
+def is_bf16_supported(): return SUPPORTS_BFLOAT16
+torch.cuda.is_bf16_supported = is_bf16_supported
# We support Pytorch 2
# Fixes https://github.com/unslothai/unsloth/issues/38
diff --git a/unsloth/trainer.py b/unsloth/trainer.py
index b234a98d8bf..c8e00be2312 100644
--- a/unsloth/trainer.py
+++ b/unsloth/trainer.py
@@ -16,6 +16,7 @@ from dataclasses import dataclass, field
from typing import Optional
from transformers import TrainingArguments
from trl import SFTTrainer
+from . import is_bfloat16_supported
__all__ = [
"UnslothTrainingArguments",