-
Notifications
You must be signed in to change notification settings - Fork 11
[feat] support aiter pa for Qwen3.5 GA module in decode phase #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Qwen3.5_v0.5.9
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import logging | ||
| from typing import TYPE_CHECKING | ||
| from sglang.srt.utils import get_bool_env_var | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -221,6 +222,14 @@ def attn_backend_wrapper(runner: "ModelRunner", full_attn_backend: "AttentionBac | |
| "Expected hybrid GDN or NemotronH models, but got unknown model." | ||
| ) | ||
| full_attn_layers = cfg.full_attention_layer_ids | ||
| if get_bool_env_var("SGLANG_USE_AITER_PA"): | ||
| from sglang.srt.layers.attention.aiter_backend import AiterAttnBackend | ||
| return HybridLinearAttnBackend( | ||
| full_attn_backend, | ||
| linear_attn_backend, | ||
| full_attn_layers, | ||
| AiterAttnBackend(runner), | ||
| ) | ||
|
Comment on lines
+225
to
+232
|
||
| return HybridLinearAttnBackend( | ||
| full_attn_backend, linear_attn_backend, full_attn_layers | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1567,11 +1567,16 @@ def __init__( | |
| full_attn_backend: AttentionBackend, | ||
| linear_attn_backend: MambaAttnBackendBase, | ||
| full_attn_layers: list[int], | ||
| full_attn_decode_backend: Optional[AttentionBackend] = None, | ||
| ): | ||
| self.full_attn_layers = full_attn_layers | ||
| self.full_attn_backend = full_attn_backend | ||
| self.linear_attn_backend = linear_attn_backend | ||
| self.attn_backend_list = [full_attn_backend, linear_attn_backend] | ||
| self.full_attn_decode_backend = None | ||
| if full_attn_decode_backend is not None: | ||
| self.full_attn_decode_backend = full_attn_decode_backend | ||
| self.attn_backend_list += [full_attn_decode_backend] | ||
|
|
||
| def init_forward_metadata(self, forward_batch: ForwardBatch): | ||
| for attn_backend in self.attn_backend_list: | ||
|
|
@@ -1643,9 +1648,14 @@ def forward_decode( | |
| ): | ||
| layer_id = layer.layer_id if layer else kwargs["layer_id"] | ||
| if layer_id in self.full_attn_layers: | ||
| return self.full_attn_backend.forward_decode( | ||
| q, k, v, layer, forward_batch, save_kv_cache, **kwargs | ||
| ) | ||
| if self.full_attn_decode_backend is not None: | ||
| return self.full_attn_decode_backend.forward_decode( | ||
| q, k, v, layer, forward_batch, save_kv_cache, **kwargs | ||
| ) | ||
|
Comment on lines
+1651
to
+1654
|
||
| else: | ||
| return self.full_attn_backend.forward_decode( | ||
| q, k, v, layer, forward_batch, save_kv_cache, **kwargs | ||
| ) | ||
| # Linear attention backend | ||
| return self.linear_attn_backend.forward_decode( | ||
| q=q, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This v_head_dim selection is based on specific model configs (
hybrid_gdn_config/kimi_linear_config), but the underlying issue is whethertoken_to_kv_pool.get_value_buffer(0)is valid (it can raise forHybridLinearKVPoolwhen layer 0 isn’t a full-attention layer). To avoid reintroducing the same loader failure for other hybrid models (e.g., NemotronH / other mambaish configs), prefer a capability-based check likehasattr(token_to_kv_pool, "get_v_head_dim")(orisinstance(..., HybridLinearKVPool)) and useget_v_head_dim()when available.