Bug Fixes (#2197)
* Update loader.py * model names * Gemma 3 chat template * Bug fixes * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update llama.py * Update llama.py * Update rl.py * Update chat_templates.py * Update chat_templates.py * Update vision.py * Update vision.py * Update vision.py * Update loader.py * Update vision.py * Update vision.py * Revert * Update _utils.py * forced precision * Autocast * Update vision.py * Update vision.py * Update rl.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl.py * vLLM fixes * constexpr * Update vision.py * Update vision.py * Update vision.py * Update rl.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py * Update save.py * New models * Triton windows update (#1976) * Update pyproject.toml * Update README.md * Update RMS LayerNorm implementation, and list compr. change in chat templates (#1974) * Update RMS LayerNorm implementation with optimizations and testing suite * perf: optimize list comprehension in get_ollama_eos_tokens * Update Zoo * Update llama.py * Update llama.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl_replacements.py * Update vision.py * grpo fix * Update rl_replacements.py * Update vision.py * Update rl_replacements.py * Update vision.py * Update mapper.py * Update vision.py * Update vision.py * Update loader.py * Update vision.py * Update save.py * Update save.py * Update save.py * Update rl.py * Update _utils.py * Version * Update pyproject.toml * Update llama.py * Update llama.py * bug fix #2008 (#2039) * fix (#2051) * Update loader.py * Update pyproject.toml * Update pyproject.toml * Update vision.py * more prints * Update loader.py * LoRA 16bit fix * Update vision.py * Update vision.py * Update _utils.py * Update vision.py * move forced float32 * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py * move print * Update _utils.py * disable bfloat16 * Fix forced float32 * move float32 * Ensure trust_remote_code propegates down to unsloth_compile_transformers (#2075) * Update _utils.py * Show both `peft_error` and `autoconfig_error`, not just `autoconfig_error` (#2080) When loading a PEFT model fails, only the `autoconfig_error` is shown. Instead of the `peft_error`, which is what really matters when we're trying to load a PEFT adapter, the user will see something like this: ``` RuntimeError: Unrecognized model in my_model. Should have a `model_type` key in its config.json, or contain one of the following strings in its name: albert, align, altclip, ... ``` This PR just changes it so `autoconfig_error` and `peft_error` are both displayed. * fix error message (#2046) * Update vision.py * Update _utils.py * Update pyproject.toml * Update __init__.py * Update __init__.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl_replacements.py * Update rl_replacements.py * Update rl_replacements.py * Update rl_replacements.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl_replacements.py * Update vision.py * Update rl_replacements.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Remove double generate patch * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update mapper.py * Update vision.py * fix: config.torch_dtype in LlamaModel_fast_forward_inference (#2091) * fix: config.torch_dtype in LlamaModel_fast_forward_inference * Update llama.py * update for consistency --------- Co-authored-by: Daniel Han <danielhanchen@gmail.com> * versioning * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * model_type_arch * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update loader.py * check * Update _utils.py * Update loader.py * Update loader.py * Remove prints * Update _utils.py * Update _utils.py * versioning * Update _utils.py * Update _utils.py * Update _utils.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update vision.py * HF Transfer * fix(utils): add missing importlib import to fix NameError (#2134) This commit fixes a NameError that occurs when `importlib` is referenced in _utils.py without being imported, especially when UNSLOTH_USE_MODELSCOPE=1 is enabled. By adding the missing import statement, the code will no longer throw a NameError. * Add QLoRA Train and Merge16bit Test (#2130) * add reference and unsloth lora merging tests * add test / dataset printing to test scripts * allow running tests from repo root * add qlora test readme * more readme edits * ruff formatting * additional readme comments * forgot to add actual tests * add apache license * Update pyproject.toml * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update loader.py * Update loader.py * Revert * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Bug fix * Update mapper.py * check SDPA for Mistral 3, Pixtral * Update vision.py * Versioning * Update rl_replacements.py --------- Co-authored-by: Akshay Behl <126911424+Captain-T2004@users.noreply.github.com> Co-authored-by: Nino Risteski <95188570+NinoRisteski@users.noreply.github.com> Co-authored-by: Mukkesh Ganesh <mukmckenzie@gmail.com> Co-authored-by: Kareem <81531392+KareemMusleh@users.noreply.github.com> Co-authored-by: Xander Hawthorne <167850078+CuppaXanax@users.noreply.github.com> Co-authored-by: Isaac Breen <isaac.breen@icloud.com> Co-authored-by: lurf21 <93976703+lurf21@users.noreply.github.com> Co-authored-by: naliazheli <nalia0316@gmail.com> Co-authored-by: jeromeku <jerome.ku@gmail.com>
This commit is contained in:
parent
31c4a78945
commit
bc790cc624
8 changed files with 53 additions and 38 deletions
|
|
@ -37,7 +37,7 @@ triton = [
|
|||
]
|
||||
|
||||
huggingface = [
|
||||
"unsloth_zoo>=2025.3.16",
|
||||
"unsloth_zoo>=2025.3.17",
|
||||
"packaging",
|
||||
"tyro",
|
||||
"transformers>=4.46.1,!=4.47.0",
|
||||
|
|
@ -351,7 +351,7 @@ colab-ampere-torch220 = [
|
|||
"flash-attn>=2.6.3",
|
||||
]
|
||||
colab-new = [
|
||||
"unsloth_zoo>=2025.3.16",
|
||||
"unsloth_zoo>=2025.3.17",
|
||||
"packaging",
|
||||
"tyro",
|
||||
"transformers>=4.46.1,!=4.47.0",
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ pass
|
|||
# Check for unsloth_zoo
|
||||
try:
|
||||
unsloth_zoo_version = importlib_version("unsloth_zoo")
|
||||
if Version(unsloth_zoo_version) < Version("2025.3.16"):
|
||||
if Version(unsloth_zoo_version) < Version("2025.3.17"):
|
||||
print(
|
||||
"Unsloth: Updating Unsloth-Zoo utilies to the latest version.\n"\
|
||||
"To disable this, set `os.environ['UNSLOTH_DISABLE_AUTO_UPDATES'] = '1'`"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
__version__ = "2025.3.18"
|
||||
__version__ = "2025.3.19"
|
||||
|
||||
__all__ = [
|
||||
"SUPPORTS_BFLOAT16",
|
||||
|
|
@ -1176,9 +1176,10 @@ def unsloth_compile_transformers(
|
|||
"so turning off some optimizations!"
|
||||
)
|
||||
return
|
||||
if disable: return
|
||||
|
||||
model_types = list(dict().fromkeys(model_types).keys())
|
||||
if disable: return model_types, False
|
||||
|
||||
supports_sdpa = [True]
|
||||
for model_type in model_types:
|
||||
_unsloth_compile_transformers(
|
||||
model_type,
|
||||
|
|
@ -1206,12 +1207,13 @@ def unsloth_compile_transformers(
|
|||
import_from_cache = import_from_cache,
|
||||
disable = disable,
|
||||
return_logits = return_logits,
|
||||
supports_sdpa = supports_sdpa,
|
||||
)
|
||||
pass
|
||||
# Redo patches which override compiler
|
||||
for temporary_patch in TEMPORARY_PATCHES:
|
||||
temporary_patch()
|
||||
return model_types
|
||||
return model_types, supports_sdpa[0]
|
||||
pass
|
||||
|
||||
# We need an empty logits flag to warn people logits will not be returned anymore unless asked ie
|
||||
|
|
|
|||
|
|
@ -2024,6 +2024,14 @@ class FastLlamaModel:
|
|||
**kwargs,
|
||||
):
|
||||
if os.environ.get("UNSLOTH_USE_NEW_MODEL", "0") == "1":
|
||||
# Check for other PEFT args in kwargs
|
||||
for (peft_arg, flag) in (
|
||||
("finetune_vision_layers", False),
|
||||
("finetune_language_layers", True),
|
||||
("finetune_attention_modules", True),
|
||||
("finetune_mlp_modules", True),
|
||||
):
|
||||
if peft_arg not in kwargs: kwargs[peft_arg] = flag
|
||||
return FastBaseModel.get_peft_model(
|
||||
model = model,
|
||||
r = r,
|
||||
|
|
@ -2031,10 +2039,6 @@ class FastLlamaModel:
|
|||
lora_alpha = lora_alpha,
|
||||
lora_dropout = lora_dropout,
|
||||
bias = bias,
|
||||
finetune_vision_layers = False,
|
||||
finetune_language_layers = True,
|
||||
finetune_attention_modules = True,
|
||||
finetune_mlp_modules = True,
|
||||
layers_to_transform = layers_to_transform,
|
||||
layers_pattern = layers_pattern,
|
||||
use_gradient_checkpointing = use_gradient_checkpointing,
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ class FastModel(FastBaseModel):
|
|||
|
||||
with redirector:
|
||||
patch_loss_functions(torch_compile = False)
|
||||
model_types = unsloth_compile_transformers(
|
||||
model_types, supports_sdpa = unsloth_compile_transformers(
|
||||
dtype = dtype,
|
||||
model_name = model_name,
|
||||
model_types = model_types,
|
||||
|
|
@ -726,6 +726,7 @@ class FastModel(FastBaseModel):
|
|||
tokenizer_name = tokenizer_name,
|
||||
auto_model = auto_model,
|
||||
use_gradient_checkpointing = use_gradient_checkpointing,
|
||||
supports_sdpa = supports_sdpa,
|
||||
*args, **kwargs,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -728,6 +728,16 @@ __INT_TO_FLOAT_MAPPER = \
|
|||
"mistralai/Mistral-Small-3.1-24B-Base-2503",
|
||||
"unsloth/Mistral-Small-3.1-24B-Base-2503-bnb-4bit",
|
||||
),
|
||||
"unsloth/orpheus-3b-0.1-pretrained-unsloth-bnb-4bit" : (
|
||||
"unsloth/orpheus-3b-0.1-pretrained",
|
||||
"canopylabs/orpheus-3b-0.1-pretrained",
|
||||
"unsloth/orpheus-3b-0.1-pretrained-bnb-4bit",
|
||||
),
|
||||
"unsloth/orpheus-3b-0.1-ft-unsloth-bnb-4bit" : (
|
||||
"unsloth/orpheus-3b-0.1-ft",
|
||||
"canopylabs/orpheus-3b-0.1-ft",
|
||||
"unsloth/orpheus-3b-0.1-ft-bnb-4bit",
|
||||
),
|
||||
}
|
||||
|
||||
INT_TO_FLOAT_MAPPER = {}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def sft_trainer_prepare_dataset(function_name, function):
|
|||
function_name != "_prepare_dataset": return function
|
||||
|
||||
fast_sft_prepare_dataset = RL_REPLACEMENTS.get("sft_prepare_dataset", None)
|
||||
if fast_sft_prepare_dataset is not None and "pack_examples" in function:
|
||||
if fast_sft_prepare_dataset is not None:
|
||||
params = inspect.signature(fast_sft_prepare_dataset).parameters.keys()
|
||||
params = ".*?".join(params)
|
||||
matched = re.match(
|
||||
|
|
|
|||
|
|
@ -66,11 +66,6 @@ __all__ = [
|
|||
"FastBaseModel",
|
||||
]
|
||||
|
||||
global FORCE_EAGER_ATTENTION
|
||||
FORCE_EAGER_ATTENTION = [
|
||||
"pixtral", # Pixtral SDPA not implemented
|
||||
]
|
||||
|
||||
global NUM_LOGITS_TO_KEEP
|
||||
NUM_LOGITS_TO_KEEP = dict()
|
||||
global PROMPT_LOOPKUP
|
||||
|
|
@ -145,8 +140,11 @@ def unsloth_base_fast_generate(
|
|||
kwargs[key] = 1
|
||||
global PROMPT_LOOPKUP
|
||||
if arch not in PROMPT_LOOPKUP:
|
||||
PROMPT_LOOPKUP[arch] = True
|
||||
|
||||
# Only works for VLMs and not LLMs!
|
||||
if is_vlm:
|
||||
PROMPT_LOOPKUP[arch] = False
|
||||
else:
|
||||
PROMPT_LOOPKUP[arch] = True
|
||||
if bsz == 1 and PROMPT_LOOPKUP[arch]:
|
||||
kwargs["prompt_lookup_num_tokens"] = 3
|
||||
|
||||
|
|
@ -237,8 +235,14 @@ class FastBaseModel:
|
|||
tokenizer_name = None,
|
||||
auto_model = AutoModelForVision2Seq,
|
||||
use_gradient_checkpointing = "unsloth",
|
||||
supports_sdpa = True,
|
||||
**kwargs,
|
||||
):
|
||||
if model_types is None:
|
||||
raise RuntimeError(
|
||||
"Unsloth: Please use FastModel or FastVisionModel and not use FastBaseModel directly!"
|
||||
)
|
||||
|
||||
os.environ["UNSLOTH_USE_NEW_MODEL"] = "1"
|
||||
if trust_remote_code:
|
||||
print(
|
||||
|
|
@ -299,16 +303,11 @@ class FastBaseModel:
|
|||
bnb_compute_dtype = torch.float16
|
||||
do_forced_float32 = True
|
||||
pass
|
||||
|
||||
global FORCE_EAGER_ATTENTION
|
||||
attn_implementation = "sdpa"
|
||||
for disable_name in FORCE_EAGER_ATTENTION:
|
||||
if (disable_name.lower() == model_type_arch.lower() or \
|
||||
disable_name.lower() in model_name.lower()):
|
||||
|
||||
print(f"Unsloth: {model_type_arch} does not support SDPA - switching to eager!")
|
||||
attn_implementation = "eager"
|
||||
break
|
||||
# Stop SDPA for some archs like Pixtral / Mistral3
|
||||
kwargs["attn_implementation"] = "sdpa"
|
||||
if not supports_sdpa:
|
||||
print(f"Unsloth: {model_type_arch.title()} does not support SDPA - switching to eager!")
|
||||
del kwargs["attn_implementation"]
|
||||
pass
|
||||
|
||||
bnb_config = None
|
||||
|
|
@ -347,8 +346,6 @@ class FastBaseModel:
|
|||
os.environ["UNSLOTH_ENABLE_FULL_FINETUNING"] = "0"
|
||||
pass
|
||||
|
||||
kwargs.pop("attn_implementation", None); # No need since we auto call it
|
||||
|
||||
# Cannot be None, since HF now checks for the config
|
||||
if load_in_4bit: kwargs["quantization_config"] = bnb_config
|
||||
|
||||
|
|
@ -362,7 +359,7 @@ class FastBaseModel:
|
|||
# quantization_config = bnb_config,
|
||||
token = token,
|
||||
trust_remote_code = trust_remote_code,
|
||||
attn_implementation = attn_implementation,
|
||||
# attn_implementation = attn_implementation,
|
||||
**kwargs,
|
||||
)
|
||||
# Return old flag
|
||||
|
|
@ -431,11 +428,12 @@ class FastBaseModel:
|
|||
m.is_loaded_in_8bit = True if not full_finetuning else False
|
||||
|
||||
# Patch generate
|
||||
if model.generate.__name__ != "unsloth_base_fast_generate":
|
||||
model._old_generate = model.generate
|
||||
unsloth_base_fast_generate.__doc__ = model._old_generate.__doc__
|
||||
model.generate = types.MethodType(unsloth_base_fast_generate, model)
|
||||
|
||||
if os.environ.get("UNSLOTH_DISABLE_FAST_GENERATION", "0") == "0":
|
||||
if model.generate.__name__ != "unsloth_base_fast_generate":
|
||||
model._old_generate = model.generate
|
||||
unsloth_base_fast_generate.__doc__ = model._old_generate.__doc__
|
||||
model.generate = types.MethodType(unsloth_base_fast_generate, model)
|
||||
pass
|
||||
# Post patches
|
||||
model = FastBaseModel.post_patch_model(
|
||||
model,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue