Skip to content

Conversation

@SangChengC
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SangChengC, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the compatibility and robustness of the InternVL model by addressing specific configuration and data processing aspects. It introduces an explicit initialization for the head dimension in Qwen3-VL transformer layers and refines how image tokens are counted and embeddings are shaped within the Vision Transformer component. These changes are crucial for ensuring correct data flow and seamless integration of visual and language modalities.

Highlights

  • Qwen3-VL Transformer Layer Configuration: The head_dim_ attribute is now explicitly initialized in the Qwen3VLTransformerLayerInfer class, ensuring proper configuration for the transformer layers.
  • ViT Image Token Count Logic: The method for determining the number of tokens for an image in the ViT model's encode function has been updated to directly use img.token_num, providing a more explicit and potentially accurate count.
  • ViT Image Embedding Reshaping: Image embeddings returned by the ViT model's encode function are now reshaped to (-1, all_img_embeds.shape[-1]), ensuring a consistent output shape for downstream processing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces fixes for the InternVL model integration, specifically within the Qwen3-VL and ViT model implementations. The changes correctly adjust the output shape of ViT image embeddings and fix an issue with token counting. Additionally, a necessary head_dim attribute is added for the Qwen3-VL transformer layer. My review includes a suggestion to improve code robustness by adding an assertion and another to remove redundant code for better maintainability.

Comment on lines 28 to 30
self.mrope_section = torch.tensor(
network_config["rope_scaling"]["mrope_section"], dtype=torch.int32, device="cuda"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The initialization of self.mrope_section is redundant as it's already handled by the superclass Qwen2VLTransformerLayerInfer's __init__ method, which is invoked via super().__init__() on line 26. Removing these lines will eliminate code duplication and improve maintainability.

raise Exception("Unsupport input types: {} for {}".format(type(img), img))

cur_num = img_tensors[-1].shape[0]
cur_num = img.token_num
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness, consider adding an assertion to verify that img.token_num is not None before it's used. This will help catch potential issues early if the value is not set as expected, preventing a TypeError during the summation and making the code's contract clearer.

Suggested change
cur_num = img.token_num
assert img.token_num is not None, "Image token number must be set before calling encode."
cur_num = img.token_num

@hiworldwzj hiworldwzj merged commit 04b214b into main Jan 9, 2026
1 check passed
@hiworldwzj hiworldwzj deleted the fix_internvl branch January 9, 2026 07:35
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