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

Generate: add missing **model_kwargs in sample tests #18696

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

gante
Copy link
Member

@gante gante commented Aug 19, 2022

What does this PR do?

One call of the sample-related tests was missing **model_kwargs, which MAY explain the random failures we were seeing.

I've run all test_sample_generate_dict_output tests 100x with no failures. Before this change, it was failing once every ~10 calls of py.test tests/ -k test_sample_generate_dict_output.

@gante gante changed the title Generate: add missing model_kwargs in sample tests Generate: add missing **model_kwargs in sample tests Aug 19, 2022
@gante gante requested a review from ydshieh August 19, 2022 14:10
@@ -327,6 +327,7 @@ def _sample_generate(
remove_invalid_values=True,
**logits_warper_kwargs,
**process_kwargs,
**model_kwargs,
Copy link
Member Author

Choose a reason for hiding this comment

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

The dict only carries the attention mask :)

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 19, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

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

Thank you @gante . We can finally sleep better without seeing this pop again :-)

It is somehow mysterious that without passing attn mask, we have more frequent test failure.
It might be a good idea to keep this on a TODO list somewhere, either a comment above the changed line, or on Notion.

@gante
Copy link
Member Author

gante commented Aug 19, 2022

@ydshieh when the attention mask is not passed, it is inferred from the input (here).

Depending on the pad and eos tokens, the mask inferred from the random input tokens may have issues. This automatic attention mask is a big source of issues in general, especially for the tests :(

Passing the mask explicitly is always preferred!

@gante gante merged commit e95d433 into huggingface:main Aug 19, 2022
@gante gante deleted the fix_sample_tests branch August 19, 2022 15:14
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.

3 participants