ROCm notebook stability: deepseek OCR hook + offline GGUF guard

This commit is contained in:
Daniel Han-Chen 2026-02-11 12:13:50 +00:00
commit fb02399719
3 changed files with 29 additions and 1 deletions

View file

@ -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:

View file

@ -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

View file

@ -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: