Skip to content

eval_loss not found when training a peft model using trainer.py / losses not retrieved from base model where appropriate #38130

@kreil

Description

@kreil

System Info

pip list |grep transf; python --version; uname -a

transformers 4.51.3
Python 3.12.10
Linux gap 6.11.10+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.10-1~bpo12+1 (2024-12-19) x86_64 GNU/Linux

Who can help?

@zach-huggingface @SunMarc

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Train any peft model. I am training a LoRA adapter using the AutoModelForMaskedLM from ModernBERT.

Expected behavior

Trainer and its most regular features should handle looking up the losses in the base model, which at several places in the code they apparently don't. So instead of finding eval_loss they only see the new losses added by peft such as eval_steps_per_second.

One such issue is described, including a fix, in #33420. This fix should be merged with the regular sources.

The second such issue, triggered by setting load_best_model_at_end to True, is described in the comments to #33420 (no fix yet).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions