Skip to content

Ask transformers whether a model supports context parallelism - #4198

Open
qgallouedec wants to merge 3 commits into
mainfrom
use-supports-context-parallel
Open

Ask transformers whether a model supports context parallelism#4198
qgallouedec wants to merge 3 commits into
mainfrom
use-supports-context-parallel

Conversation

@qgallouedec

Copy link
Copy Markdown
Member

Follow-up to #4177, and depends on huggingface/transformers#48442. Draft until that merges.

#4177 pattern-matches layer_types and sliding_window from inside accelerate. @SunMarc noted in review that this belongs in transformers, and huggingface/transformers#48442 adds supports_context_parallel for it. This swaps the inline check for that property.

It also picks up something the config check could not express: a model can set _supports_context_parallel = False to rule context parallelism out whatever its config, which is the case for gpt-oss (attention sinks need a custom kernel that SDPA cannot provide).

Defaults to allowed when the property is absent, so an older transformers behaves exactly as it does today.

Leaves _refuse_recurrent_layers_under_sequence_parallelism alone on purpose. supports_context_parallel is also False for sliding-window models, and I have not verified that those are broken under Ulysses, so reusing it there would refuse models that may well work.

@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.

@SunMarc SunMarc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be the better solution but let's see if this is worth adding it in transformers itself.

@qgallouedec
qgallouedec marked this pull request as ready for review September 7, 2026 21:48
@qgallouedec

Copy link
Copy Markdown
Member Author

Holding this until #4209 lands, then rebuilding it on top, two changes:

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.

3 participants