Skip to content

feat(mm)(grpc): compute M-RoPE positions for preprocessed VL inputs#19973

Merged
slin1237 merged 3 commits intomainfrom
fix/grpc-mrope
Mar 18, 2026
Merged

feat(mm)(grpc): compute M-RoPE positions for preprocessed VL inputs#19973
slin1237 merged 3 commits intomainfrom
fix/grpc-mrope

Conversation

@CatherineSue
Copy link
Copy Markdown
Collaborator

Motivation

Qwen VL, GLM4V, and ERNIE4.5-VL models use Multi-dimensional Rotary Position Encoding (M-RoPE) which requires mrope_positions computed from image_grid_thw and the expanded input_ids. The normal HTTP path computes this inside the model's multimodal processor (e.g., QwenVLProcessor), but the gRPC preprocessed path bypasses the processor entirely, leaving mrope_positions as None and crashing in _compute_mrope_positions.

Modifications

Rather than adding model-specific M-RoPE logic into grpc_server.py (which would defeat the purpose of a generic gRPC interface), this PR:

  • Adds compute_mrope_positions() to BaseMultimodalProcessor with a default no-op, overridden by QwenVLProcessor, GLM4VProcessor, and ERNIE45VLProcessor
  • Loads the mm_processor in the scheduler (same pattern as vLLM)
  • Calls compute_mrope_positions() as a fallback when mrope_positions is None after multimodal input setup
  • Keeps grpc_server.py fully model-agnostic

Accuracy Tests

N/A - This is a bug fix that enables gRPC preprocessed inputs to work with M-RoPE models. The M-RoPE position computation logic is identical to what the processors already compute in the HTTP path.

Benchmarking and Profiling

N/A - No performance-critical code path is modified. The M-RoPE position computation only runs when mrope_positions is None (gRPC preprocessed path fallback).

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@CatherineSue
Copy link
Copy Markdown
Collaborator Author

/tag-run-ci-label

@github-actions github-actions Bot added the run-ci label Mar 5, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@CatherineSue CatherineSue changed the title fix(grpc): compute M-RoPE positions for preprocessed VL inputs feat(mm)(grpc): compute M-RoPE positions for preprocessed VL inputs Mar 5, 2026
@slin1237
Copy link
Copy Markdown
Collaborator

slin1237 commented Mar 6, 2026

/tag-and-rerun-ci

yhyang201
yhyang201 previously approved these changes Mar 6, 2026
@yhyang201 yhyang201 self-requested a review March 6, 2026 03:32
Comment thread python/sglang/srt/managers/scheduler.py Outdated
if self.model_config.is_multimodal and self.processor is not None:
try:
from sglang.srt.managers.multimodal_processor import (
get_mm_processor,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: move this to the top of this file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed. Sorry for the late reply.

req.origin_input_ids, image_inputs
)
req.extend_image_inputs(image_inputs)
self._maybe_compute_mrope_positions(req)
Copy link
Copy Markdown
Collaborator

@mickqian mickqian Mar 6, 2026

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This link points to the initialization logic rather than the computation logic. Is it duplicated with this section?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree it is a bit duplicated. I couldn't think of a clear design due to the lack of familarity with the code here. Happy to refine this if you could point a direction.

Copy link
Copy Markdown
Collaborator

@mickqian mickqian left a comment

Choose a reason for hiding this comment

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

brilliant

@slin1237
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci,

@slin1237
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

The gRPC preprocessed path bypasses the model's multimodal processor,
which normally computes M-RoPE positions during processing. Instead of
adding model-specific M-RoPE logic to grpc_server.py (which defeats
the purpose of a generic gRPC interface), this commit:

- Adds compute_mrope_positions() to BaseMultimodalProcessor with a
  default no-op, overridden by QwenVL, GLM4V, and ERNIE4.5 processors
- Loads the mm_processor in the scheduler (same pattern as vLLM)
- Calls compute_mrope_positions() as a fallback when mrope_positions
  is None after multimodal input setup
- Reverts all M-RoPE specific code from grpc_server.py, keeping it
  fully model-agnostic

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Signed-off-by: Chang Su <chang.s.su@oracle.com>
@slin1237
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@slin1237 slin1237 merged commit 0d23a46 into main Mar 18, 2026
190 of 213 checks passed
@slin1237 slin1237 deleted the fix/grpc-mrope branch March 18, 2026 22:34
Wangzheee pushed a commit to Wangzheee/sglang that referenced this pull request Mar 21, 2026
…gl-project#19973)

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Chang Su <chang.s.su@oracle.com>
0-693 pushed a commit to 0-693/sglang that referenced this pull request Mar 25, 2026
…gl-project#19973)

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Chang Su <chang.s.su@oracle.com>
dutsc pushed a commit to dutsc/sglang that referenced this pull request Mar 30, 2026
…gl-project#19973)

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Chang Su <chang.s.su@oracle.com>
JustinTong0323 pushed a commit to JustinTong0323/sglang that referenced this pull request Apr 7, 2026
…gl-project#19973)

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Chang Su <chang.s.su@oracle.com>
yhyang201 pushed a commit to yhyang201/sglang that referenced this pull request Apr 22, 2026
…gl-project#19973)

Signed-off-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Chang Su <chang.s.su@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants