Repository navigation
[Data][LLM] Add multimodal support to SGLang engine path - #67543
vijit-vishnoi wants to merge 2 commits into
Conversation
Signed-off-by: vijit-vishnoi <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces multimodal support (images, audio, and video) to the SGLang engine processor by adding a new preprocessing stage, updating request and output schemas, and forwarding media arguments to the underlying engine. It also adds comprehensive unit tests to validate input extraction, error handling, and schema alignment. The review feedback highlights two valuable improvement opportunities: simplifying a redundant conditional dictionary retrieval for embeddings, and unconditionally popping all potential media keys from the input row to prevent memory leaks when alternative media columns are present.
| generated_text=output["text"] if "text" in output else None, | ||
| num_generated_tokens=output["meta_info"]["completion_tokens"], | ||
| num_generated_tokens=meta_info["completion_tokens"], | ||
| embeddings=output.get("embedding", None) if "embedding" in output else None, |
There was a problem hiding this comment.
The conditional expression output.get("embedding", None) if "embedding" in output else None is redundant. Since dict.get() already returns None (or a specified default) if the key is missing, this can be simplified to a direct .get() call.
| embeddings=output.get("embedding", None) if "embedding" in output else None, | |
| embeddings=output.get("embedding"), |
| direct_image = row.pop("image_data", None) | ||
| if direct_image is None: | ||
| direct_image = row.pop("image", None) | ||
| if direct_image is None: | ||
| direct_image = row.pop("images", None) | ||
|
|
||
| direct_audio = row.pop("audio_data", None) | ||
| if direct_audio is None: | ||
| direct_audio = row.pop("audio", None) | ||
|
|
||
| direct_video = row.pop("video_data", None) | ||
| if direct_video is None: | ||
| direct_video = row.pop("video", None) |
There was a problem hiding this comment.
To prevent memory leaks and ensure large media payloads do not linger in the dataset, all potential media columns should be unconditionally popped from the row. In the current implementation, if image_data is present and not None, the image and images keys are never popped, which could leave large media blobs in the row.
image_data_val = row.pop("image_data", None)
image_val = row.pop("image", None)
images_val = row.pop("images", None)
direct_image = image_data_val if image_data_val is not None else (image_val if image_val is not None else images_val)
audio_data_val = row.pop("audio_data", None)
audio_val = row.pop("audio", None)
direct_audio = audio_data_val if audio_data_val is not None else audio_val
video_data_val = row.pop("video_data", None)
video_val = row.pop("video", None)
direct_video = video_data_val if video_data_val is not None else video_valThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 8a64692. Configure here.
…t requirement Signed-off-by: vijit-vishnoi <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |

Description
Currently, the
SGLangEngineProcessorConfiginray.data.llmsilently degrades to text-only when passed rows containing media columns (images, video, audio).This PR adds full multimodal support to the SGLang engine path, ensuring a batch job mixing text and media can be run on either the vLLM or SGLang engine using the exact same column conventions and expected output schema.
Related issues
Fixes #66928
Additional information
Implementation Details:
PrepareMultimodalStageinto the SGLang processor builder to ensure pipeline preprocessing parity with vLLM.multimodal_data,image_data, etc.) from the row in_prepare_llm_request.ValueErrorfor unsupported modalities or conflicting media inputs rather than silently ignoring them.SGLangOutputDatawithvLLMOutputData(addedembeddings,logprobs,prompt_logprobs, andmetrics).Testing:
test_sglang_engine_stage.pyverifying fail-closed logic, media popping, schema alignment, and kwarg forwarding.test_sglang_engine_proc.pyfor pipeline stage ordering.(Note: AI assistance was utilized during the development and testing of this patch).