"vscode:/vscode.git/clone" did not exist on "a2986b3e337cb83676700fd4e76a6548e96e874b"
Unverified Commit 9fb27dd3 authored by Shanshan Shen's avatar Shanshan Shen Committed by GitHub
Browse files

[MM] Align the prefix of MMEncoderAttention with Attention (#33750)


Signed-off-by: default avatarshen-shanshan <467638484@qq.com>
parent 4dffc5e0
...@@ -130,7 +130,7 @@ class AIMv2Attention(nn.Module): ...@@ -130,7 +130,7 @@ class AIMv2Attention(nn.Module):
self.num_heads_per_partition, self.num_heads_per_partition,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward(self, x: torch.Tensor) -> torch.Tensor: def forward(self, x: torch.Tensor) -> torch.Tensor:
......
...@@ -126,7 +126,7 @@ class BlipAttention(nn.Module): ...@@ -126,7 +126,7 @@ class BlipAttention(nn.Module):
self.num_heads_per_partition, self.num_heads_per_partition,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int): def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
......
...@@ -296,7 +296,7 @@ class Glm4vVisionAttention(nn.Module): ...@@ -296,7 +296,7 @@ class Glm4vVisionAttention(nn.Module):
num_heads=self.num_attention_heads_per_partition, num_heads=self.num_attention_heads_per_partition,
head_size=self.hidden_size_per_attention_head, head_size=self.hidden_size_per_attention_head,
scale=self.hidden_size_per_attention_head**-0.5, scale=self.hidden_size_per_attention_head**-0.5,
prefix=prefix, prefix=f"{prefix}.attn",
) )
self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True) self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True)
......
...@@ -139,7 +139,7 @@ class EVA2CLIPAttention(nn.Module): ...@@ -139,7 +139,7 @@ class EVA2CLIPAttention(nn.Module):
self.num_heads_per_rank, self.num_heads_per_rank,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
self.output_dropout = torch.nn.Dropout(config.dropout_prob) self.output_dropout = torch.nn.Dropout(config.dropout_prob)
......
...@@ -137,6 +137,7 @@ class GlmOcrVisionAttention(nn.Module): ...@@ -137,6 +137,7 @@ class GlmOcrVisionAttention(nn.Module):
num_heads=self.num_attention_heads_per_partition, num_heads=self.num_attention_heads_per_partition,
head_size=self.hidden_size_per_attention_head, head_size=self.hidden_size_per_attention_head,
scale=self.hidden_size_per_attention_head**-0.5, scale=self.hidden_size_per_attention_head**-0.5,
prefix=f"{prefix}.attn",
) )
self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True) self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True)
......
...@@ -166,7 +166,7 @@ class Idefics2VisionAttention(nn.Module): ...@@ -166,7 +166,7 @@ class Idefics2VisionAttention(nn.Module):
self.num_heads_per_partition, self.num_heads_per_partition,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward( def forward(
......
...@@ -215,7 +215,7 @@ class InternParallelAttention(nn.Module): ...@@ -215,7 +215,7 @@ class InternParallelAttention(nn.Module):
self.num_heads_per_partition, self.num_heads_per_partition,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def _apply_qk_norm(self, q: torch.Tensor, k: torch.Tensor): def _apply_qk_norm(self, q: torch.Tensor, k: torch.Tensor):
......
...@@ -220,7 +220,7 @@ class InternSdpaAttention(nn.Module): ...@@ -220,7 +220,7 @@ class InternSdpaAttention(nn.Module):
self.num_heads, self.num_heads,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward(self, x: torch.Tensor) -> torch.Tensor: def forward(self, x: torch.Tensor) -> torch.Tensor:
......
...@@ -257,7 +257,7 @@ class Llama4VisionAttention(nn.Module): ...@@ -257,7 +257,7 @@ class Llama4VisionAttention(nn.Module):
self.num_local_heads, self.num_local_heads,
self.head_dim, self.head_dim,
self.scaling, self.scaling,
prefix=prefix, prefix=f"{prefix}.attn",
) )
if use_data_parallel: if use_data_parallel:
......
...@@ -235,7 +235,7 @@ class MultiHeadDotProductAttention(nn.Module): ...@@ -235,7 +235,7 @@ class MultiHeadDotProductAttention(nn.Module):
self.head_dim, self.head_dim,
self.scale, self.scale,
num_kv_heads=self.num_kv_heads, num_kv_heads=self.num_kv_heads,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward( def forward(
......
...@@ -611,7 +611,7 @@ class ImagePoolingAttention(nn.Module): ...@@ -611,7 +611,7 @@ class ImagePoolingAttention(nn.Module):
self.head_dim, self.head_dim,
self.scale, self.scale,
num_kv_heads=self.num_kv_heads, num_kv_heads=self.num_kv_heads,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward_sdpa( def forward_sdpa(
......
...@@ -125,6 +125,7 @@ class OpenPanguVisionAttention(nn.Module): ...@@ -125,6 +125,7 @@ class OpenPanguVisionAttention(nn.Module):
num_heads=self.num_attention_heads_per_partition, num_heads=self.num_attention_heads_per_partition,
head_size=self.hidden_size_per_attention_head, head_size=self.hidden_size_per_attention_head,
scale=self.hidden_size_per_attention_head**-0.5, scale=self.hidden_size_per_attention_head**-0.5,
prefix=f"{prefix}.attn",
) )
self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True) self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True)
......
...@@ -345,7 +345,7 @@ class Qwen2_5_VisionAttention(nn.Module): ...@@ -345,7 +345,7 @@ class Qwen2_5_VisionAttention(nn.Module):
num_heads=self.num_attention_heads_per_partition, num_heads=self.num_attention_heads_per_partition,
head_size=self.hidden_size_per_attention_head, head_size=self.hidden_size_per_attention_head,
scale=self.hidden_size_per_attention_head**-0.5, scale=self.hidden_size_per_attention_head**-0.5,
prefix=prefix, prefix=f"{prefix}.attn",
) )
self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True) self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True)
......
...@@ -319,7 +319,7 @@ class Qwen2VisionAttention(nn.Module): ...@@ -319,7 +319,7 @@ class Qwen2VisionAttention(nn.Module):
num_heads=self.num_attention_heads_per_partition, num_heads=self.num_attention_heads_per_partition,
head_size=self.hidden_size_per_attention_head, head_size=self.hidden_size_per_attention_head,
scale=self.hidden_size_per_attention_head**-0.5, scale=self.hidden_size_per_attention_head**-0.5,
prefix=prefix, prefix=f"{prefix}.attn",
) )
self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True) self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True)
......
...@@ -194,7 +194,7 @@ class Qwen3OmniMoeAudioAttention(nn.Module): ...@@ -194,7 +194,7 @@ class Qwen3OmniMoeAudioAttention(nn.Module):
num_heads=self.num_local_heads, num_heads=self.num_local_heads,
head_size=self.head_dim, head_size=self.head_dim,
scale=self.scaling, scale=self.scaling,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward( def forward(
......
...@@ -763,7 +763,7 @@ class Step3VisionAttention(nn.Module): ...@@ -763,7 +763,7 @@ class Step3VisionAttention(nn.Module):
self.num_heads, self.num_heads,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
def forward( def forward(
......
...@@ -224,7 +224,7 @@ class PerceptionEncoderVisionAttention(nn.Module): ...@@ -224,7 +224,7 @@ class PerceptionEncoderVisionAttention(nn.Module):
self.num_heads, self.num_heads,
self.head_dim, self.head_dim,
self.scale, self.scale,
prefix=prefix, prefix=f"{prefix}.attn",
) )
self.rope = PerceptionEncoderRope2D( self.rope = PerceptionEncoderRope2D(
dim=self.head_dim, dim=self.head_dim,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment