fix fused_set_kv_buffer for rope with Ling-v2 (#20316)

This commit is contained in:
strgrb
2026-03-23 19:20:40 +08:00
committed by GitHub
parent 4641e5a3d2
commit 80d4a0753a
+6 -2
View File
@@ -532,6 +532,10 @@ class BailingMoEAttention(nn.Module):
head_dim=self.head_dim,
alt_stream=self.alt_stream,
)
can_fuse_set_kv = (
self.head_dim == self.rotary_emb.rotary_dim
and enable_fused_set_kv_buffer(forward_batch)
)
q, k = self.rotary_emb(
positions,
q,
@@ -542,7 +546,7 @@ class BailingMoEAttention(nn.Module):
layer=self.attn,
forward_batch=forward_batch,
)
if enable_fused_set_kv_buffer(forward_batch)
if can_fuse_set_kv
else None
),
)
@@ -551,7 +555,7 @@ class BailingMoEAttention(nn.Module):
k,
v,
forward_batch,
save_kv_cache=not enable_fused_set_kv_buffer(forward_batch),
save_kv_cache=not can_fuse_set_kv,
)
attn_output, _ = self.dense(context_layer)
return attn_output