[Exploratory] Drop accelerate launch: the CLI, docs and examples launch with torchrun - #7180
Draft
qgallouedec wants to merge 1 commit into
Draft
[Exploratory] Drop accelerate launch: the CLI, docs and examples launch with torchrun#7180qgallouedec wants to merge 1 commit into
accelerate launch: the CLI, docs and examples launch with torchrun#7180qgallouedec wants to merge 1 commit into
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.
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.
Why
Important
This does not drop support for
accelerate launch. accelerate stays a dependency andaccelerate launch train.pykeeps working, with its config files. What changes is the default: the launcher thetrlCLI uses and the one the docs and examples show is torchrun.For multi-GPU CUDA,
accelerate launchis a wrapper aroundtorch.distributed.run: it reads a config file, setsACCELERATE_*env vars, then calls torchrun. What it adds on top:accelerate config) holding num_processes, mixed precision and the DeepSpeed/FSDP plugin settingsxla_spawn, DeepSpeed pdsh multi-node, MPI, SageMaker,notebook_launcherFor a
Trainer-based library none of this is needed:TrainingArgumentsalready builds the DeepSpeed and FSDP plugins from--deepspeed/--fsdp/--bf16, and TRL only supports CUDA in practice. So TRL users end up learning a second config format (accelerate yaml) that duplicates the training arguments, and users who know torchrun have to guess how--num_processesmaps to--nproc_per_node. Launching with torchrun directly removes that layer and makes the CLI, docs and examples say the same thing as the rest of the PyTorch ecosystem.What does this PR do?
trl <cmd>now launches its training script withtorchruninstead ofaccelerate launch, and every launch command in the docs and examples follows.trl/cli/commands/training.py: arguments the script does not know go to torchrun (--nproc_per_node,--nnodes,--master_port, ...), from the command line or from the--configYAML. Defaults to one process per accelerator. With no launcher argument and a single device, the script runs aspython script.py(whataccelerate launchdid too), so nothing opens a rendezvous port.trl/cli/accelerate_launcher.py,trl/cli/accelerate_config.py,--accelerate_configand the shippedtrl/accelerate_configs/*.yaml. DeepSpeed and FSDP are configured through the training arguments like anytransformers.Trainer:--deepspeed zero3.json,--fsdp [--fsdp_config fsdp2.json].examples/accelerate_configs/becomesexamples/deepspeed_configs/zero{1,2,3}.jsonandexamples/fsdp_configs/fsdp2.json(same settings as the accelerate plugin defaults:autobatch sizes, bf16auto, ZeRO-3 gathers 16-bit weights on save).alst_ulysses_4gpu.yamlandcontext_parallel_2gpu.yamlhad no user and are gone. The 1M-context example setsfsdp=True, parallelism_config=ParallelismConfig(cp_size=8)in itsSFTConfiginstead of the yaml (parallelism_configis not CLI-parsable).trl envno longer prints the accelerate default config.tests/distributed:torchrun --nproc_per_node 2 ... --deepspeed/--fsdpwith minimal JSON configs.Behaviour changes
~/.cache/huggingface/accelerate/default_config.yamlis no longer read bytrl.--fsdp_configneeds transformers >= 4.57 (fsdp_versionkey); with 4.56.2 (our floor)accelerate launchstill works for it since accelerate stays a dependency.torch.accelerator.device_count()for the default process count needs torch >= 2.6.accelerate launch train.pybecametorchrun --nproc_per_node 8 train.py;CUDA_VISIBLE_DEVICES=n accelerate launchbecamepython. The Online DPO benchmark commands stay as they were (they reproduce from a v1.10.0 checkout).Tested
2xH100 via torchrun, tiny Qwen2, 3 steps: SFT ddp / zero2 / zero3 / fsdp2, DPO zero3, and SFT with FSDP2 +
ParallelismConfig(cp_size=2).tests/test_cli.py(single-process path + newtest_sft_torchrun),tests/test_cli_utils.py,tests/test_examples_index.py.tests/distributed/test_distributed.pyon 2 GPUs: 35 passed, 12 skipped (liger not installed).Untested: the DeepSpeed Ulysses (
sp_size) snippet in the long-context guide, and multi-node.