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

This commit is contained in:
Baizhou Zhang
2026-03-19 18:03:04 -07:00
committed by GitHub
parent 8d22efdeea
commit 42f4b7276c
5 changed files with 0 additions and 111 deletions
@@ -252,14 +252,6 @@ class BaseMultimodalProcessor(ABC):
MM_ITEM_MEMORY_POOL_RECYCLE_INTERVAL,
)
def compute_mrope_positions(self, input_ids, mm_items):
"""Compute M-RoPE positions from expanded input_ids and multimodal items.
Returns (mrope_positions, mrope_position_delta) or (None, None) if the
model does not use M-RoPE.
"""
return None, None
@property
def spatial_merge_size(self):
return self.hf_config.vision_config.spatial_merge_size
@@ -357,24 +357,6 @@ class Ernie4_5_VLImageProcessor(SGLangBaseProcessor):
return result
def compute_mrope_positions(self, input_ids, mm_items):
image_grid_thw = None
video_grid_thw = None
for item in mm_items:
if "image_grid_thw" in item.model_specific_data:
image_grid_thw = item.model_specific_data["image_grid_thw"]
if "video_grid_thw" in item.model_specific_data:
video_grid_thw = item.model_specific_data["video_grid_thw"]
input_ids_tensor = torch.tensor(input_ids, dtype=torch.long).unsqueeze(0)
mrope_positions, mrope_position_delta = MRotaryEmbedding.get_rope_index_ernie45(
input_ids=input_ids_tensor,
hf_config=self.hf_config,
image_grid_thw=image_grid_thw,
video_grid_thw=video_grid_thw,
)
return mrope_positions.squeeze(1), mrope_position_delta
async def process_mm_data_async(
self,
image_data: List[Union[str, bytes]],
@@ -59,28 +59,6 @@ class Glm4vImageProcessor(SGLangBaseProcessor):
video_token_id=self.IM_TOKEN_ID,
).build(_processor)
def compute_mrope_positions(self, input_ids, mm_items):
image_grid_thw = None
video_grid_thw = None
for item in mm_items:
if "image_grid_thw" in item.model_specific_data:
image_grid_thw = item.model_specific_data["image_grid_thw"]
if "video_grid_thw" in item.model_specific_data:
video_grid_thw = item.model_specific_data["video_grid_thw"]
import torch
input_ids_tensor = torch.tensor(input_ids, dtype=torch.long).unsqueeze(0)
attention_mask = torch.ones_like(input_ids_tensor)
mrope_positions, mrope_position_delta = MRotaryEmbedding.get_rope_index_glm4v(
input_ids=input_ids_tensor,
hf_config=self.hf_config,
image_grid_thw=image_grid_thw,
video_grid_thw=video_grid_thw,
attention_mask=attention_mask,
)
return mrope_positions.squeeze(1), mrope_position_delta
async def process_mm_data_async(
self,
image_data: List[Union[str, bytes]],
@@ -369,31 +369,6 @@ class QwenVLImageProcessor(SGLangBaseProcessor):
return input_ids, offsets, modality_list
def compute_mrope_positions(self, input_ids, mm_items):
image_grid_thw = None
video_grid_thw = None
for item in mm_items:
if "image_grid_thw" in item.model_specific_data:
image_grid_thw = item.model_specific_data["image_grid_thw"]
if "video_grid_thw" in item.model_specific_data:
video_grid_thw = item.model_specific_data["video_grid_thw"]
input_ids_tensor = torch.tensor(input_ids, dtype=torch.long).unsqueeze(0)
mrope_positions, mrope_position_delta = MRotaryEmbedding.get_rope_index(
spatial_merge_size=self.hf_config.vision_config.spatial_merge_size,
image_token_id=self.mm_tokens.image_token_id,
video_token_id=self.mm_tokens.video_token_id,
vision_start_token_id=self.vision_start_token_id,
model_type=self.model_type,
tokens_per_second=getattr(
self.hf_config.vision_config, "tokens_per_second", None
),
input_ids=input_ids_tensor,
image_grid_thw=image_grid_thw,
video_grid_thw=video_grid_thw,
)
return mrope_positions.squeeze(1), mrope_position_delta
def get_mm_data(self, prompt, embeddings, **kwargs):
img_grid_thw = kwargs.get("img_grid_thw", None)
video_grid_thw = kwargs.get("video_grid_thw", None)