From 9197ce07cb065aff0c761a20bbf6290e9029c613 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 26 Dec 2024 18:45:16 -0800 Subject: [PATCH] print --- unsloth/models/_utils.py | 1 - unsloth/models/llama.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 5fa6b5de52..4bedce38e5 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -1127,7 +1127,6 @@ def patch_gradient_accumulation_fix(Trainer): r"(.+?)return loss\.detach\(\) \/ self\.args\.gradient_accumulation_steps", "else:\n"\ - "\1print(self.args.gradient_accumulation_steps)\n" "\2if num_items_in_batch is None:\n"\ "\3loss = loss / self.args.gradient_accumulation_steps\n"\ "\1self.accelerator.backward(loss, **kwargs)", diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index c94514966f..ddee9e9017 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1009,6 +1009,7 @@ 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(0, n_items) loss = fused_linear_cross_entropy( hidden_states = hidden_states, lm_weight = lm_head, @@ -1055,6 +1056,7 @@ def CausalLM_fast_forward(fast_forward_inference): # Fixes https://github.com/unslothai/unsloth/issues/10 self.extra_ignored_labels = torch.full((self.max_seq_length, 1), -100, device = "cuda:0") pass + print(1, kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None)) shift_labels = torch.hstack((labels[..., 1:], self.extra_ignored_labels[:labels.shape[0]])) loss = fast_cross_entropy_loss( logits = shift_logits,