diff --git a/unsloth/__init__.py b/unsloth/__init__.py index b068d6a5fc..1c168d7a72 100644 --- a/unsloth/__init__.py +++ b/unsloth/__init__.py @@ -203,10 +203,14 @@ if DEVICE_TYPE == "cuda": del major_version, minor_version elif DEVICE_TYPE == "hip": SUPPORTS_BFLOAT16 = torch.cuda.is_bf16_supported() + def is_bf16_supported(): + return SUPPORTS_BFLOAT16 elif DEVICE_TYPE == "xpu": # torch.xpu.is_bf16_supported() does not have including_emulation # set SUPPORTS_BFLOAT16 as torch.xpu.is_bf16_supported() SUPPORTS_BFLOAT16 = torch.xpu.is_bf16_supported() + def is_bf16_supported(): + return SUPPORTS_BFLOAT16 # For Gradio HF Spaces? # if "SPACE_AUTHOR_NAME" not in os.environ and "SPACE_REPO_NAME" not in os.environ: diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index 3e6dc8ac5f..15a7dd5515 100644 --- a/unsloth/models/vision.py +++ b/unsloth/models/vision.py @@ -782,6 +782,11 @@ class FastBaseModel: # attn_implementation = attn_implementation, **kwargs, ) + try: + from unsloth_zoo.temporary_patches.misc import patch_deepseek_ocr_masked_scatter + patch_deepseek_ocr_masked_scatter() + except Exception: + pass if hasattr(model, "generate"): model.fast_generate = make_fast_generate_wrapper(model.generate) model.fast_generate_batches = error_out_no_vllm diff --git a/unsloth/save.py b/unsloth/save.py index fc3b7b8771..11e70a5dee 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -1996,7 +1996,15 @@ def unsloth_save_pretrained_gguf( is_gpt_oss = is_gpt_oss, # Pass gpt_oss Flag ) except Exception as e: - if IS_KAGGLE_ENVIRONMENT: + if os.environ.get("UNSLOTH_GGUF_OFFLINE", "0") == "1": + print( + "Unsloth: GGUF conversion skipped due to offline mode. " + f"Reason: {e}" + ) + all_file_locations = [] + want_full_precision = None + is_vlm_update = False + elif IS_KAGGLE_ENVIRONMENT: raise RuntimeError( f"Unsloth: GGUF conversion failed in Kaggle environment.\n" f"This is likely due to the 20GB disk space limit.\n" @@ -2010,6 +2018,17 @@ def unsloth_save_pretrained_gguf( gguf_directory = f"{save_directory}_gguf" modelfile_location = None ollama_success = False + if not all_file_locations: + # Offline or failed GGUF conversion: return early to avoid index errors + return { + "save_directory": save_directory, + "gguf_directory": gguf_directory, + "gguf_files": all_file_locations, + "modelfile_location": modelfile_location, + "want_full_precision": want_full_precision, + "is_vlm": is_vlm_update, + "fix_bos_token": fix_bos_token, + } if all_file_locations: try: if is_vlm_update: