Bug fixes
This commit is contained in:
parent
810171d82c
commit
e88cb620ab
5 changed files with 43 additions and 34 deletions
|
|
@ -57,25 +57,14 @@ os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
|||
# Log Unsloth is being used
|
||||
os.environ["UNSLOTH_IS_PRESENT"] = "1"
|
||||
|
||||
# Try importing PyTorch and check version
|
||||
try:
|
||||
import torch
|
||||
except ModuleNotFoundError:
|
||||
raise ImportError(
|
||||
"Unsloth: Pytorch is not installed. Go to https://pytorch.org/.\n"\
|
||||
"We have some installation instructions on our Github page."
|
||||
)
|
||||
except Exception as exception:
|
||||
raise exception
|
||||
pass
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from importlib.metadata import version as importlib_version
|
||||
from importlib.metadata import PackageNotFoundError
|
||||
# Check for unsloth_zoo
|
||||
try:
|
||||
unsloth_zoo_version = importlib_version("unsloth_zoo")
|
||||
if Version(unsloth_zoo_version) < Version("2025.10.12"):
|
||||
if Version(unsloth_zoo_version) < Version("2025.10.13"):
|
||||
print(
|
||||
"Unsloth: Please update Unsloth and Unsloth-Zoo to the latest version!\n"\
|
||||
"Do this via `pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo`"
|
||||
|
|
@ -89,10 +78,22 @@ try:
|
|||
# except:
|
||||
# raise ImportError("Unsloth: Please update unsloth_zoo via `pip install --upgrade --no-cache-dir --no-deps unsloth_zoo`")
|
||||
import unsloth_zoo
|
||||
except NotImplementedError as e:
|
||||
raise NotImplementedError(str(e))
|
||||
except Exception as e:
|
||||
raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` Also error = {str(e)}")
|
||||
except PackageNotFoundError:
|
||||
raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!")
|
||||
except:
|
||||
raise
|
||||
pass
|
||||
|
||||
# Try importing PyTorch and check version
|
||||
try:
|
||||
import torch
|
||||
except ModuleNotFoundError:
|
||||
raise ImportError(
|
||||
"Unsloth: Pytorch is not installed. Go to https://pytorch.org/.\n"\
|
||||
"We have some installation instructions on our Github page."
|
||||
)
|
||||
except Exception as exception:
|
||||
raise exception
|
||||
pass
|
||||
|
||||
from unsloth_zoo.device_type import (
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ def ignore_logger_messages():
|
|||
pass
|
||||
|
||||
def patch_ipykernel_hf_xet():
|
||||
# HF-XET == 1.1.10 and ipykernel == 7.0.0 causes issues
|
||||
# HF-XET == 1.1.10 and ipykernel == 7.0.0 / 7.0.1 causes issues
|
||||
# See https://github.com/huggingface/xet-core/issues/526
|
||||
# 2025-10-13T20:37:33.028737Z ERROR Python exception updating progress:, error: PyErr { type: <class 'LookupError'>, value: LookupError(<ContextVar name='shell_parent' at 0x7535b4cebd80>), traceback: Some(<traceback object at 0x753408489f40>) }, caller: "src/progress_update.rs:313"
|
||||
# at /home/runner/work/xet-core/xet-core/error_printer/src/lib.rs:28
|
||||
|
|
@ -150,12 +150,11 @@ def patch_ipykernel_hf_xet():
|
|||
Version(importlib_version("hf_xet")) == Version("1.1.10")
|
||||
) and (
|
||||
(ipykernel_version == Version("7.0.0")) or \
|
||||
(ipykernel_version == Version("7.0.1")) or \ # 7.0.1 seems to also break with LookupError: <ContextVar name='shell_parent' at 0x7a9775143ec0>
|
||||
(ipykernel_version >= Version("7.0.2"))
|
||||
(ipykernel_version == Version("7.0.1")) # 7.0.1 seems to also break with LookupError: <ContextVar name='shell_parent' at 0x7a9775143ec0>
|
||||
):
|
||||
print(
|
||||
"#### Unsloth: `hf_xet==1.1.10` and `ipykernel>=7.0.0` breaks progress bars. Using ASCII progress bars.\n"\
|
||||
"#### Unsloth: To re-enable progress bars, please downgrade to `ipykernel<7.0.0` or wait for a fix to\n"\
|
||||
"#### Unsloth: `hf_xet==1.1.10` and `ipykernel==7.0.0` or `ipykernel==7.0.1` breaks progress bars. Using ASCII progress bars.\n"\
|
||||
"#### Unsloth: To re-enable progress bars, please upgrade to `ipykernel>=7.1.0` or wait for a fix to\n"\
|
||||
"https://github.com/huggingface/xet-core/issues/526"
|
||||
)
|
||||
# from huggingface_hub.utils import disable_progress_bars
|
||||
|
|
@ -168,7 +167,6 @@ def patch_ipykernel_hf_xet():
|
|||
_tauto.trange = _tstd.trange
|
||||
_tnb.tqdm = _tstd.tqdm
|
||||
_tnb.trange = _tstd.trange
|
||||
pass
|
||||
pass
|
||||
|
||||
def patch_trackio():
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
__version__ = "2025.10.11"
|
||||
__version__ = "2025.10.12"
|
||||
|
||||
__all__ = [
|
||||
"SUPPORTS_BFLOAT16",
|
||||
|
|
@ -975,12 +975,12 @@ def _get_statistics(statistics = None, force_download = True):
|
|||
from huggingface_hub import snapshot_download
|
||||
from unsloth_zoo.rl_environments import execute_with_time_limit
|
||||
if has_internet():
|
||||
@execute_with_time_limit(120)
|
||||
def stats_check():
|
||||
with tempfile.TemporaryDirectory(ignore_cleanup_errors = True) as f:
|
||||
snapshot_download(f"unslothai/{statistics}", force_download = True, cache_dir = f, local_dir = f)
|
||||
time_limited_stats_check = execute_with_time_limit(120)(stats_check)
|
||||
try:
|
||||
stats_check()
|
||||
time_limited_stats_check()
|
||||
except TimeoutError:
|
||||
raise TimeoutError(
|
||||
"Unsloth: HuggingFace seems to be down after trying for 120 seconds :(\n"\
|
||||
|
|
@ -993,6 +993,9 @@ def _get_statistics(statistics = None, force_download = True):
|
|||
"model = FastLanguageModel.from_pretrained('unsloth/gpt-oss-20b')\n"\
|
||||
"```"
|
||||
)
|
||||
except:
|
||||
# Try no time limit check
|
||||
stats_check()
|
||||
pass
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ class FastLanguageModel(FastLlamaModel):
|
|||
revision = None,
|
||||
use_exact_model_name = False,
|
||||
offload_embedding = False,
|
||||
float32_mixed_precision = None, # Forces float32 mixed precision
|
||||
|
||||
fast_inference = False, # uses vLLM
|
||||
gpu_memory_utilization = 0.5,
|
||||
|
|
@ -172,7 +173,7 @@ class FastLanguageModel(FastLlamaModel):
|
|||
fullgraph = True, # No graph breaks
|
||||
use_exact_model_name = use_exact_model_name,
|
||||
offload_embedding = offload_embedding,
|
||||
|
||||
float32_mixed_precision = float32_mixed_precision,
|
||||
# Pass vLLM/inference parameters
|
||||
fast_inference = fast_inference,
|
||||
gpu_memory_utilization = gpu_memory_utilization,
|
||||
|
|
@ -449,7 +450,7 @@ class FastLanguageModel(FastLlamaModel):
|
|||
fullgraph = True, # No graph breaks
|
||||
use_exact_model_name = use_exact_model_name,
|
||||
offload_embedding = offload_embedding,
|
||||
|
||||
float32_mixed_precision = float32_mixed_precision,
|
||||
# Pass vLLM/inference parameters
|
||||
fast_inference = fast_inference,
|
||||
gpu_memory_utilization = gpu_memory_utilization,
|
||||
|
|
@ -594,7 +595,7 @@ class FastModel(FastBaseModel):
|
|||
whisper_task = None,
|
||||
unsloth_force_compile = False,
|
||||
offload_embedding = False,
|
||||
|
||||
float32_mixed_precision = None, # Forces float32 mixed precision
|
||||
# Add the missing vLLM/inference parameters
|
||||
fast_inference = False, # uses vLLM
|
||||
gpu_memory_utilization = 0.5,
|
||||
|
|
@ -1008,7 +1009,7 @@ class FastModel(FastBaseModel):
|
|||
whisper_task = whisper_task,
|
||||
auto_config = model_config,
|
||||
offload_embedding = offload_embedding,
|
||||
|
||||
float32_mixed_precision = float32_mixed_precision,
|
||||
# Pass vLLM/inference parameters
|
||||
fast_inference = fast_inference,
|
||||
gpu_memory_utilization = gpu_memory_utilization,
|
||||
|
|
|
|||
|
|
@ -316,6 +316,7 @@ class FastBaseModel:
|
|||
whisper_task = None,
|
||||
auto_config = None,
|
||||
offload_embedding = False,
|
||||
float32_mixed_precision = None, # Forces float32 mixed precision
|
||||
# vLLM parameters
|
||||
fast_inference = False,
|
||||
gpu_memory_utilization = 0.5,
|
||||
|
|
@ -780,6 +781,7 @@ class FastBaseModel:
|
|||
trust_remote_code = trust_remote_code,
|
||||
model_type = model_type_arch,
|
||||
tokenizer = tokenizer,
|
||||
float32_mixed_precision = float32_mixed_precision,
|
||||
)
|
||||
# Clear deleted GPU items
|
||||
for _ in range(3):
|
||||
|
|
@ -940,13 +942,17 @@ class FastBaseModel:
|
|||
trust_remote_code = False,
|
||||
model_type = None,
|
||||
tokenizer = None,
|
||||
float32_mixed_precision = None,
|
||||
):
|
||||
full_finetuning = os.environ.get("UNSLOTH_ENABLE_FULL_FINETUNING", "0") == "1"
|
||||
|
||||
float32_mixed_precision = True
|
||||
if _get_dtype(dtype_from_config(model.config)) == torch.bfloat16 and full_finetuning:
|
||||
# Use bfloat16 precision for full finetuning
|
||||
float32_mixed_precision = False
|
||||
if type(float32_mixed_precision) is bool:
|
||||
# Respect whatever it was set before
|
||||
else:
|
||||
float32_mixed_precision = True
|
||||
if _get_dtype(dtype_from_config(model.config)) == torch.bfloat16 and full_finetuning:
|
||||
# Use bfloat16 precision for full finetuning
|
||||
float32_mixed_precision = False
|
||||
|
||||
model = prepare_model_for_training(
|
||||
model,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue