Skip to content

Load generation config from nested configs#42922

Merged
zucchini-nlp merged 6 commits intohuggingface:mainfrom
zucchini-nlp:load-generation-config
Dec 18, 2025
Merged

Load generation config from nested configs#42922
zucchini-nlp merged 6 commits intohuggingface:mainfrom
zucchini-nlp:load-generation-config

Conversation

@zucchini-nlp
Copy link
Member

What does this PR do?

Fixes #42794. The issue was that model's generation params are saved in text config, but we couldn't call config.get_text_config() on a dict object. We can delete the second load_pretrained because each model gets a default generation config from model config in __init__

We could technically get the text config from dict, but I don't see a reason for adding more code if we can delete redundant blocks

@zucchini-nlp zucchini-nlp requested a review from vasqu December 17, 2025 13:13
@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
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.

Nice thx for the test just nits and let's double-check possibly affected models (with run-slow or so)

pixel_values = floats_tensor((2, 3, 30, 30))
conditioning_input = torch.tensor([[10], [10]]) # this should be the 2nd output token, after the BOS token
model = AutoModelForVision2Seq.from_pretrained(
model = AutoModelForImageTextToText.from_pretrained(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks unrelated? Nothing to change just noticed

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 mapping was deprecated in favor of AutoModelForImageTextToText, so just making sure we don't use deprecated stuff in tests

@zucchini-nlp
Copy link
Member Author

run-slow: t5, bart, mbart, umt5

@github-actions
Copy link
Contributor

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

models: ["models/bart", "models/mbart", "models/t5", "models/umt5"]
quantizations: []

@github-actions
Copy link
Contributor

CI Results

Workflow Run ⚙️

Model CI Report

❌ Failed tests

  • bart:
    tests/models/bart/test_modeling_bart.py::FastIntegrationTests::test_xsum_1_1_batch_generation
    tests/models/bart/test_modeling_bart.py::FastIntegrationTests::test_xsum_1_1_generation
    tests/models/bart/test_modeling_bart.py::BartModelIntegrationTests::test_decoder_attention_mask

  • mbart:
    tests/models/mbart/test_modeling_mbart.py::MBartEnroIntegrationTest::test_enro_generate_batch

@zucchini-nlp
Copy link
Member Author

zucchini-nlp commented Dec 18, 2025

super weird, I am getting a failure with these test cases even on main branch. Will try also by ssh-ing to runners

edit: i am blind, i was using an incorrect python env and thus checking against this same branch 🤦🏻

@zucchini-nlp
Copy link
Member Author

run-slow: t5, bart, mbart, umt5, llama, gemma3, mistral

@github-actions
Copy link
Contributor

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

models: ["models/bart", "models/gemma3", "models/llama", "models/mbart", "models/mistral", "models/t5", "models/umt5"]
quantizations: []

@github-actions
Copy link
Contributor

CI Results

Workflow Run ⚙️

✅ No failing test specific to this PR 🎉 !

@zucchini-nlp
Copy link
Member Author

run-slow: t5, bart, mbart, umt5, llama, gemma3, mistral

@zucchini-nlp
Copy link
Member Author

Didn't see that slow tests were triggered. All pass, merging!

@zucchini-nlp zucchini-nlp merged commit f2c6d2a into huggingface:main Dec 18, 2025
26 checks passed
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
* fix

* add comment

* add a test

* wording

* this is it!
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.

decoder_start_token_id or bos_token_id has to be defined for encoder-decoder generation.

3 participants