[Model] Enable LoRA support for internvl2#32397
Conversation
|
👋 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 You ask your reviewers to trigger select CI tests on top of 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 If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
There was a problem hiding this comment.
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.
801b2e1 to
1b0a1f8
Compare
|
Have you tested this locally? |
|
Hi @jeejeelee, yes I tested it with InternVL2 HF checkpoint (OpenGVLab/InternVL2-1B). |
1b0a1f8 to
ce9462d
Compare
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
ce9462d to
ef3518e
Compare
Signed-off-by: Matteo Fari <matteofari06@gmail.com> Signed-off-by: 陈建华 <1647430658@qq.com>
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
Signed-off-by: Matteo Fari <matteofari06@gmail.com>
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.