[Core] Simplify multimodal masking (#34246)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
@@ -719,16 +719,6 @@ class GPUModelRunner(
|
||||
self.max_num_reqs, dtype=torch.int32
|
||||
)
|
||||
|
||||
# Only relevant for multimodal models
|
||||
if self.supports_mm_inputs:
|
||||
# Double buffer to avoid race condition: previous iteration's async
|
||||
# copy may still be reading from CPU while current iteration writes.
|
||||
self.is_mm_embed_buffers = [
|
||||
self._make_buffer(self.max_num_tokens, dtype=torch.bool),
|
||||
self._make_buffer(self.max_num_tokens, dtype=torch.bool),
|
||||
]
|
||||
self.is_mm_embed_idx = 0
|
||||
|
||||
# Only relevant for models using M-RoPE (e.g, Qwen2-VL)
|
||||
if self.uses_mrope:
|
||||
# NOTE: `mrope_positions` is implemented with one additional dummy
|
||||
@@ -2910,14 +2900,10 @@ class GPUModelRunner(
|
||||
) -> tuple[list[torch.Tensor], torch.Tensor]:
|
||||
total_num_scheduled_tokens = scheduler_output.total_num_scheduled_tokens
|
||||
|
||||
# Swap to the other buffer to avoid race condition with previous
|
||||
# iteration's async copy that may still be reading from CPU.
|
||||
self.is_mm_embed_idx = 1 - self.is_mm_embed_idx
|
||||
is_mm_embed_buf = self.is_mm_embed_buffers[self.is_mm_embed_idx]
|
||||
|
||||
mm_embeds = list[torch.Tensor]()
|
||||
is_mm_embed = is_mm_embed_buf.cpu
|
||||
is_mm_embed[:total_num_scheduled_tokens] = False
|
||||
is_mm_embed = torch.zeros(
|
||||
total_num_scheduled_tokens, dtype=torch.bool, device="cpu"
|
||||
)
|
||||
|
||||
req_start_idx = 0
|
||||
should_sync_mrope_positions = False
|
||||
@@ -3000,8 +2986,6 @@ class GPUModelRunner(
|
||||
mm_embeds.extend(mm_embeds_req)
|
||||
req_start_idx += num_scheduled_tokens
|
||||
|
||||
is_mm_embed = is_mm_embed_buf.copy_to_gpu(total_num_scheduled_tokens)
|
||||
|
||||
if should_sync_mrope_positions:
|
||||
self._calc_mrope_positions(scheduler_output)
|
||||
self.mrope_positions.copy_to_gpu(total_num_scheduled_tokens)
|
||||
|
||||
Reference in New Issue
Block a user