Fix Qwen3.5 hybrid attention and add torch GDN fallback - #497
Open
ruijieguo wants to merge 1 commit into
Open
Conversation
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.
Qwen3.5 hybrid attention can fail when tensor parallelism exceeds the number of KV heads. With 24 query heads, four KV heads and TP=8, Megatron-Core 0.16.0 returns three query heads but six output-gate heads per rank. Slice the gate to the same rank-local heads as the query, while preserving results from Megatron versions that already do this correctly.
Add an explicit
additional_configs.gdn_backend: torchoption for environments where the fused causal-conv1d or FLA delta-rule kernels are unsuitable. It selects Megatron's existing PyTorch paths only for Qwen3.5 GDN layers. The default remainsfla, other layers retain their deterministic settings, and checkpoint parameter names are unchanged. FLA is still required for its L2-normalization kernel.Includes eight distributed regression cases and a reproducible text SFT example for Qwen3.6-27B and Qwen3.8-27B, whose configs use the
qwen3_5architecture.Validation on eight H800 80 GB GPUs:
AutoModel.from_pretrainedand produced finite logits in an eight-rank forward pass.git diff --checkpassed.Tested with PyTorch 2.10.0+cu130, Megatron-Core 0.16.0, Transformers 5.5.4, Transformer Engine 2.14.1 and flash-linear-attention 0.5.0. The example uses TP=8, CP=1 and sequence parallelism, with packing disabled. The arithmetic data exercise execution and checkpointing; these runs do not establish model quality, long-run stability, or RLVR/DPO/vision support. The PyTorch GDN fallback may be slower and use more memory.