Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm/model_executor/models/gemma3_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def _find_mm_placeholders(

def get_repl_toks(tok: int) -> list[int]:
if tok == newline_3:
return [newline_1, newline_2]
return [newline_2, newline_1]
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change correctly handles the case where [newline_2, newline_1] is merged into newline_3. However, it breaks the case where [newline_1, newline_2] is merged, as the decomposition is no longer its inverse.

The root cause is the ambiguous merging in _apply_token_matches (lines 373-382) where both [newline_1, newline_2] and [newline_2, newline_1] are merged into newline_3. The decomposition here in _find_mm_placeholders can only be the inverse of one of these, making the transformation lossy and causing one of the cases to fail.

A more robust fix would be to make the merging unambiguous. For example, by only merging [newline_2, newline_1] into newline_3 in _apply_token_matches and removing the merge for [newline_1, newline_2].

Specifically, you could remove lines 373-377 in _apply_token_matches:

        token_ids = replace_token_matches(
            token_ids,
            [newline_1, newline_2],
            [newline_3],
        )

With that change, your change here to decompose newline_3 into [newline_2, newline_1] would be correct and not break other cases. Without changing _apply_token_matches, this PR trades one bug for another.

if tok == newline_4:
return [newline_2, newline_2]

Expand Down