Skip to content

Conversation

zucchini-nlp
Copy link
Member

What does this PR do?

Fixes #40964

In most vision models the output.hidden_states are the hiddens right after encoder blocks, i.e. before the last layernorm. Therefore for these models output.hidden_states != output.last_hidden_state

Currently check_model_inputs assumes that last hidden state is the correct one to return which is true for language models only. This PR adds a kwarg for check_model_inputs which decides whether to replace last hidden state or not

TBH, i think the way it is done in LMs is the ultimate correct version and we probably need to "break" vision models. But I can't think of a way to obtain pre-norm last hidden states which are needed for some VLMs

Copy link
Contributor

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

run-slow: aimv2, apertus, arcee, aria, audio_spectrogram_transformer, aya_vision, bitnet, blip, blip_2, cohere, cohere2, cohere2_vision, csm, deepseek_v2, deepseek_v3, deit

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

@zucchini-nlp zucchini-nlp removed the request for review from ArthurZucker September 19, 2025 10:54
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.

llava model compile output regression caused by check_model_inputs
2 participants