Skip to content

Fix always issuing generation deprecation warning#43389

Merged
ydshieh merged 1 commit intohuggingface:mainfrom
githubnemo:issue/deprecation-always-issued
Jan 22, 2026
Merged

Fix always issuing generation deprecation warning#43389
ydshieh merged 1 commit intohuggingface:mainfrom
githubnemo:issue/deprecation-always-issued

Conversation

@githubnemo
Copy link
Copy Markdown
Contributor

What does this PR do?

Note: already discussed with @zucchini-nlp internally

Commit 38e5987 from PR #43194 introduced a minor bug that causes the issuing of a deprecation warning regardless of the user using the deprecated interface.

For example:

model.generate(**input_ids, do_sample=False)

would issue a deprecation warning not to pass GenerationConfig as well as generation kwargs even though we're not passing a GenerationConfig.

Along the fix this also introduces a unit test to check both the intended and the bug behavior.

@githubnemo githubnemo force-pushed the issue/deprecation-always-issued branch from c926f83 to aeb8ffe Compare January 21, 2026 12:12
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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
Copy Markdown
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Thanks, one tiny question and then feel free to merge :)

Comment on lines +2716 to +2719
try:
# Providing generation_config and kwargs is deprecated, so we expect a warning here.
#
# We're using logging_once, make sure that we emit this warning in any case by clearing the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: what is the purpose of try, and can we let it fail explicitly to know that this test has issues instead of silent skip

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

try without except doesn't catch the exceptions, it executes the code in try and then invokes finally to clean up - that's the only purpose of this construct is to remove the logging handler after the test is done in any case (exception thrown because of assertion failure or not)

Commit 38e5987 from PR huggingface#43194 introduced a minor bug that causes the issuing of
a deprecation warning regardless of the user using the deprecated interface.

For example:
```
model.generate(**input_ids, do_sample=False)
```
would issue a deprecation warning not to pass `GenerationConfig` as well as generation kwargs
even though we're not passing a `GenerationConfig`.

Along the fix this also introduces a unit test to check both the intended and the bug
behavior.
@githubnemo githubnemo force-pushed the issue/deprecation-always-issued branch from aeb8ffe to e7cd078 Compare January 22, 2026 13:44
@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43389&sha=e7cd07

@ydshieh ydshieh merged commit 6e1cde6 into huggingface:main Jan 22, 2026
23 of 25 checks passed
vaibhav-research pushed a commit to vaibhav-research/transformers that referenced this pull request Jan 22, 2026
Commit 38e5987 from PR huggingface#43194 introduced a minor bug that causes the issuing of
a deprecation warning regardless of the user using the deprecated interface.

For example:
```
model.generate(**input_ids, do_sample=False)
```
would issue a deprecation warning not to pass `GenerationConfig` as well as generation kwargs
even though we're not passing a `GenerationConfig`.

Along the fix this also introduces a unit test to check both the intended and the bug
behavior.

Co-authored-by: nemo <git@ningu.net>
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
Commit 38e5987 from PR huggingface#43194 introduced a minor bug that causes the issuing of
a deprecation warning regardless of the user using the deprecated interface.

For example:
```
model.generate(**input_ids, do_sample=False)
```
would issue a deprecation warning not to pass `GenerationConfig` as well as generation kwargs
even though we're not passing a `GenerationConfig`.

Along the fix this also introduces a unit test to check both the intended and the bug
behavior.

Co-authored-by: nemo <git@ningu.net>
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.

4 participants