From 95a46a6ff51afe25c3a65c8367322f57571fa4b8 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 1 Dec 2024 02:19:07 -0800 Subject: [PATCH] Update llama.py --- unsloth/models/llama.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 1d413f0acc..68aa527990 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1706,18 +1706,19 @@ class FastLlamaModel: spaces = re.search('\n([\s\t]{1,})', original_debug).group(0)[1:] front_spaces = re.match('([\s\t]{1,})', inner_training_loop).group(0) - debug_info = """debug_info = \\ unsloth_0 = r'==((====))==' unsloth_1 = r' \\ /| ' unsloth_2 = r'O^O/ \_/ \ ' unsloth_3 = r'\ / ' unsloth_4 = r' "-____-" ' + + debug_info = """debug_info = \\ f"{unsloth_0} Unsloth - 2x faster free finetuning | Num GPUs = {args.world_size}\\n"\\ f"{unsloth_1} Num examples = {num_examples:,} | Num Epochs = {num_train_epochs:,}\\n"\\ f"{unsloth_2} Batch size per device = {self._train_batch_size:,} | Gradient Accumulation steps = {args.gradient_accumulation_steps}\\n"\\ f"{unsloth_3} Total batch size = {total_train_batch_size:,} | Total steps = {max_steps:,}\\n"\\ f'{unsloth_4} Number of trainable parameters = {get_model_param_count(model, trainable_only=True):,}' - print(debug_info) + logger.warning(debug_info) import subprocess, re, gc, numpy as np a = np.array([0,]) try: @@ -1733,6 +1734,14 @@ class FastLlamaModel: gc.collect() torch.cuda.empty_cache()""" + print(debug_info) + debug_info = debug_info\ + .replace("{unsloth_0}", unsloth_0)\ + .replace("{unsloth_1}", unsloth_1)\ + .replace("{unsloth_2}", unsloth_2)\ + .replace("{unsloth_3}", unsloth_3)\ + .replace("{unsloth_4}", unsloth_4) + debug_info = debug_info.split('\n') debug_info = "\n".join([debug_info[0]] + [spaces + x[8:] for x in debug_info[1:]]) inner_training_loop = inner_training_loop.replace(original_debug, debug_info)