Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trainer: fail early in the presence of an unsavable generation_config #29675

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

gante
Copy link
Member

@gante gante commented Mar 15, 2024

What does this PR do?

Fixes #29665

We don't allow saving bad generation config files (i.e. ones whose validation has warnings or exceptions). This check was only done at save time, which happens AFTER training. This PR introduces the same check in the trainer's __init__, to fail early (and before spending time/$)

@gante gante requested review from muellerzr and amyeroberts March 15, 2024 11:00
@gante gante changed the title Trainer: fail early in the presence of a unsavable generation_config Trainer: fail early in the presence of an unsavable generation_config Mar 15, 2024
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for quickly adding this!

with warnings.catch_warnings(record=True) as caught_warnings:
gen_config.validate()
if len(caught_warnings) > 0:
raise ValueError(str([w.message for w in caught_warnings]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this properly separate out the messages? We might want to add a line break in between the w.message elements

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it prints a list of str, so it is easy to separate the messages :)

a = ["foo", "bar", "baz"]
raise ValueError(str([msg for msg in a]))
# ValueError: ['foo', 'bar', 'baz']

@gante gante merged commit c47fcd0 into huggingface:main Mar 15, 2024
19 checks passed
@gante gante deleted the fail_trainer_early branch March 15, 2024 12:59
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.

GenerationConfig.from_pretrained raise ValueError after training, maybe raise it earlier?
3 participants