[Perf] Remove redundant clone for GLM, Deepseek etc (#46651)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2026-06-25 13:09:00 -07:00
committed by GitHub
parent e8e7b592d1
commit 8b4d93ba2b
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -649,7 +649,7 @@ class AXK1DecoderLayer(nn.Module):
) -> tuple[torch.Tensor, torch.Tensor]:
# Self Attention
if residual is None:
residual = hidden_states.clone()
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
else:
hidden_states, residual = self.input_layernorm(hidden_states, residual)
+1 -1
View File
@@ -1186,7 +1186,7 @@ class DeepseekV2DecoderLayer(nn.Module):
) -> torch.Tensor:
# Self Attention
if residual is None:
residual = hidden_states.clone()
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
else:
hidden_states, residual = self.input_layernorm(hidden_states, residual)
+1 -1
View File
@@ -184,7 +184,7 @@ class Glm4MoeLiteDecoderLayer(nn.Module):
) -> torch.Tensor:
# Self Attention
if residual is None:
residual = hidden_states.clone()
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
else:
hidden_states, residual = self.input_layernorm(hidden_states, residual)
+1 -1
View File
@@ -935,7 +935,7 @@ class OpenPanguDecoderLayer(nn.Module):
residual: torch.Tensor | None,
) -> torch.Tensor:
if residual is None:
residual = hidden_states.clone()
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
else:
hidden_states, residual = self.input_layernorm(hidden_states, residual)