From b4ef87028074b5830d7eecb5d62fb2acd51b26bd Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 25 Nov 2024 22:17:20 -0800 Subject: [PATCH] Update _utils.py --- unsloth/models/_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 531adad317..daf0bdf44d 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -1175,17 +1175,19 @@ LOGITS_ERROR_STRING = \ "os.environ['UNSLOTH_RETURN_LOGITS'] = '1'\n"\ "... trainer.train() ..." -def raise_logits_error(*args, **kwargs): print(LOGITS_ERROR_STRING) +def raise_logits_error1(*args, **kwargs): print(1000) +def raise_logits_error2(*args, **kwargs): print(2000) class EmptyLogits: def __init__(self): return - __getitem__ = raise_logits_error - __getattr__ = raise_logits_error + __getitem__ = raise_logits_error1 + __getattr__ = raise_logits_error2 def __repr__(self): return LOGITS_ERROR_STRING def __str__ (self): return LOGITS_ERROR_STRING pass EMPTY_LOGITS = EmptyLogits() functions = dir(torch.Tensor) -for function in functions: - try: exec(f"EMPTY_LOGITS.{function} = raise_logits_error", globals(), locals()) +for j, function in enumerate(functions): + exec(f"def raise_{j}: print({j})", globals(), locals()) + try: exec(f"EMPTY_LOGITS.{function} = raise_{j}", globals(), locals()) except: continue pass