Skip to content

fix: prevent crash when args.adapter_file is None in sft_trainer#921

Open
JasonOA888 wants to merge 1 commit into
Blaizzy:mainfrom
JasonOA888:fix/908-sft-trainer-adapter-file-none
Open

fix: prevent crash when args.adapter_file is None in sft_trainer#921
JasonOA888 wants to merge 1 commit into
Blaizzy:mainfrom
JasonOA888:fix/908-sft-trainer-adapter-file-none

Conversation

@JasonOA888
Copy link
Copy Markdown

Problem

sft_trainer.py crashes with TypeError: argument should be a str or an os.PathLike object when args.adapter_file is None. This happens when TrainingArgs is constructed with an explicit None value for adapter_file (e.g. from programmatic usage).

Fix

  • Add defensive fallback: adapter_file = args.adapter_file or "adapters.safetensors" at both save points (checkpoint and final)
  • Create parent directory before saving to prevent FileNotFoundError

Both the checkpoint save (line ~471) and final save (line ~484) are covered.

Closes #908

Add defensive fallback to 'adapters.safetensors' when adapter_file is
None, and ensure parent directory exists before saving.

Closes Blaizzy#908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] sft_trainer crashes on checkpoint save — args.adapter_file is None

1 participant