unsloth 2026.11.7
legitimate ML training framework
“2-5X faster training, reinforcement learning & finetuning”
Agent skill executes caller supplied PythonRemote native stage fails open on manifest errors
SHA-25694b0ccb7a602aae49da9cb6302dfda263bf78fed8e0b9c956ec4b89020202a79
Evidence
1# Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5# http://www.apache.org/licenses/LICENSE-2.0
6# Unless required by applicable law or agreed to in writing, software
7# distributed under th …
9:19… for the specific language governing permissions and
10# limitations under the License.
11
12# Defensive imports: added in unsloth-zoo PR #526 and may not exist on older versions.
13from unsloth_zoo.utils import Version
14from importlib.metadata import version as importlib_version
15from unsloth_zoo.hf_utils import dtype_from_config, HAS_TORCH_DTYPE
16from contextlib import contextmanager, nullcontext
17from unsloth_zoo.llama_cpp import (
18 convert_to_gguf,
19 quantize_gguf,
20 use_local_gguf,
21 install_llama_cpp,
22 check_llama_cpp,
23 _download_convert_hf_to_gguf,
24)
25
26try:
27 from unsloth_zoo.llama_cpp import LLAMA_CPP_DEFAULT_DIR, IS_WINDOWS
28except ImportError:
29 import sys
30 IS_WINDOWS = sys.platform == "win32"
31 LLAMA_CPP_DEFAULT_DIR = "llama.cpp"
32# Without bnb, peft stops exporting its 4bit …
32:123… ng can match are exact stand-ins.
33try:
34 from bitsandbytes.nn import Linear4bit as Bnb_Linear4bit
35 from peft.tuners.lora import Linear4bit as Peft_Linear4bit
36except Exception:
37
⋯5 lines
43
44
45from peft.tuners.lora import Linear as Peft_Linear
46from typing import Optional, Callable, Union, List
47import sys
48import math
49import requests
50import torch
51import os
52import json
53import shutil
54import pickle
55import gc
56import contextvars
57import functools
58from transformers.models.llama.modeling_llama import logger
59from .kernels import fast_dequantize, QUANT_STATE, get_lora_parameters_bias
60import subprocess
61import traceback
62import psutil
63import re
64from .models.loader_utils import (
65 get_model_name,
66 sync_load_when_quantizing,
67 _resolve_hub_repo_cached_file,
68 _tokenizer_cache_dir,
69 _tokenizer_revision,
70 _tokenizer_wants_local_only,
71)
72from .models._utils import (
73 _is_unsloth_pipeline_parallel,
74 _is_unsloth_tensor_parallel,
75 _refuse_model_parallel_export,
76 _convert_torchao_model,
77 _merged_torchao_config_for_peft_qat,
78 _peft_untied_lm_head,
79 _strip_torchao_fake_quantization,
142:113… laptop, and the branches below (/tmp save paths, deleting the cached base model) are all wrong there.
143from .disk_utils import (
144 KAGGLE_TMP,
145 is_colab_environment,
146 is_kaggle_environment,
147 estimate_gguf_export_bytes,
148 free_bytes,
149 kaggle_tmp_redirect,
150 logical_numel,
151 model_16bit_bytes,
152)
153
154IS_COLAB_ENVIRONMENT = is_colab_environment()
155IS_KAGGLE_ENVIRONMENT = is_kaggle_environment()
156
157LLAMA_WEIGHTS = (
⋯5 lines
888:61… = mapping, namespaces = namespaces)
889 import types
890
891 finder_module = types.ModuleType(module)
892 exec(compile(code, "<" + module + ">", "exec"), finder_module.__dict__)
893 finder = finder_module._EditableFinder
894 if finder_file:
895 # Retired once its finder file is gone (the editable was …
Showing the top 5 files — 4 more files (519 regions) not shown.
No evidence locations were recorded for this file. Raw result