Update _utils.py
This commit is contained in:
parent
3612242027
commit
0d1ec74bf0
1 changed files with 8 additions and 0 deletions
|
|
@ -1086,6 +1086,14 @@ def patch_gradient_accumulation_fix(Trainer):
|
|||
"if num_items_in_batch is not None: loss *= self.args.gradient_accumulation_steps",
|
||||
)
|
||||
function = function.replace("def training_step", "def _unsloth_training_step", 1)
|
||||
|
||||
# Fix 4.47.0 issue where num_items_in_batch was removed
|
||||
# See https://github.com/huggingface/transformers/pull/35121
|
||||
function = function.replace(
|
||||
"if self.model_accepts_loss_kwargs:",
|
||||
"if False:",
|
||||
)
|
||||
|
||||
exec(function, globals())
|
||||
Trainer.training_step = _unsloth_training_step
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue