Skip to content

Remove the unreachable prepare_multimodal_messages_vllm - #6946

Merged
qgallouedec merged 12 commits into
mainfrom
fix/6928-remove-dead-prepare-multimodal-vllm
Oct 2, 2026
Merged

qgallouedec merged 12 commits into
mainfrom
fix/6928-remove-dead-prepare-multimodal-vllm

Conversation

@behroozazarkhalili

@behroozazarkhalili behroozazarkhalili commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Assistant tool-call messages without content caused a key error in the live vLLM message conversion path. I made that path preserve these messages and removed the unused prepare_multimodal_messages_vllm helper and its exports. The new tool-call test fails on main, the data utility tests pass, and import checks confirm the removed name is gone.
Resolves #6928.


Note

Low Risk
Dead-code removal and public API shrinkage; only breaks callers that imported the removed helper, which the PR treats as unused.

Overview
Removes the unused prepare_multimodal_messages_vllm helper that deep-copied chat messages and rewrote image blocks from "type": "image" / "image" to vLLM’s "image_pil" format.

The function is dropped from trl/data_utils.py, no longer exported from trl/__init__.py, and TestPrepareMultimodalMessagesVLLM plus the related copy imports are deleted from tests. Multimodal prep stays on prepare_multimodal_messages (including tool-call turns without content, covered by existing tests in this branch per the PR description).

Reviewed by Cursor Bugbot for commit 433232a. Bugbot is set up for automated code reviews on this repo. Configure here.

…ges_vllm

Nothing in trl has called this function since #5238. Its history is two
steps: #4700 moved the call out of the GRPO and RLOO trainers into
trl/generation/vllm_generation.py, and #5238 ("Tokenize before vLLM
generation call") then removed that call site. The vLLM path has used
to_openai_messages since. Only the test suite still exercised the
function.

#6928 reports that it raises KeyError('content') on a tool-call message
that carries no content key. Fixing that would keep an unreachable
function alive, so remove it instead.

The function was also exported from trl/__init__.py, so this drops a
public name. That matches how the repo already treats a redundant
utility of this size: #6158 removed get_kbit_device_map() the same way,
with no deprecation cycle.

Dropping the function leaves `import copy` unused in trl/data_utils.py
and in tests/test_data_utils.py, so both imports go too. The sibling
prepare_multimodal_messages is untouched and still has 26 call
sites across 12 files.

Resolves #6928
@bot-ci-comment

Copy link
Copy Markdown

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.

@behroozazarkhalili

Copy link
Copy Markdown
Collaborator Author

prepare_multimodal_messages_vllm is listed in trl/__init__.py, so from trl import prepare_multimodal_messages_vllm resolves. I checked every tag from v1.5.0 through v1.12.0 and the export is present in all twelve, so a user on any released version can import it from the package root.

That does not contradict the dead-code reading. In TRL's own call graph it is dead: on main the only files that mention it are trl/__init__.py, trl/data_utils.py, and its tests. Internal unreachability and external usage are separate questions, and the export answers the second one differently. @YZJF's repro imports it directly, which is the case you asked about, and there has been no reply either way.

TRL has removed public symbols before, in two steps. XPO, PPO, ORPO, PRM, and Judges were each deprecated first with a warnings.warn naming v2.0.0 as the removal release, then deleted in a follow-up. This PR deletes in one step.

I am not proposing a change here. You asked for the removal and the diff does that. If v2.0.0 is where breaks are being collected, this fits and there is nothing to do. If the import should keep resolving through 1.x, the shim is small and I can add it to this PR.

…sages

The message from #6928, an assistant turn that carries tool_calls and no
content key, still raised KeyError on the live vLLM path after the dead
helper was removed: to_openai_messages indexed message["content"] for
every message, and both VLLMClient.chat and the model probe in __init__
go through it. Read the key with get so the message passes through
unchanged, and pin it with a unit test that fails on main with the same
KeyError. A second test covers the image inlining the function exists
for, which had no direct test.

@qgallouedec qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! We won't have a deprecation cycle for this one. For clarity: TRL's public API is what's in the docs. This helper isn't, even though it's importable from trl. I trimmed the PR to the removal (dropped the to_openai_messages change and its tests, nothing in TRL reaches it with a missing content) and merged main.

@qgallouedec
qgallouedec merged commit 6ced2d2 into main Oct 2, 2026
11 checks passed
@qgallouedec
qgallouedec deleted the fix/6928-remove-dead-prepare-multimodal-vllm branch October 2, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prepare_multimodal_messages_vllm fails on content-less tool-call messages

2 participants