Skip to content

fix(qwen4_exp): fall back QSA to full attention under sequence parallelism - #184

Closed
ehooon wants to merge 1 commit into
modelscope:mainfrom
ehooon:fix-qwen4-exp-qsa-sp
Closed

fix(qwen4_exp): fall back QSA to full attention under sequence parallelism#184
ehooon wants to merge 1 commit into
modelscope:mainfrom
ehooon:fix-qwen4-exp-qsa-sp

Conversation

@ehooon

@ehooon ehooon commented Sep 3, 2026

Copy link
Copy Markdown

Related to #178.

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. The [b, 1, s, s] selection mask then
mismatches 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.

…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.
@ehooon ehooon closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant