Skip to content

Conversation

@hmellor
Copy link
Member

@hmellor hmellor commented Jul 22, 2025

  • TransformersModel no longer inherits from nn.Module so self.model = AutoModel.from_config(...) is no longer instantly registered as a child module of TransformersModel
  • In TransformersForCausalLM and TransformersForMultimodalLM we set self.model to the inner model from TransformersModel
  • Now, hf_to_vllm_mapper is no longer necessary in TransformersForCausalLM and can be converted to a class variable in TransformersForMultimodalLM
  • Now that hf_to_vllm_mapper is no longer a @property in any Transformers backend classes, we can update SupportsQuant to access the class attribute directly as instructed in the comments

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 simplifies the Transformers backend by removing nn.Module inheritance from TransformersModel, streamlining weight mappers. However, the weight mapper in TransformersForMultimodalLM has a critical issue that will cause weight loading to fail for some models. The review includes a fix for this issue, as well as suggestions for code simplification and readability.

Comment on lines 757 to 765
hf_to_vllm_mapper = WeightsMapper(
orig_to_new_prefix={
"language_model.model": "language_model",
"text_model.model": "text_model",
"text_model.lm_head": "lm_head",
"language_model.lm_head": "lm_head",
# deal with Qwen2-VL mapping
"model.layers": "language_model.layers",
})
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The updated hf_to_vllm_mapper for TransformersForMultimodalLM appears to be incorrect. The AutoWeightsLoader is initialized with self (the TransformersForMultimodalLM instance), which has self.model as an attribute containing the PreTrainedModel. Therefore, parameter names within the model are expected to be prefixed with model. (e.g., model.language_model...).

The current mappings, such as "language_model.model": "language_model", will cause the loader to look for a top-level language_model attribute on TransformersForMultimodalLM, which doesn't exist. The target prefixes should include model. to correctly map to the nested structure.

For example, language_model.model from the checkpoint should map to model.language_model in the vLLM model.

hf_to_vllm_mapper = WeightsMapper(
        orig_to_new_prefix={
            "language_model.model": "model.language_model",
            "text_model.model": "model.text_model",
            "text_model.lm_head": "model.lm_head",
            "language_model.lm_head": "model.lm_head",
            # deal with Qwen2-VL mapping
            "model.layers": "model.language_model.layers",
        })

@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.

🚀

@DarkLight1337 DarkLight1337 requested a review from Isotr0py July 22, 2025 14:38
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 as long as tests can pass.

@Isotr0py Isotr0py enabled auto-merge (squash) July 22, 2025 15:23
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 22, 2025
@vllm-bot vllm-bot merged commit f154bb9 into vllm-project:main Jul 23, 2025
73 of 76 checks passed
@hmellor hmellor deleted the transformers-backend-remove-mapper branch July 23, 2025 07:12
zixi-qi pushed a commit to zixi-qi/vllm that referenced this pull request Jul 23, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
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
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
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

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants