Use device-aware bf16 check so AMD/Intel are unaffected

The auto mixed-precision branch now gates bf16 on unsloth_zoo's
device_is_bf16_supported() (CUDA/XPU/HIP) instead of torch.cuda.is_bf16_supported(),
which is only patched on CUDA. This keeps V100/T4 on fp16 while leaving AMD (HIP)
and Intel (XPU) behavior unchanged. Falls back to the torch call on older
unsloth_zoo.
This commit is contained in:
danielhanchen 2026-05-31 04:25:46 +00:00
commit 690185abe1
2 changed files with 10 additions and 1 deletions

View file

@ -58,8 +58,11 @@ def _decide(
uz = types.ModuleType("unsloth_zoo")
uzu = types.ModuleType("unsloth_zoo.utils")
uzu._get_dtype = lambda x: x
uzd = types.ModuleType("unsloth_zoo.device_type")
uzd.device_is_bf16_supported = lambda: bf16_supported # device-aware signal stub
sys.modules.setdefault("unsloth_zoo", uz)
sys.modules["unsloth_zoo.utils"] = uzu
sys.modules["unsloth_zoo.device_type"] = uzd
for k in (
"UNSLOTH_FORCE_FLOAT32",
"UNSLOTH_ENABLE_FULL_FINETUNING",