Repository navigation
Send the generated response when continuing a multimodal partial rollout - #2500
Open
apex-mochen wants to merge 1 commit into
Open
apex-mochen wants to merge 1 commit into
apex-mochen wants to merge 1 commit into
Conversation
With --partial-rollout, an aborted sample is resumed with its accumulated sample.tokens and a max_new_tokens budget reduced by response_length. For samples with images, generate() and generate_streaming() still sent only text=sample.prompt, so SGLang generated a fresh response from the prompt and the new tokens were appended after the old partial response. Send text only for the first segment, so SGLang still expands the image placeholders with its own processor; continuations send sample.tokens with the images, the form on_policy_distillation already sends to SGLang. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
With
--partial-rollout, a sample aborted mid-generation goes back to the data buffer and is resumed later.generate()resumes it with amax_new_tokensbudget reduced bysample.response_lengthand appends the new tokens after the existing response, so the request must be conditioned on that response.For samples with images, the request is built as:
sample.promptdoes not include the response generated so far, so SGLang starts a fresh response from the prompt. The new tokens are then appended after the old partial response. The resulting trajectory is spliced: its second half was not generated after its first half, and its rollout log probabilities are taken under a different context.generate_streaming()builds the request the same way.Nothing rejects
--partial-rolloutwith multimodal data, andabort()recycles any aborted group with a non-empty response, including groups with images.A test that resumes an image sample after one generated token shows it: the request carries
text="describe the picture", noinput_ids, andmax_new_tokens=7(8 - 1). The generated token is appended as[9, 3, 4].Fix
Send
textonly for the first segment (response_length == 0), so SGLang still expands the image placeholders with its own processor rules. A continuation sendsinput_ids=list(sample.tokens)with the images.sample.tokensholds the prompt and the response so far. This is the formon_policy_distillation.reward_funcalready sends to SGLang.I used
sample.tokensrather thanprompt_idson purpose. For an image sample withoutmultimodal_train_inputs,_prepare_prompt_idsre-processes the prompt, and the result does not include the response.Test
tests/test_multimodal_partial_rollout.pyruns the realsglang_rollout.generatewithpost,GenerateStateand image encoding mocked:input_ids == [9, 3], the images, notext, andmax_new_tokens == 7;textand noinput_ids.The first case fails on
main(540ea91) and passes with this change.CPU only, with this machine's dependencies:
main: 20 failed, 46 passed;The only difference between the two failure lists is the new test. The other 19 fail the same way on both trees because of the environment.
Not covered: I did not run a real SGLang server, and the new test does not cover
generate_streaming, which has the same one-line change.🤖 Generated with Claude Code