Repository navigation
Place vLLM image features at the model config's image token - #7773
Open
albertvillanova wants to merge 1 commit into
Open
albertvillanova wants to merge 1 commit into
albertvillanova wants to merge 1 commit into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes VLM training with vLLM in server mode for Gemma3, where vLLM generated as if the prompts had no image.
Fix #7772.
Motivation
In server mode,
_place_featureslocated the image tokens with the processor'simage_token_id, which for Gemma3 on transformers 5.x is<start_of_image>instead of the image placeholder token. The features were then sent to vLLM at the wrong position, and generations ignored the images (see the issue for the reproduction).Solution
Read the image token from the model config, which holds the placeholder token for every supported VLM, as
VLLMGenerationalready does for the image token suppression in #7698.With the reproduction from the issue, the completion becomes "Red".
Changes
model.config.image_token_idinstead of the processor'simage_token_idinVLLMGeneration._place_featuresThere is no test: the server-mode VLM test is skipped until there is a mock for the vLLM server, and the bug needs a real Gemma3 behind a vLLM server.
Note
Low Risk
Single-token-ID source change in server-mode feature placement; low scope but fixes incorrect multimodal alignment for affected VLMs.
Overview
Fixes vLLM server-mode VLM training (e.g. Gemma3) where generations ignored images because multimodal features were aligned to the wrong token positions.
In
VLLMGeneration._place_features, image placeholder runs in the trainer’sprompt_idsare now found usingmodel.config.image_token_idinstead of the processor’simage_token_id. For some models (Gemma3 on transformers 5.x) those IDs differ, so features were sent to vLLM at incorrect offsets. This matches how TRL already picks the image token for suppression elsewhere in the vLLM path.Reviewed by Cursor Bugbot for commit 2df7030. Bugbot is set up for automated code reviews on this repo. Configure here.