Fix: Add **kwargs to QEffLlama4VisionModel.forward() for transformers v4.57.3 compatibility#933
Merged
quic-rishinr merged 1 commit intoquic:mainfrom Apr 24, 2026
Conversation
1d04918 to
ef43dab
Compare
vbaddi
approved these changes
Apr 21, 2026
Contributor
|
@quic-rishinr Check for CI and merge pls, thanks :) |
Contributor
Author
|
@quic-dhirajku any update on the review of this patch? |
… v4.57.3 compatibility ## Problem After the transformers v4.57.3 rebase (commit 7acb860), the following error occurs: TypeError: QEffLlama4VisionModel.forward() got an unexpected keyword argument 'vision_feature_layer' ## Root Cause Analysis 1. In transformers v4.57.3, Llama4ForConditionalGeneration.get_image_features() now passes additional parameters (vision_feature_layer and vision_feature_select_strategy) to the vision model's forward method via **kwargs. 2. The call chain: - QEffLlama4EncoderWrapper.forward() calls self.model.get_image_features() - get_image_features() (from transformers library) calls self.vision_model(**kwargs) - QEffLlama4VisionModel.forward() was not accepting **kwargs 3. Since QEffLlama4VisionModel overrides the forward() method but didn't accept **kwargs, it raised a TypeError when these unexpected arguments were passed. ## Solution Added **kwargs parameter to QEffLlama4VisionModel.forward() method signature. This allows the method to accept vision_feature_layer and vision_feature_select_strategy parameters from the parent class's get_image_features() method, even though they're not used in the QEff implementation. ## Impact - Backward compatible change - Fixes ONNX export failures for Llama4 vision models - Maintains compatibility with transformers v4.57.3 API Tested with: examples/image_text_to_text/models/llama4/single_image.py Signed-off-by: sudheepm <sudheepm@qti.qualcomm.com>
ef43dab to
04c9f57
Compare
quic-akuruvil
pushed a commit
that referenced
this pull request
Apr 27, 2026
… v4.57.3 compatibility (#933) ## Problem After the transformers v4.57.3 rebase (commit 7acb860), the following error occurs: TypeError: QEffLlama4VisionModel.forward() got an unexpected keyword argument 'vision_feature_layer' ## Root Cause Analysis 1. In transformers v4.57.3, Llama4ForConditionalGeneration.get_image_features() now passes additional parameters (vision_feature_layer and vision_feature_select_strategy) to the vision model's forward method via **kwargs. 2. The call chain: - QEffLlama4EncoderWrapper.forward() calls self.model.get_image_features() - get_image_features() (from transformers library) calls self.vision_model(**kwargs) - QEffLlama4VisionModel.forward() was not accepting **kwargs 3. Since QEffLlama4VisionModel overrides the forward() method but didn't accept **kwargs, it raised a TypeError when these unexpected arguments were passed. ## Solution Added **kwargs parameter to QEffLlama4VisionModel.forward() method signature. This allows the method to accept vision_feature_layer and vision_feature_select_strategy parameters from the parent class's get_image_features() method, even though they're not used in the QEff implementation. ## Impact - Backward compatible change - Fixes ONNX export failures for Llama4 vision models - Maintains compatibility with transformers v4.57.3 API Tested with: examples/image_text_to_text/models/llama4/single_image.py Signed-off-by: sudheepm <sudheepm@qti.qualcomm.com> Co-authored-by: sudheepm <sudheepm@qti.qualcomm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After the transformers v4.57.3 rebase (commit 7acb860), the following error occurs:
TypeError: QEffLlama4VisionModel.forward() got an unexpected keyword argument 'vision_feature_layer'
Root Cause Analysis
In transformers v4.57.3, Llama4ForConditionalGeneration.get_image_features()
now passes additional parameters (vision_feature_layer and vision_feature_select_strategy)
to the vision model's forward method via **kwargs.
The call chain:
Since QEffLlama4VisionModel overrides the forward() method but didn't accept **kwargs,
it raised a TypeError when these unexpected arguments were passed.
Solution
Added **kwargs parameter to QEffLlama4VisionModel.forward() method signature.
This allows the method to accept vision_feature_layer and vision_feature_select_strategy
parameters from the parent class's get_image_features() method, even though they're
not used in the QEff implementation.
Impact
Tested with: examples/image_text_to_text/models/llama4/single_image.py