Skip to content

Fix MusicGen generation config#43194

Merged
zucchini-nlp merged 9 commits intohuggingface:mainfrom
zucchini-nlp:gen-config-defaults
Jan 15, 2026
Merged

Fix MusicGen generation config#43194
zucchini-nlp merged 9 commits intohuggingface:mainfrom
zucchini-nlp:gen-config-defaults

Conversation

@zucchini-nlp
Copy link
Copy Markdown
Member

What does this PR do?

Some audio models have their own generate() which doesn't call prepare_generation_config. We need to call prepare_generation_config to update values to prev defaults

Also, I added a small deprecation warning preparing us and users to passing either generation config of kwargs, only one. We will anyway have to support it for a long time, it is a common pattern among users

@zucchini-nlp zucchini-nlp requested a review from vasqu January 9, 2026 14:44
generation_config = copy.deepcopy(generation_config)
model_kwargs = generation_config.update(**kwargs) # All unused kwargs must be model kwargs
generation_config.validate()
generation_config = self.generation_config if generation_config is None else generation_config
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this line is used in all overriden generate() to use custom gen-params. Need to clean up after your PR on custom generation parameters

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to prio #43181 first then, I changed the logic to be within update directly (via a new kwarg), lmk what you think otherwise fine to fix this first

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, I don't mind waiting for your PR to be merged first

@zucchini-nlp
Copy link
Copy Markdown
Member Author

run-slow: musicgen_melody

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 9, 2026

This comment contains run-slow, running the specified jobs:

models: ["models/musicgen_melody"]
quantizations: []

@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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 9, 2026

CI Results

Workflow Run ⚙️

✅ No failing test specific to this PR 🎉 !

Copy link
Copy Markdown
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

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

Fine to fix this first before we forget, test_generate_text_audio_prompt still fails not sure if it failed before as well

Comment on lines +1813 to +1818
logger.warning_once(
f"Passing `generation_config` together with generation-related "
f"arguments=({generation_kwargs}) is deprecated and will be removed in future versions. "
"Please pass either a `generation_config` object OR all generation "
"parameters explicitly, but not both.",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would love to have this raise an error but it's probably too breaking?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, we don't want to break it yet. This is to nudge users for better practices and give them time to get used to it. Maybe we can raise errors after 10-15 releases

generation_config = copy.deepcopy(generation_config)
model_kwargs = generation_config.update(**kwargs) # All unused kwargs must be model kwargs
generation_config.validate()
generation_config = self.generation_config if generation_config is None else generation_config
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to prio #43181 first then, I changed the logic to be within update directly (via a new kwarg), lmk what you think otherwise fine to fix this first

@vasqu
Copy link
Copy Markdown
Contributor

vasqu commented Jan 9, 2026

CI is going crazy with the flakiness 😢

@zucchini-nlp zucchini-nlp enabled auto-merge (squash) January 13, 2026 08:44
@zucchini-nlp
Copy link
Copy Markdown
Member Author

CI is sooo flaky

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: musicgen_melody, whisper

@zucchini-nlp zucchini-nlp merged commit 38e5987 into huggingface:main Jan 15, 2026
25 checks passed
githubnemo pushed a commit to githubnemo/transformers that referenced this pull request Jan 21, 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.
githubnemo pushed a commit to githubnemo/transformers that referenced this pull request Jan 21, 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.
githubnemo pushed a commit to githubnemo/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.
ydshieh pushed a commit that referenced this pull request Jan 22, 2026
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.

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

* custom gen config now works
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.

3 participants