Skip to content

Commit 8b54b52

Browse files
refactor(linear_attn): extract GDN into shared LinearAttBackend (#1390)
Co-authored-by: wangzaijun <wzjhelloworld@qq.com>
1 parent 8cbb20a commit 8b54b52

30 files changed

Lines changed: 539 additions & 415 deletions

lightllm/common/basemodel/attention/base_att.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class AttControl:
7070
nsa_prefill_dict: Dict = None
7171
nsa_decode: bool = False
7272
nsa_decode_dict: Dict = None
73+
# linear attention 专用传参项
74+
linear_att_prefill: bool = False
75+
linear_att_prefill_dict: Dict = None
76+
linear_att_decode: bool = False
77+
linear_att_decode_dict: Dict = None
7378

7479

7580
@dataclass
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .gdn import (
2+
LinearAttBackend,
3+
LinearAttPrefillAttState,
4+
LinearAttDecodeAttState,
5+
)
6+
7+
__all__ = [
8+
"LinearAttBackend",
9+
"LinearAttPrefillAttState",
10+
"LinearAttDecodeAttState",
11+
]

lightllm/common/basemodel/attention/linear/gdn.py

Lines changed: 376 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Linear-attention / GDN triton kernels shared across hybrid models."""
2+
3+
from .causal_conv1d import causal_conv1d_fn
4+
from .causal_conv1d_spec import causal_conv1d_update
5+
from .fused_gdn_gating import fused_gdn_gating
6+
from .gdn_decode_pack import conv_pack_gdn_decode_inputs
7+
from .mtp_fused_recurrent import mtp_fused_recurrent_gated_delta_rule
8+
from .fla.ops import chunk_gated_delta_rule, fused_recurrent_gated_delta_rule
9+
10+
__all__ = [
11+
"causal_conv1d_fn",
12+
"causal_conv1d_update",
13+
"fused_gdn_gating",
14+
"conv_pack_gdn_decode_inputs",
15+
"mtp_fused_recurrent_gated_delta_rule",
16+
"chunk_gated_delta_rule",
17+
"fused_recurrent_gated_delta_rule",
18+
]

lightllm/models/qwen3next/triton_kernel/causal_conv1d.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/causal_conv1d.py

File renamed without changes.

lightllm/models/qwen3next/triton_kernel/causal_conv1d_spec.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/causal_conv1d_spec.py

File renamed without changes.

lightllm/models/qwen3next/triton_kernel/fla/__init__.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/fla/__init__.py

File renamed without changes.

lightllm/models/qwen3next/triton_kernel/fla/ops/__init__.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/fla/ops/__init__.py

File renamed without changes.

lightllm/models/qwen3next/triton_kernel/fla/ops/chunk.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/fla/ops/chunk.py

File renamed without changes.

lightllm/models/qwen3next/triton_kernel/fla/ops/chunk_delta_h.py renamed to lightllm/common/basemodel/triton_kernel/linear_att/fla/ops/chunk_delta_h.py

File renamed without changes.

0 commit comments

Comments
 (0)