[AMD] Qwen3.5: guard attn layers against empty DP-attention batch (#34474)

Co-authored-by: jacky.cheng <yichiche@amd.com>
This commit is contained in:
Zhaoyi Li
2026-08-15 21:28:13 -07:00
committed by GitHub
co-authored by jacky.cheng
parent 66de161976
commit 24ab8f9ed9
+6 -3
View File
@@ -693,7 +693,10 @@ class Qwen3_5GatedDeltaNet(nn.Module):
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 = core_attn_out.reshape(*core_attn_out.shape[:-2], -1) core_attn_out = core_attn_out.reshape(
*core_attn_out.shape[:-2],
core_attn_out.shape[-2] * core_attn_out.shape[-1],
)
output, _ = self.out_proj(core_attn_out) output, _ = self.out_proj(core_attn_out)
return output return output
@@ -800,7 +803,7 @@ class Qwen3_5LinearDecoderLayer(nn.Module):
) )
) )
if not forward_batch.forward_mode.is_idle(): if not forward_batch.forward_mode.is_idle() and hidden_states.shape[0] > 0:
hidden_states = self.linear_attn( hidden_states = self.linear_attn(
hidden_states, hidden_states,
forward_batch, forward_batch,
@@ -1204,7 +1207,7 @@ class Qwen3_5AttentionDecoderLayer(nn.Module):
) )
) )
if not forward_batch.forward_mode.is_idle(): if not forward_batch.forward_mode.is_idle() and hidden_states.shape[0] > 0:
hidden_states = self.self_attention( hidden_states = self.self_attention(
positions=positions, positions=positions,
hidden_states=hidden_states, hidden_states=hidden_states,