Skip to content

Require accelerate>=1.10.1 and drop the ParallelismConfig shim - #7643

Merged
albertvillanova merged 3 commits into
mainfrom
require-accelerate-1-10-1
Oct 13, 2026
Merged

albertvillanova merged 3 commits into
mainfrom
require-accelerate-1-10-1

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

This PR raises the accelerate floor from 1.4.0 (February 2025) to 1.10.1 (August 2025) and removes the compatibility code that floor required.

Part of #7644.

Motivation

accelerate 1.4.0 is 20 months old, so it falls under the second case of the criterion in #7116: weigh how hard the old version is to keep against who still depends on it. What it costs us is one monkeypatching shim and four version guards, and nothing pulls users towards an accelerate that old, since transformers only asks for >=1.1.0. That makes it the "hard to keep, few users" case.

1.10.1 is the newest release the 1-year rule allows today, at 14 months old.

Solution

_patch_transformers_parallelism_config existed because transformers below 4.57.0 only imports ParallelismConfig when accelerate is at least 1.10.1, and typing.get_type_hints then raises NameError on TrainingArguments. Its own docstring gives the exit condition this PR meets. With the floor at 1.10.1 the guard can never be true, so the patch and its call at import time both go.

The five ParallelismConfig.tp_size guards, and the context-parallelism check in SFT, are unconditional for the same reason. Two of the five tested accelerate>=1.12.0, although Accelerator.parallelism_config has existed since 1.10.0, so under tensor parallelism on 1.10.1 to 1.11.x they were silently falling back to tp_size = 1.

Changes

  • Raise accelerate>=1.4.0 to >=1.10.1
  • Remove _patch_transformers_parallelism_config from trl/_compat.py and the call that applied it
  • Read parallelism_config.tp_size without a version test in the DPO, KTO, SFT and reward trainers and in the experimental TPO trainer, keeping the five blocks identical
  • Run the SFT packing and context-parallelism check unconditionally

The accelerate>=1.11.0 and >=1.12.0 guards stay, since both are above this floor.


Note

Low Risk
Dependency floor bump may break installs pinned to accelerate<1.10.1; runtime behavior is simplified, not redesigned.

Overview
Raises the minimum accelerate dependency from 1.4.0 to 1.10.1 in pyproject.toml and pins accelerate==1.10.1 in the CI minimum-versions job.

With that floor, TRL drops legacy compatibility code: the _patch_transformers_parallelism_config import-time shim in trl/_compat.py (it papered over missing ParallelismConfig on older accelerate/transformers pairs) is removed entirely.

Several trainers (DPO, KTO, SFT, Reward, and experimental TPO) stop gating on accelerate version when reading accelerator.parallelism_config.tp_size for token-count correction under tensor parallelism. SFT likewise always enforces the packing vs. context-parallelism conflict instead of only when accelerate ≥ 1.10.1. Unused accelerate imports tied to those guards are cleaned up. Guards for newer accelerate features (e.g. 1.12.0 sequence parallelism) are unchanged.

Reviewed by Cursor Bugbot for commit 1d2ebd9. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

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.

@qgallouedec

Copy link
Copy Markdown
Member

Thanks. Two more copies of the TP block still guard on 1.12.0:

# computed, so they need no such correction. `parallelism_config` requires accelerate 1.12.0.
if Version(accelerate.__version__) >= Version("1.12.0") and self.accelerator.parallelism_config is not None:

# computed, so they need no such correction. `parallelism_config` requires accelerate 1.12.0.
if Version(accelerate.__version__) >= Version("1.12.0") and self.accelerator.parallelism_config is not None:

The comment is wrong: Accelerator.parallelism_config is already in 1.10.1 https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/accelerator.py#L760-L762
So they can drop the guard too, and the five copies stay identical. As is, on accelerate 1.10.1 to 1.11.x they fall back to _tp_size = 1 under TP.

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

Feel free to merge when the above comment is addressed

@albertvillanova

Copy link
Copy Markdown
Member Author

Good catch, both are fixed. Accelerator.parallelism_config and ParallelismConfig.tp_size are both there in 1.10.0, so the 1.12.0 test had no basis: those two copies were falling back to tp_size = 1 under TP on 1.10.1 to 1.11.x and over-counting num_tokens. All five blocks are identical now, and import accelerate goes with the guard in both files.

The three remaining accelerate>=1.12.0 tests in sft_trainer.py read sp_enabled or sp_backend, which really were added in 1.12.0, so those stay.

@albertvillanova
albertvillanova merged commit 9041256 into main Oct 13, 2026
11 checks passed
@albertvillanova
albertvillanova deleted the require-accelerate-1-10-1 branch October 13, 2026 13:51
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