Ask transformers whether a model supports context parallelism - #4198
Open
qgallouedec wants to merge 3 commits into
Open
Ask transformers whether a model supports context parallelism#4198qgallouedec wants to merge 3 commits into
qgallouedec wants to merge 3 commits into
Conversation
|
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
approved these changes
Sep 1, 2026
SunMarc
left a comment
Member
There was a problem hiding this comment.
That would be the better solution but let's see if this is worth adding it in transformers itself.
qgallouedec
marked this pull request as ready for review
September 7, 2026 21:48
Member
Author
|
Holding this until #4209 lands, then rebuilding it on top, two changes:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4177, and depends on huggingface/transformers#48442. Draft until that merges.
#4177 pattern-matches
layer_typesandsliding_windowfrom inside accelerate. @SunMarc noted in review that this belongs in transformers, and huggingface/transformers#48442 addssupports_context_parallelfor 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 = Falseto 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_parallelismalone on purpose.supports_context_parallelis alsoFalsefor 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.