[MM] Pass prefix parameter to MMEncoderAttention (#33674)

Signed-off-by: shen-shanshan <467638484@qq.com>
This commit is contained in:
Shanshan Shen
2026-02-03 06:47:41 -08:00
committed by GitHub
parent f3d8a34671
commit 5c4f2dd6ef
15 changed files with 58 additions and 11 deletions
+12 -2
View File
@@ -170,6 +170,7 @@ class InternSdpaAttention(nn.Module):
config: PretrainedConfig,
*,
num_dummy_heads: int = 0,
prefix: str = "",
) -> None:
super().__init__()
@@ -215,7 +216,12 @@ class InternSdpaAttention(nn.Module):
self.projection_layer = nn.Linear(self.dummy_dim, self.embed_dim)
# Use unified MMEncoderAttention with automatic backend selection
self.attn = MMEncoderAttention(self.num_heads, self.head_dim, self.scale)
self.attn = MMEncoderAttention(
self.num_heads,
self.head_dim,
self.scale,
prefix=prefix,
)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""x shape: (B, N, C)"""
@@ -313,7 +319,11 @@ class InternS1VisionLayer(nn.Module):
num_dummy_heads: int,
prefix: str = "",
):
return InternSdpaAttention(config, num_dummy_heads=num_dummy_heads)
return InternSdpaAttention(
config,
num_dummy_heads=num_dummy_heads,
prefix=prefix,
)
def forward(
self,