Skip to content

serve: fall back to sequential generation for models continuous batching can't run - #51215

Open
tarekziade wants to merge 1 commit into
mainfrom
serve-cb-fallback
Open

tarekziade wants to merge 1 commit into
mainfrom
serve-cb-fallback

Conversation

@tarekziade

@tarekziade tarekziade commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

transformers serve --continuous-batching sends every text model to continuous batching (CB). CB's cache only has allocators for full_attention and sliding_attention layers, so a hybrid model such as Qwen3-Next (linear_attention layers) passes serve's check and then fails on the first request with ValueError: Invalid layer type: linear_attention.

This PR:

  • adds unsupported_layer_types(config) to the CB cache module and uses it to give the CB error a clear message: Continuous batching does not support linear_attention layers (supported: full_attention, sliding_attention);
  • makes serve check it before choosing CB, and fall back to sequential generation with a warning that says why, as it already does for vision-language models.

Tests use MIC fixtures (small models built from the real checkpoints' configs): huggingface-mic/Qwen3-30B-A3B-mic (MoE, still uses CB) and huggingface-mic/Qwen3-Next-80B-A3B-Instruct-mic (hybrid, falls back). Reproduced on main with both fixtures before the change: the MoE runs generate_batch, the hybrid raises.

Supporting linear-attention layers in CB itself is a separate, larger change.

🤖 Generated with Claude Code

@tarekziade tarekziade self-assigned this Nov 25, 2026
@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