Skip to content

[Model] Enable LoRA support for internvl2#32397

Merged
jeejeelee merged 1 commit intovllm-project:mainfrom
MatteoFari:InternVL2-lora
Jan 23, 2026
Merged

[Model] Enable LoRA support for internvl2#32397
jeejeelee merged 1 commit intovllm-project:mainfrom
MatteoFari:InternVL2-lora

Conversation

@MatteoFari
Copy link
Copy Markdown
Contributor

@MatteoFari MatteoFari commented Jan 15, 2026

Purpose

Enable dynamic LoRA adapters on InternVL2 vision tower + connector (part of #31479) by implementing:

  • get_num_mm_encoder_tokens()

  • get_num_mm_connector_tokens()

Technical Details

InternVL2 has a CLS token and pixel-shuffle downsampling (downsample_ratio), so LM <IMG_CONTEXT> tokens (post-downsample) don’t match tower tokens (pre-downsample). These helpers map token counts correctly between LM and tower/connector.

Part of #31479.

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors.

You ask your reviewers to trigger select CI tests on top of fastcheck CI.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

Copy link
Copy Markdown
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 enables LoRA support for the InternVL2 model by implementing get_num_mm_encoder_tokens and get_num_mm_connector_tokens. The logic in these new methods is sound. However, I've identified a critical issue that could lead to a ZeroDivisionError and a high-severity maintainability issue due to significant code duplication. I've provided a specific code suggestion to fix the critical bug and a recommendation for refactoring to address the code duplication.

@jeejeelee
Copy link
Copy Markdown
Collaborator

Have you tested this locally?

@MatteoFari
Copy link
Copy Markdown
Contributor Author

Hi @jeejeelee, yes I tested it with InternVL2 HF checkpoint (OpenGVLab/InternVL2-1B).
these are the test + logs

@jeejeelee jeejeelee added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 21, 2026
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
@jeejeelee jeejeelee merged commit fec9da0 into vllm-project:main Jan 23, 2026
53 checks passed
cwazai pushed a commit to cwazai/vllm that referenced this pull request Jan 25, 2026
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
Signed-off-by: 陈建华 <1647430658@qq.com>
lapy pushed a commit to lapy/vllm that referenced this pull request Jan 27, 2026
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
ItzDEXX pushed a commit to ItzDEXX/vllm that referenced this pull request Feb 19, 2026
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants