Skip to content

Commit 55f7690

Browse files
danielhanchentimothelaborieeltociearErland366Datta0
authored
Bug fixes (#1255)
* 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 * Update _utils.py * Update llama.py * CE Loss * Update cross_entropy_loss.py * Update _utils.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update cross_entropy_loss.py * Update llama.py * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py --------- 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 3ea7044 commit 55f7690

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

unsloth/models/_utils.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "2024.11.1"
15+
__version__ = "2024.11.3"
1616

1717
__all__ = [
1818
"prepare_model_for_kbit_training",
@@ -69,7 +69,6 @@
6969
patch_compiling_bitsandbytes,
7070
patch_layernorm,
7171
patch_torch_compile,
72-
patch_regional_compilation,
7372
patch_model_and_tokenizer,
7473
)
7574
from unsloth_zoo.gradient_checkpointing import (
@@ -88,8 +87,9 @@
8887
# Disable some warnings which can get annoying
8988
warnings.filterwarnings(action = "ignore", category = UserWarning, module = "torch")
9089
warnings.filterwarnings(action = "ignore", category = UserWarning, module = "huggingface_hub")
91-
warnings.filterwarnings(action = "ignore", category = UserWarning, module = "trl")
9290
warnings.filterwarnings(action = "ignore", category = FutureWarning, module = "huggingface_hub")
91+
warnings.filterwarnings(action = "ignore", category = UserWarning, module = "trl")
92+
warnings.filterwarnings(action = "ignore", category = FutureWarning, module = "trl")
9393
warnings.filterwarnings(action = "ignore", category = FutureWarning, module = "xformers")
9494
warnings.filterwarnings(action = "ignore", category = RuntimeWarning, module = "subprocess")
9595
warnings.filterwarnings(action = "ignore", category = UserWarning, module = "transformers")
@@ -374,8 +374,9 @@ def _is_openai_available(): return False
374374

375375
# =============================================
376376
# Torch compile settings
377-
UNSLOTH_COMPILE_DEBUG = "UNSLOTH_COMPILE_DEBUG" in os.environ
378-
UNSLOTH_COMPILE_MAXIMUM = "UNSLOTH_COMPILE_MAXIMUM" in os.environ
377+
UNSLOTH_COMPILE_DEBUG = os.environ.get("UNSLOTH_COMPILE_DEBUG", "0") == "1"
378+
UNSLOTH_COMPILE_MAXIMUM = os.environ.get("UNSLOTH_COMPILE_MAXIMUM", "0") == "1"
379+
UNSLOTH_COMPILE_IGNORE_ERRORS = os.environ.get("UNSLOTH_COMPILE_IGNORE_ERRORS", "1") == "1"
379380
# Just remove max_autotune_gemm warning
380381
import functools
381382
@functools.lru_cache(None)
@@ -387,7 +388,11 @@ def is_big_gpu(index):
387388
return True
388389
import torch._inductor.utils
389390
torch._inductor.utils.is_big_gpu = is_big_gpu
390-
patch_torch_compile(debug = UNSLOTH_COMPILE_DEBUG, O3 = UNSLOTH_COMPILE_MAXIMUM)
391+
patch_torch_compile(
392+
debug = UNSLOTH_COMPILE_DEBUG,
393+
O3 = UNSLOTH_COMPILE_MAXIMUM,
394+
ignore_errors = UNSLOTH_COMPILE_IGNORE_ERRORS,
395+
)
391396

392397
torch_compile_options = {
393398
"epilogue_fusion" : True,
@@ -408,6 +413,26 @@ def torch_compile_kwargs(*args, **kwargs):
408413
accelerate.accelerator.TorchDynamoPlugin.to_kwargs = torch_compile_kwargs
409414
del accelerate
410415

416+
def patch_regional_compilation():
417+
# Regional torch 2.5 Recompilation - weirdly very slow??
418+
if torch.nn.ModuleList.__name__ == "UnslothModuleList": return
419+
# Only works for torch 2.5
420+
if Version(torch.__version__) < Version("2.5.0"): return
421+
422+
old_module_list = torch.nn.ModuleList
423+
os.environ["UNSLOTH_PATCHED"] = "1"
424+
425+
def UnslothModuleList(*args, **kwargs):
426+
if len(args) == 1 and len(kwargs) == 0 and type(args[0]) is list:
427+
args = [old_module_list([torch.compile(x, dynamic = True, options = torch_compile_options, fullgraph = False) for x in args[0]])]
428+
return old_module_list(*args, **kwargs)
429+
pass
430+
UnslothModuleList.__doc__ = old_module_list.__doc__
431+
432+
torch.nn.ModuleList = UnslothModuleList
433+
return
434+
pass
435+
411436
# =============================================
412437

413438
def prepare_model_for_kbit_training(

0 commit comments

Comments
 (0)