Repository navigation
Add supports_context_parallel to PreTrainedModel - #48442
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. |
ArthurZucker
left a comment
There was a problem hiding this comment.
LGTM, but this belongs in the DistributedMixin? (or not? TrainingMixing would be a better name?)
|
Kept it in PreTrainedModel on purpose: it's a capability flag, and those all live there today ( |
CI recapDashboard: View test results in Grafana |
Add supports_context_parallel to PreTrainedModel
@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).