Repository navigation
Remove the unreachable prepare_multimodal_messages_vllm - #6946
Conversation
…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
|
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. |
…prepare-multimodal-vllm
|
That does not contradict the dead-code reading. In TRL's own call graph it is dead: on TRL has removed public symbols before, in two steps. XPO, PPO, ORPO, PRM, and Judges were each deprecated first with a 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. |
…prepare-multimodal-vllm
…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
left a comment
There was a problem hiding this comment.
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.
Assistant tool-call messages without
contentcaused a key error in the live vLLM message conversion path. I made that path preserve these messages and removed the unusedprepare_multimodal_messages_vllmhelper 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_vllmhelper 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 fromtrl/__init__.py, andTestPrepareMultimodalMessagesVLLMplus the relatedcopyimports are deleted from tests. Multimodal prep stays onprepare_multimodal_messages(including tool-call turns withoutcontent, 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.