Revert "Fix hybrid linear attention misrouting plain-RadixAttention linear layers to the full backend (Ring-2.5-1T)" (#27116)
This commit is contained in:
@@ -782,17 +782,22 @@ class HybridLinearAttnBackend(AttentionBackend):
|
||||
self.req_to_token_pool = full_attn_backend.req_to_token_pool
|
||||
|
||||
def _is_full_attn(
|
||||
self,
|
||||
layer: Optional[Union[RadixAttention, RadixLinearAttention]],
|
||||
layer_id: Optional[int] = None,
|
||||
self, layer: Optional[RadixAttention], layer_id: Optional[int] = None
|
||||
) -> bool:
|
||||
# RadixLinearAttention is unambiguously a linear-attention layer.
|
||||
# Everything else (including plain RadixAttention) must be classified by
|
||||
# layer id: models like Bailing/Ring use a plain RadixAttention for their
|
||||
# linear layers, so an `isinstance(layer, RadixAttention) -> full` shortcut
|
||||
# would misroute those linear layers to the full-attention backend.
|
||||
# Explicit linear-attention subclass → strong linear signal (KDA, GDN,
|
||||
# Qwen3-Next, Qwen3.5 main linear layers).
|
||||
if isinstance(layer, RadixLinearAttention):
|
||||
return False
|
||||
# Some hybrid models (Ling-2.5/2.6) wrap their linear layers in plain
|
||||
# `RadixAttention` rather than `RadixLinearAttention`. Those wrappers
|
||||
# set `_is_linear_attention=True` on the attn module so we can
|
||||
# distinguish them from full-attention RadixAttention instances —
|
||||
# including MTP/NEXTN draft layers, which are full and must default to
|
||||
# the full-attn path.
|
||||
if layer is not None and getattr(layer, "_is_linear_attention", False):
|
||||
return False
|
||||
if isinstance(layer, RadixAttention):
|
||||
return True
|
||||
|
||||
if layer is not None:
|
||||
layer_id = layer.layer_id
|
||||
|
||||
@@ -508,6 +508,12 @@ class BailingMoELinearAttention(nn.Module):
|
||||
quant_config=quant_config,
|
||||
prefix=f"{prefix}.attn",
|
||||
)
|
||||
# Marker for HybridLinearAttnBackend._is_full_attn: Bailing wraps
|
||||
# linear-attention layers in a plain RadixAttention, so the
|
||||
# dispatcher can't tell from the type alone that this is a linear
|
||||
# layer (would otherwise default to the full-attn backend, e.g. the
|
||||
# same way MTP/NEXTN draft layers are routed).
|
||||
self.attn._is_linear_attention = True
|
||||
|
||||
self.group_norm_size = getattr(config, "group_norm_size", 1)
|
||||
self.rms_norm_eps = float(getattr(config, "rms_norm_eps", 1e-5))
|
||||
|
||||
Reference in New Issue
Block a user