fix: don't re-flatten vLLM server completion_ids in Online DPO#6146
Open
vineethsaivs wants to merge 1 commit into
Open
fix: don't re-flatten vLLM server completion_ids in Online DPO#6146vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
OnlineDPOTrainer._generate_vllm_server re-flattened the completion_ids returned by the vLLM client, which is already a list[list[int]] with one token-id list per completion (the same shape the colocate path and GRPO produce). The comprehension iterated over every completion and every token, turning each token into its own single-token completion, which corrupts the completion mask and the per-process row count. Remove the re-flatten so completion_ids is passed through unchanged. Added a CPU regression test that mocks the vLLM client and the distributed gather/broadcast and asserts each completion is preserved. Fixes huggingface#5514
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.
What does this PR do?
OnlineDPOTrainer._generate_vllm_serverre-flattened the vLLM client'scompletion_ids:VLLMClient.generate(...)["completion_ids"]already returns alist[list[int]]with one token-id list per completion (the same shape the colocate path produces and that GRPO uses). The comprehension iterated over every completion and every token, so a completion like[101, 102, 103]became three single-token "completions"[101], [102], [103]. Downstream that makescompletion_mask[1, 0, 0, ...]for every row and throws off the per-process row count. The colocate path (_generate_vllm_colocate) andGRPOTrainernever apply this extra flatten, so server-mode Online DPO was the only inconsistent path. This removes the re-flatten socompletion_idsis passed through unchanged, and adds a CPU regression test.This supersedes the abandoned draft #5516 (a WIP with the same one-line removal, untouched since April); I commented on the issue first to coordinate.
Fixes #5514
Before submitting
AI writing disclosure
Who can review?
Anyone in the community is free to review the PR once the tests have passed.
Note
Low Risk
Small behavioral fix in experimental Online DPO vLLM server path only; aligns with colocate behavior and is covered by a targeted unit test.
Overview
Fixes vLLM server-mode Online DPO generation where
_generate_vllm_serverincorrectly re-flattenedVLLMClient.generate’scompletion_ids. The client already returnslist[list[int]](one full token sequence per completion, same as colocate/GRPO); the removed comprehension treated each token as its own completion, breakingcompletion_maskand per-process row counts._generate_vllm_servernow passescompletion_idsthrough unchanged after the main-process generate call. A CPU regression test (test_generate_vllm_server_preserves_completion_token_lists) stubs gather/broadcast and the vLLM client to assert multi-token completions stay intact.Reviewed by Cursor Bugbot for commit 6a9f32a. Bugbot is set up for automated code reviews on this repo. Configure here.