Skip to content

Conversation

@wzqd
Copy link
Contributor

@wzqd wzqd commented Jul 24, 2025

Support tensor parallel for timm ViT

  • Wrap external ViT from timm library to support tensor parallel
  • Apply tensor parallel to mlp blocks
  • Apply tensor parallel to attention blocks

Purpose

The vision transformer from timm library does not support tensor parallel and has bad performance. Currently minicpmv2_0 and deepseek_vl2 are the only two models using timm ViT, but minicpmv2_6 has changed to idefics ViT. The purpose of this pr is to enhance performance of the ViT in deepseekvl2 without changing the model structure.

@mergify mergify bot added the deepseek Related to DeepSeek models label Jul 24, 2025
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 tensor parallelism support for the timm Vision Transformer's MLP blocks within the deepseek_vl2 model. The implementation correctly monkey-patches timm.layers.Mlp to substitute nn.Linear with vLLM's ColumnParallelLinear and RowParallelLinear. A wrapper class is also added to adapt the output format of these parallel layers for compatibility with the timm library.

The overall approach is solid and directly addresses the goal of improving performance through tensor parallelism. However, I have identified a critical issue in the exception handling logic that could lead to a runtime error, as well as a high-severity issue in the implementation of the wrapper class that could introduce subtle bugs. Addressing these points will significantly improve the robustness and correctness of the code.

@github-actions
Copy link

👋 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 can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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.

🚀

Signed-off-by: wzqd <1057337859@qq.com>
wzqd added 2 commits July 24, 2025 15:07
Signed-off-by: wzqd <1057337859@qq.com>
Signed-off-by: wzqd <1057337859@qq.com>
@wzqd wzqd requested a review from Isotr0py July 25, 2025 02:09
Copy link
Member

@Isotr0py Isotr0py left a comment

Choose a reason for hiding this comment

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

LGTM now!

@Isotr0py Isotr0py enabled auto-merge (squash) July 25, 2025 03:02
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 25, 2025
@vllm-bot vllm-bot merged commit b38bc65 into vllm-project:main Jul 25, 2025
68 of 72 checks passed
liuyumoye pushed a commit to liuyumoye/vllm that referenced this pull request Jul 31, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
…oject#21494) Signed-off-by: wzqd <1057337859@qq.com> Signed-off-by: x22x22 <wadeking@qq.com>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
…oject#21494) Signed-off-by: wzqd <1057337859@qq.com> Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
…oject#21494) Signed-off-by: wzqd <1057337859@qq.com> Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
…oject#21494) Signed-off-by: wzqd <1057337859@qq.com> Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek Related to DeepSeek models ready ONLY add when PR is ready to merge/full CI is needed

3 participants