[Mypy Fix] Mypy fix for "vllm/model_executor/models/[cC][dD]" (#52003)
This commit is contained in:
@@ -66,7 +66,7 @@ class Cosmos3EdgeVisionEncoder(Siglip2VisionTransformer):
|
||||
def dtype(self) -> torch.dtype:
|
||||
return self.embeddings.patch_embedding.weight.dtype
|
||||
|
||||
def forward(
|
||||
def encode(
|
||||
self,
|
||||
pixel_values: torch.Tensor,
|
||||
grid_thw: torch.Tensor,
|
||||
@@ -253,7 +253,7 @@ class Cosmos3EdgeVisionModel(nn.Module):
|
||||
grid_thw: torch.Tensor | list[list[int]],
|
||||
) -> torch.Tensor:
|
||||
grid_thw = torch.as_tensor(grid_thw, dtype=torch.int64, device="cpu")
|
||||
image_embeds = self.encoder(pixel_values.type(self.dtype), grid_thw=grid_thw)
|
||||
image_embeds = self.encoder.encode(pixel_values.type(self.dtype), grid_thw)
|
||||
image_embeds = patch_merging_by_param(
|
||||
image_embeds,
|
||||
grid_thw,
|
||||
@@ -315,11 +315,10 @@ class Cosmos3EdgeAttention(NemotronHAttention):
|
||||
rope_parameters=config.rope_parameters,
|
||||
)
|
||||
|
||||
def forward(
|
||||
def forward_with_positions(
|
||||
self,
|
||||
positions: torch.Tensor,
|
||||
hidden_states: torch.Tensor,
|
||||
**kwargs,
|
||||
) -> torch.Tensor:
|
||||
qkv, _ = self.qkv_proj(hidden_states)
|
||||
q, k, v = qkv.split([self.q_size, self.kv_size, self.kv_size], dim=-1)
|
||||
@@ -367,7 +366,7 @@ class Cosmos3EdgeAttentionDecoderLayer(nn.Module):
|
||||
hidden_states = self.norm(hidden_states)
|
||||
else:
|
||||
hidden_states, residual = self.norm(hidden_states, residual)
|
||||
hidden_states = self.mixer(positions=positions, hidden_states=hidden_states)
|
||||
hidden_states = self.mixer.forward_with_positions(positions, hidden_states)
|
||||
return hidden_states, residual
|
||||
|
||||
|
||||
@@ -562,6 +561,7 @@ class Cosmos3EdgeForConditionalGeneration(
|
||||
config = vllm_config.model_config.hf_config
|
||||
quant_config = vllm_config.quant_config
|
||||
multimodal_config = vllm_config.model_config.multimodal_config
|
||||
assert multimodal_config is not None
|
||||
|
||||
self.config = config
|
||||
self.multimodal_config = multimodal_config
|
||||
@@ -619,6 +619,8 @@ class Cosmos3EdgeForConditionalGeneration(
|
||||
image_grid_thw=image_grid_thw,
|
||||
)
|
||||
|
||||
raise AssertionError
|
||||
|
||||
def _parse_and_validate_video_input(
|
||||
self, **kwargs: object
|
||||
) -> Qwen2_5_VLVideoInputs | None:
|
||||
@@ -645,6 +647,8 @@ class Cosmos3EdgeForConditionalGeneration(
|
||||
video_grid_thw=video_grid_thw,
|
||||
)
|
||||
|
||||
raise AssertionError
|
||||
|
||||
def _process_image_input(
|
||||
self, image_input: Qwen2_5_VLImageInputs
|
||||
) -> tuple[torch.Tensor, ...]:
|
||||
@@ -684,7 +688,7 @@ class Cosmos3EdgeForConditionalGeneration(
|
||||
return self._get_image_features(pixel_values_videos, grid_thw)
|
||||
|
||||
def _parse_and_validate_multimodal_inputs(self, **kwargs: object) -> dict:
|
||||
modalities = {}
|
||||
modalities: dict = {}
|
||||
image_input = self._parse_and_validate_image_input(**kwargs)
|
||||
if image_input is not None:
|
||||
modalities["image"] = image_input
|
||||
|
||||
Reference in New Issue
Block a user