Skip to content

[rl] SGLang engine: take the request's Prompt and the vision_processor argument - #6024

Merged
acisseJZhong merged 1 commit into
mainfrom
wwwjn/rl-sglang-engine-prompt
Nov 11, 2026
Merged

acisseJZhong merged 1 commit into
mainfrom
wwwjn/rl-sglang-engine-prompt

Conversation

@wwwjn

@wwwjn wwwjn commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

#5824 changed the generation engine interface for image prompts, and the SGLang engine (#5812), which landed on main while #5824 was in review, kept the old one:

  • EngineRequest.prompt_token_ids: list[int] became EngineRequest.prompt: Prompt (tokens plus images). SGLangEngine.add_requests still reads request.prompt_token_ids (3 places).
  • Generator passes vision_processor= to every engine's build. SGLangEngine.__init__ has no such parameter.

Example. On main, any generator with engine=SGLangEngine.Config():

Generator setup -> config.engine.build(..., vision_processor=None, ...)
  TypeError: SGLangEngine.__init__() got an unexpected keyword argument 'vision_processor'

and, past that, every request: AttributeError: 'EngineRequest' object has no attribute 'prompt_token_ids'.

What changed

  • SGLangEngine takes vision_processor: VisionProcessor.Config | None (as VLLMEngine does) and raises a ValueError unless it is None: SGLang serves text prompts only, and image prompts need VLLMEngine.
  • add_requests reads request.prompt.token_ids once and uses it for the range check, the sampling params and SGLang's input_ids.
  • test_sglang_bitwise_parity.py builds requests with Prompt(token_ids=...) and passes vision_processor=None to the engine's build.

Testing

  • No local environment has SGLang, so I could not run its tests here. A static check (AST of the sources) of the keyword arguments Generator passes to engine.build against SGLangEngine.__init__'s parameters: on main, vision_processor is missing; with this PR, nothing is.
  • pre-commit on the two files passes.
  • CI: the RL B200 workflow runs test_sglang_bitwise_parity.py (SGLang installed); it needs the ciflow/rl label.

…r argument

#5824 changed the generation engine interface for image prompts:
`EngineRequest.prompt_token_ids` became `EngineRequest.prompt` (a `Prompt`), and
`Generator` passes `vision_processor` to every engine's build. The SGLang engine,
which landed on main while #5824 was in review, kept the old interface: building it
fails with "unexpected keyword argument 'vision_processor'", and every request would
fail reading `prompt_token_ids`.

- `SGLangEngine` takes `vision_processor` and raises unless it is None: it serves text
  prompts only.
- It reads the request's `prompt.token_ids`.
- `test_sglang_bitwise_parity` builds requests with `Prompt` and passes
  `vision_processor=None`.
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 11, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 11, 2026 00:51
del generator_name, output_dir
if vision_processor is not None:
raise ValueError(
"SGLangEngine serves text prompts only; image prompts "

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BandAid fix for now - Just make API compatible.

I will ask agent to test multimodal sglang too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants