transformers
2eefc0e2 - Fix `Llama4ForConditionalGeneration` forward reading `image_outputs` from the text model (#51092)

Commit
11 hours ago
Fix `Llama4ForConditionalGeneration` forward reading `image_outputs` from the text model (#51092) * Fix Llama4ForConditionalGeneration forward reading image_outputs Llama4ForConditionalGeneration calls its Llama4ForCausalLM language model directly, whose output has no image_outputs field, so every forward with return_dict (and generate) raised AttributeError. Take the image outputs from the vision features computed in the same forward, as the other multimodal models do, and add a tiny-config regression test. * Test Llama 4 with VLMModelTester and fix what the tests find Replace the tiny regression test with VLMModelTester / VLMModelTest, as asked in review. The common tests found three problems in Llama 4, fixed here: - get_image_features left pooler_output unset, so generate() did not expand the pre-encoded image features for beam search or num_return_sequences > 1 ("Image features and image tokens do not match"). pooler_output now holds the projected features, as in Llava, and the forward reads them from there. Logits are unchanged. - Llama4VisionModel raised IndexError with output_attentions=True when hidden states were not requested. - The forward refused pixel_values together with inputs_embeds, although get_placeholder_mask already handles inputs_embeds. Skipped with reasons: the base_model_prefix and TP-plan tests, RoPE scaling from config (the MODEL_MAPPING class has no last_hidden_state) and three compile tests (get_compiled_call never compiles llama4). The RoPE frequency test is overridden for the complex-valued RoPE, as in DeepseekV2. * Return Llama 4 vision outputs through can_return_tuple --------- Co-authored-by: Xiaoyuan Wang <174581044+XiaoyuanWang111@users.noreply.github.com>
Parents
Loading