Skip to content

Commit e2e406e

Browse files
danielhanchentimothelaborieeltociearErland366Datta0
authored
Bug fixes (#1245)
* Fix TRL * Update mistral.py * Patch processing_class * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Installation guide (#1165) * chore: update chat_templates.py (#1166) orginal -> original * Disable Flex Attention * Update tokenizer_utils.py * Update _utils.py * n_items * Update cross_entropy_loss.py * Fix DPO, ORPO * Update _utils.py * Update _utils.py * fix/transformers-unpack (#1180) * Fix DPO, ORPO (#1177) * Fix TRL * Update mistral.py * Patch processing_class * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Update tokenizer_utils.py * Installation guide (#1165) * chore: update chat_templates.py (#1166) orginal -> original * Disable Flex Attention * Update tokenizer_utils.py * Update _utils.py * n_items * Update cross_entropy_loss.py * Fix DPO, ORPO * Update _utils.py --------- Co-authored-by: timothelaborie <97834767+timothelaborie@users.noreply.github.com> Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com> * Add warning for missing Unpack and KwargsForCausalLM in older Transformers versions --------- Co-authored-by: Daniel Han <danielhanchen@gmail.com> Co-authored-by: timothelaborie <97834767+timothelaborie@users.noreply.github.com> Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com> * Update cross_entropy_loss.py * Update _utils.py * Update _utils.py * donot upcast lm_head and embeddings to float32 (#1186) * Cleanup upcast logs (#1188) * Fix/phi-longrope (#1193) * Enhance rotary embedding handling in LlamaAttention and LongRopeRotaryEmbedding * Typo * Improve rotary embedding handling in LlamaAttention to prevent errors with short KV cache * Update llama.py * Update llama.py --------- Co-authored-by: Daniel Han <danielhanchen@gmail.com> * Update transformers * Unk token issues * Update _utils.py * Fix pad token * Update llama.py * Typo * ignored labels * Revert "ignored labels" This reverts commit 9d07be0. * More patching * Update _utils.py * Update _utils.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Feat/all tmp (#1219) * Update save.py Check whether path is in /tmp dir for Kaggle environment * Update save.py Move temporary_location to /tmp in Kaggle * Enhance Kaggle environment support in save and tokenizer utilities --------- Co-authored-by: dendarrion <37800703+dendarrion@users.noreply.github.com> Co-authored-by: Erland366 <erland.pg366@gmail.com> * Bug fixes * Update pyproject.toml * Update _utils.py * Update __init__.py * Update __init__.py * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Tied weights * Revert "Tied weights" This reverts commit 8090b7c. * Tied weights * Utils * CE Loss patching * Update __init__.py * Update __init__.py * Patching * Update cross_entropy_loss.py * CE Loss * Update _utils.py * Update _utils.py * CE Loss * Update _utils.py * Update _utils.py * Layernorm * Update _utils.py * Update _utils.py * Post patch * Update _utils.py * Update llama.py * Update _utils.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * typing * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * int64 * Update _utils.py * Update cross_entropy_loss.py * constexpr * constexpr * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update _utils.py * Update _utils.py * Update _utils.py * CE * Update cross_entropy_loss.py * Update _utils.py * Update llama.py * Update _utils.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update utils.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * Update rms_layernorm.py * typing * Update rope_embedding.py * types * Disable compiling * Update _utils.py * Update _utils.py * Forward hook * Update _utils.py * Update llama.py * Update _utils.py * Update llama.py * Update llama.py * Update _utils.py * Update pyproject.toml --------- Co-authored-by: timothelaborie <97834767+timothelaborie@users.noreply.github.com> Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com> Co-authored-by: Edd <68678137+Erland366@users.noreply.github.com> Co-authored-by: Datta Nimmaturi <datta.nimmaturi@nutanix.com> Co-authored-by: dendarrion <37800703+dendarrion@users.noreply.github.com> Co-authored-by: Erland366 <erland.pg366@gmail.com>
1 parent a2f8db3 commit e2e406e

File tree

14 files changed

+287
-727
lines changed

14 files changed

+287
-727
lines changed

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ exclude = ["images*"]
3333

3434
[project.optional-dependencies]
3535
huggingface = [
36-
"unsloth_zoo",
36+
"unsloth_zoo>=2024.11.1",
3737
"packaging",
3838
"tyro",
39-
"transformers>=4.44.2",
39+
"transformers>=4.46.1",
4040
"datasets>=2.16.0",
4141
"sentencepiece>=0.2.0",
4242
"tqdm",
@@ -244,10 +244,10 @@ colab-ampere-torch220 = [
244244
"flash-attn>=2.6.3",
245245
]
246246
colab-new = [
247-
"unsloth_zoo",
247+
"unsloth_zoo>=2024.11.1",
248248
"packaging",
249249
"tyro",
250-
"transformers>=4.44.2",
250+
"transformers>=4.46.1",
251251
"datasets>=2.16.0",
252252
"sentencepiece>=0.2.0",
253253
"tqdm",

unsloth/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
# pass
2828
# pass
2929

30-
# Check for unsloth_zoo
31-
try:
32-
import unsloth_zoo
33-
except:
34-
raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth-zoo`")
35-
pass
36-
3730
# Unsloth currently does not work on multi GPU setups - sadly we are a 2 brother team so
3831
# enabling it will require much more work, so we have to prioritize. Please understand!
3932
# We do have a beta version, which you can contact us about!
@@ -60,6 +53,14 @@
6053
# Reduce VRAM usage by reducing fragmentation
6154
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
6255

56+
# Hugging Face Hub faster downloads
57+
if "HF_HUB_ENABLE_HF_TRANSFER" not in os.environ:
58+
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
59+
pass
60+
61+
# Log Unsloth is being used
62+
os.environ["UNSLOTH_IS_PRESENT"] = "1"
63+
6364
try:
6465
import torch
6566
except ModuleNotFoundError:
@@ -71,12 +72,6 @@
7172
raise exception
7273
pass
7374

74-
# Hugging Face Hub faster downloads (only enable during Colab and Kaggle sessions)
75-
keynames = "\n" + "\n".join(os.environ.keys())
76-
if "\nCOLAB_" in keynames or "\nKAGGLE_" in keynames:
77-
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
78-
pass
79-
8075
# We support Pytorch 2
8176
# Fixes https://github.com/unslothai/unsloth/issues/38
8277
torch_version = torch.__version__.split(".")
@@ -165,6 +160,13 @@ def is_bf16_supported(): return SUPPORTS_BFLOAT16
165160
pass
166161
pass
167162

163+
# Check for unsloth_zoo
164+
try:
165+
import unsloth_zoo
166+
except:
167+
raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth-zoo`")
168+
pass
169+
168170
from .models import *
169171
from .save import *
170172
from .chat_templates import *

unsloth/kernels/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
from .cross_entropy_loss import (
1616
fast_cross_entropy_loss,
17-
patch_llama_for_causal_lm,
18-
unpatch_llama_for_causal_lm,
17+
post_patch_loss_function,
18+
patch_loss_functions,
1919
)
2020
from .rms_layernorm import (
2121
fast_rms_layernorm,
@@ -25,7 +25,6 @@
2525
from .layernorm import (
2626
fast_layernorm,
2727
patch_layernorm,
28-
unpatch_layernorm,
2928
)
3029
from .rope_embedding import fast_rope_embedding, inplace_rope_embedding
3130
from .swiglu import swiglu_fg_kernel, swiglu_DWf_DW_dfg_kernel
@@ -54,8 +53,12 @@
5453
create_flex_attention_sliding_window_mask,
5554
)
5655

57-
try:
58-
print("🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.")
59-
except:
60-
print("Unsloth: Will patch your computer to enable 2x faster free finetuning.")
56+
import os
57+
if "UNSLOTH_ZOO_IS_PRESENT" not in os.environ:
58+
try:
59+
print("🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.")
60+
except:
61+
print("Unsloth: Will patch your computer to enable 2x faster free finetuning.")
62+
pass
6163
pass
64+
del os

0 commit comments

Comments
 (0)