[model] refactor qwen3.5 GDN to use FLA causal conv1d and cu_seq_lens_q - #176
Open
ys2025-AI wants to merge 1 commit into
Open
[model] refactor qwen3.5 GDN to use FLA causal conv1d and cu_seq_lens_q#176ys2025-AI wants to merge 1 commit into
ys2025-AI wants to merge 1 commit into
Conversation
- Add FLA causal_conv1d as the conv function for packed sequences - Pass cu_seq_lens_q directly to forward, removing manual padding/unpadding - Derive layer_types from linear_attention_freq in __init__ - Use layer_number-1 to match HF indexing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
src/mcore_bridge/model/mm_gpts/qwen3_5.py__init__hybrid-arch adaptation: auto-deriveconfig.layer_typesfromlinear_attention_freq(int → per-layer list); passlayer_number - 1to the HF parent (0-basedlayer_idx).self.causal_conv1d_fn = self._fla_conv_fn, which routes FLAcausal_conv1d(..., cu_seqlens=self._cur_cu_seqlens)— gives the conv sequence-boundary isolation in varlen (solves cross-sample state leakage thatattention_maskcannot fully prevent on GDN's recurrent state).[1, total, D]and passescu_seq_lens_qtosuper().forward(...)instead of un-padding to a padded batch + repacking after. Verified the parentQwen3_5MoeGatedDeltaNet.forward(transformers ≥5.14.1,modeling_qwen3_5_moe.py:546) consumeskwargs["cu_seq_lens_q"]→chunk_gated_delta_rule(cu_seqlens=...), and FLAcausal_conv1dsupportscu_seqlens(signature verified), so both conv and delta-rule run varlen.