Repository navigation
Launch the CLI, docs and examples with torchrun instead of accelerate launch - #7180
Conversation
… launch `trl <cmd>` hands the arguments its script does not know to torchrun (`--nproc_per_node`, `--nnodes`, ...), defaulting to one process per accelerator; a single process runs as `python script.py`. DeepSpeed and FSDP go through the training arguments (`--deepspeed`, `--fsdp`), so the shipped accelerate yamls become `examples/deepspeed_configs/*.json` and `examples/fsdp_configs/fsdp2.json`. The 1M-context example sets its context-parallel config in the SFTConfig.
# Conflicts: # docs/source/nash_md_trainer.md # docs/source/prm_trainer.md # docs/source/tpo_trainer.md # docs/source/xpo_trainer.md
accelerate launch: the CLI, docs and examples launch with torchrun
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
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. Pages changed in this PR:
|
albertvillanova
left a comment
There was a problem hiding this comment.
Thanks for the PR. A few issues need addressing before this can be merged:
- A bare
--fsdpon the command line only works on transformers >= 5.10 (huggingface/transformers#45640). Below that,fsdprequires a value, sotrl sft ... --fsdpfails with "expected one argument", and our floor is 4.56.2. This affects the# or --fsdplines inclis.mdandexample_overview.md.fsdp=Truein Python andfsdp: truein YAML work on all supported versions. Could we add a short note? --accelerate_config zero2used a config shipped in the package. The newexamples/deepspeed_configs/zero2.jsononly exists in a repo clone, so users who installed with pip have no ready config. Maybe inline the minimal JSON inclis.md?- Nit:
torch.distributed.run.main([...])instead ofrun(parse_args(...))keeps torchrun's@recorderror reporting and is shorter.
Launch the FSDP checkpoint test from #7939 with torchrun, with FSDP set in the training arguments
…rmers 5.10, and inline a ZeRO-2 config for pip installs
|
Thanks, addressed in 9979734:
|
|
Thanks, the three points are addressed. Before merging:
|
# Conflicts: # examples/async_distillation_mopd/async_distillation_mopd.py # examples/sft_gpt_oss/sft_gpt_oss.py # tests/experimental/test_async_grpo_trainer.py
|
Thanks, done: the chess example now sets |
# Conflicts: # tests/experimental/test_async_distillation_trainer.py
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 633f97f. Configure here.

trl <cmd>now launches its training script with torchrun, and the docs and examples follow. Arguments the script does not know go to torchrun (--nproc_per_node,--nnodes, ...), and DeepSpeed and FSDP are set through the training arguments (--deepspeed zero3.json,--fsdp), like for anyTrainer.accelerate launchkeeps working. Until v2.0.0,trlstill uses it, with aFutureWarning, for arguments only accelerate knows (--num_processes,--accelerate_config) and when anaccelerate configdefault file exists.examples/accelerate_configs/becomesexamples/deepspeed_configs/*.jsonandexamples/fsdp_configs/fsdp2.json.tests/distributed49 passed, the 12 Liger tests skipped) and on Trainium2 with 4 NeuronCores (torchrun 1.84 s/step, accelerate 1.82).Note
Medium Risk
Broad user-facing change to distributed entry points and config layout; deprecated accelerate paths may hide breakage until v2.0.0, but core training logic is largely unchanged.
Overview
trl <cmd>now launches training withtorchruninstead ofaccelerate launch, forwarding unrecognized flags (e.g.--nproc_per_node) to the launcher and enabling DeepSpeed/FSDP via standard training args (--deepspeed,--fsdp), aligned with TransformersTrainer. Single-GPU runs invoke the script directly without rendezvous; multi-GPU defaults to all visible devices unless--nproc_per_nodeis set.Legacy
accelerate launchremains until v2.0.0 when torchrun rejects args (--num_processes,--accelerate_config) or a defaultaccelerate configfile exists, with aFutureWarning.Docs, examples, and shared configs are migrated: launch snippets use
torchrun(orpythonfor async trainers); CLI scaling docs drop--accelerate_configprofiles in favor ofexamples/deepspeed_configs/*.jsonandexamples/fsdp_configs/;examples/accelerate_configs/is removed. Several scripts gain--deepspeedparsing or in-codedeepspeed/fsdp/ParallelismConfigsettings. Distributed tests and invariant harnesses launch viatorchrunand JSON FSDP/DeepSpeed configs.Reviewed by Cursor Bugbot for commit 633f97f. Bugbot is set up for automated code reviews on this repo. Configure here.