Skip to content

EP: keep attention replicated when tp_size cannot split the KV heads (v5.19 regression) - #49632

Closed
dacorvo wants to merge 1 commit into
mainfrom
ep-replicate-unsplittable-attention
Closed

dacorvo wants to merge 1 commit into
mainfrom
ep-replicate-unsplittable-attention

Conversation

@dacorvo

@dacorvo dacorvo commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🤗 Transformers CI

Fixes #49628.

Fix. In resolve_parallel_plans, under expert parallelism, when get_kv_heads_per_rank reports that tp_size cannot split the KV heads, the attention rules are dropped from the TP plan (and from model.tp_plan, which generate uses to size the static cache) with a warning. Attention stays replicated as in v5.18; embeddings, lm_head, the dense MLPs and the experts are sharded as on main. Models whose heads divide are unchanged, and so is pure TP (ep_size=1).

Tests. test_expert_parallel_keeps_unsplittable_attention_replicated resolves the plans of a tiny Qwen3-MoE with 2 and 4 KV heads at tp_size=ep_size=4; test_expert_parallel_forward_with_fewer_kv_heads_than_ranks runs the 2-KV-head model on 4 gloo ranks and compares the logits with a single process.

cc @ArthurZucker @vasqu @3outeille @IlyasMoutawwakil

…not split the KV heads

Since #48859 (v5.19), `tp_size=ep_size=N` also applies the TP plan, so a
MoE with fewer KV heads than N (gemma-4-26B-A4B-it, Qwen3.5-35B-A3B at 8
ranks) crashes at the first attention view; up to v5.18 expert parallelism
left attention whole. Under EP, when the KV heads cannot be split by
`tp_size`, drop the attention rules from the TP plan and warn, and keep
the rest of the plan.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 38713953927
Result: success | Grafana metrics are not available yet.

@dacorvo

dacorvo commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

After discussing with @ArthurZucker and @IlyasMoutawwakil, the correct fix at this stage is #49633

@dacorvo dacorvo closed this Oct 15, 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.

[Regression] EP no longer leaves attention replicated (v5.19)

2 participants