Skip to content

Continuous batching: find the sharded key/value projections under any decoder path - #50366

Open
qgallouedec wants to merge 1 commit into
mainfrom
cb-tp-vlm-kv-heads
Open

qgallouedec wants to merge 1 commit into
mainfrom
cb-tp-vlm-kv-heads

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

What does this PR do?

Under tensor parallelism, continuous batching decides whether the key/value heads are split across ranks by looking up layers.*.self_attn.k_proj or model.layers.*.self_attn.k_proj in the TP plan. A vision-language model's keys start with model.language_model., so the engine sizes the cache with every head on every rank and the first forward fails. Found running Qwen3.5-2B and 4B (VLM checkpoints) at tp=2 on B200: k has wrong shape at dim 2 on flash, a shape mismatch on sdpa. The lookup now matches the key suffix.

  • New test: the check holds for a causal LM and a VLM (Gemma 3) plan; the VLM case fails on main.

… decoder path

A vision-language model's TP plan keys start with model.language_model., so the engine took its key/value heads as
replicated and sized the cache with all of them on every rank: Qwen3.5 at tp=2 fails on the first decode step.
@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.

This branch has not been deployed

No deployments
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.

2 participants