fix(qwen4_exp): fall back QSA to full attention under sequence parallelism - #184
Closed
ehooon wants to merge 1 commit into
Closed
fix(qwen4_exp): fall back QSA to full attention under sequence parallelism#184ehooon wants to merge 1 commit into
ehooon wants to merge 1 commit into
Conversation
…elism With sequence_parallel=True and TP>1, the QSA indexer consumes SP-sharded hidden states (s/tp) while TE core attention runs on the all-gathered full sequence, so the [b, 1, s, s] selection mask mismatches the q/k length and the unfused path crashes on a logical_or shape error. Fall back QSA layers to full attention in this configuration, with a one-time warning that training beyond the indexer budget differs from sparse inference.
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.
Related to #178.
With
sequence_parallel=Trueand TP>1, the QSA indexer consumesSP-sharded hidden states (s/tp) while TE core attention runs on the
all-gathered full sequence. The
[b, 1, s, s]selection mask thenmismatches q/k length and the unfused path crashes on
logical_or.This is a parallel-layout bug; bf16 and FP8 both hit it.
QSA layers now fall back to full attention in this config, with a
one-time warning that training beyond the indexer budget differs
from sparse inference — same pattern as the packing/padding_free
and CP fallbacks above it.
This is a safety fallback, not an SP-aware QSA. Sequences longer
than the indexer budget (2048) are trained with dense attention.
Verified: Megatron LoRA SFT, Qwen3.8-Flash-Next-FP8, 2 GPU
(TP=2+SP, EP=2, ETP=1, PP=1, CP=1). Training proceeds with the
fallback active.