[Model] [Perf] Use flatten for Qwen3.5's GDN output projection (#42311)
Signed-off-by: Rishapveer Singh <singhrishapveer@gmail.com>
This commit is contained in:
@@ -680,7 +680,7 @@ class GatedDeltaNetAttention(PluggableLayer, MambaBase):
|
|||||||
z = z.reshape(-1, z.shape[-1])
|
z = z.reshape(-1, z.shape[-1])
|
||||||
core_attn_out = self.norm(core_attn_out, z)
|
core_attn_out = self.norm(core_attn_out, z)
|
||||||
core_attn_out = core_attn_out.reshape(z_shape_og)
|
core_attn_out = core_attn_out.reshape(z_shape_og)
|
||||||
core_attn_out = rearrange(core_attn_out, "... h d -> ... (h d)")
|
core_attn_out = core_attn_out.flatten(-2) # ... h d -> ... (h d)
|
||||||
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
||||||
|
|
||||||
def forward_hip(
|
def forward_hip(
|
||||||
@@ -828,7 +828,7 @@ class GatedDeltaNetAttention(PluggableLayer, MambaBase):
|
|||||||
z = z.reshape(-1, z.shape[-1])
|
z = z.reshape(-1, z.shape[-1])
|
||||||
core_attn_out = self.norm(core_attn_out, z)
|
core_attn_out = self.norm(core_attn_out, z)
|
||||||
core_attn_out = core_attn_out.reshape(z_shape_og)
|
core_attn_out = core_attn_out.reshape(z_shape_og)
|
||||||
core_attn_out = rearrange(core_attn_out, "... h d -> ... (h d)")
|
core_attn_out = core_attn_out.flatten(-2) # ... h d -> ... (h d)
|
||||||
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
||||||
|
|
||||||
def forward_cpu(
|
def forward_cpu(
|
||||||
@@ -878,7 +878,7 @@ class GatedDeltaNetAttention(PluggableLayer, MambaBase):
|
|||||||
z = z.reshape(-1, z.shape[-1])
|
z = z.reshape(-1, z.shape[-1])
|
||||||
core_attn_out = self.norm(core_attn_out, z)
|
core_attn_out = self.norm(core_attn_out, z)
|
||||||
core_attn_out = core_attn_out.reshape(z_shape_og)
|
core_attn_out = core_attn_out.reshape(z_shape_og)
|
||||||
core_attn_out = rearrange(core_attn_out, "... h d -> ... (h d)")
|
core_attn_out = core_attn_out.flatten(-2) # ... h d -> ... (h d)
|
||||||
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
output[:num_tokens], _ = self.out_proj(core_attn_out)
|
||||||
|
|
||||||
def _warmup_prefill_kernels(self, qkv_or_qkvz: torch.Tensor, v_dim: int) -> None:
|
def _warmup_prefill_kernels(self, qkv_or_qkvz: torch.Tensor, v_dim: int) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user