Skip to content

Qwen2VL: skip base input_ids-inputs_embeds equivalence check#34535

Merged
gante merged 1 commit intohuggingface:mainfrom
gante:qwen2vl_flaky_inputs_embeds
Oct 31, 2024
Merged

Qwen2VL: skip base input_ids-inputs_embeds equivalence check#34535
gante merged 1 commit intohuggingface:mainfrom
gante:qwen2vl_flaky_inputs_embeds

Conversation

@gante
Copy link
Contributor

@gante gante commented Oct 31, 2024

What does this PR do?

Computing inputs_embeds in Qwen2VL is more complex than simply embedding input_ids (see Qwen2VLForConditionalGeneration), so the basic check doesn't apply :)

Fixes:

py.test tests/models/qwen2_vl/test_modeling_qwen2_vl.py::Qwen2VLModelTest::test_generate_from_inputs_embeds_1_beam_search --flake-finder --flake-runs 100

@gante gante requested a review from ydshieh October 31, 2024 14:37
# 2.C - No easy fix, let's skip the check that compares the outputs from `input_ids` and `inputs_embeds`
has_complex_embeds_computation = any(
model_name in model_class.__name__.lower() for model_name in ["moshi"]
model_name in model_class.__name__.lower() for model_name in ["moshi", "qwen2vl"]
Copy link
Contributor Author

@gante gante Oct 31, 2024

Choose a reason for hiding this comment

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

This flag skips the check that passing inputs_embeds = model.get_input_embeddings()(input_ids) should be equivalent to passing input_ids to generate.

This is not true in Qwen2VL, whose computation of inputs_embeds is more complex

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK for me. Just curious: would this be addressed in the future to make it work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not unless we create a model function to embed inputs, similar to def get_input_embeddings(self).

(I think we should do it eventually, we're starting to have a few models with non-standard inputs embeddings creation!)

Copy link
Collaborator

Choose a reason for hiding this comment

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

got it :-) 👍

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

@gante gante merged commit 4ca004e into huggingface:main Oct 31, 2024
@gante gante deleted the qwen2vl_flaky_inputs_embeds branch October 31, 2024 15:42
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
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