Add supports_context_parallel to PreTrainedModel - #48442
Open
qgallouedec wants to merge 2 commits into
Open
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. |
Contributor
CI recapDashboard: View test results in Grafana |
ArthurZucker
approved these changes
Sep 1, 2026
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, but this belongs in the DistributedMixin? (or not? TrainingMixing would be a better name?)
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.
@SunMarc suggested in huggingface/accelerate#4177 that this check belongs here rather than in accelerate
It reads
layer_typesandsliding_window, which are transformers concepts, and there is already_supports_sdpa/_supports_flex_attnfor this kind of capability flag.CP can only express full causal attention. A layer with a stricter mask (sliding-window, chunked) gets that mask dropped and silently trains as full causal, and a layer carrying a recurrent state along the sequence (linear attention) never has that state exchanged between ranks.
huggingface/accelerate#4177 currently pattern-matches the config to detect this. With this property it becomes
if not model.supports_context_parallel: raise._supports_context_parallel = Falsealso lets a model rule it out whatever its config, which the config check cannot express (gpt-oss, where attention sinks need a custom kernel).