From c9239c8fdf5421e10ce798bfa396c474597e7d81 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 20 Dec 2024 03:03:26 -0800 Subject: [PATCH] Update llama.py --- unsloth/models/llama.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index dc78547ddc..3e67b4e89a 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -784,7 +784,6 @@ def LlamaModel_fast_forward( pass pass - if transformers_version > "4.47.1" and hasattr(self, "rotary_emb"): # Transformers main has made it mandatory to pass position_embeddings # https://github.com/huggingface/transformers/pull/34858 @@ -848,7 +847,7 @@ def LlamaModel_fast_forward( output_attentions = output_attentions, use_cache = use_cache, padding_mask = padding_mask, - position_embeddings = position_embeddings + position_embeddings = position_embeddings, ) hidden_states = layer_outputs[0] pass @@ -1008,7 +1007,6 @@ def CausalLM_fast_forward(fast_forward_inference): if not RETURN_LOGITS and HAS_CUT_CROSS_ENTROPY and labels is not None: n_items = kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None) - print(n_items) loss = fused_linear_cross_entropy( hidden_states = hidden_states, lm_weight = lm_head, @@ -1056,6 +1054,7 @@ def CausalLM_fast_forward(fast_forward_inference): self.extra_ignored_labels = torch.full((self.max_seq_length, 1), -100, device = "cuda:0") pass shift_labels = torch.hstack((labels[..., 1:], self.extra_ignored_labels[:labels.shape[0]])) + print(kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None)) loss = fast_cross_entropy_loss( logits = shift_logits, labels = shift_labels,