Bug: CLI --accelerate_config does not override YAML config
Reproduction
TrlParser documents that command-line arguments override values supplied by a YAML config file. This does not hold for the launcher-only accelerate_config option when the YAML file and the CLI both provide the documented two-token spelling.
The following MRE exercises the real trl sft command and only mocks the process launcher, so it does not start a training job:
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import patch
from trl.cli import main
with TemporaryDirectory() as directory:
config_path = Path(directory) / "config.yaml"
config_path.write_text("accelerate_config: zero2\\n")
with patch("trl.cli.accelerate_launcher.launch_training_script") as launch:
main(["sft", "--config", str(config_path), "--accelerate_config", "zero3"])
launch_args = launch.call_args.kwargs["launch_args"]
assert Path(launch_args[1]).name == "zero3.yaml"
assert "--accelerate_config" not in launch_args
On main at 4506f4af8ccc5b7f8b337f589a696a19913d8a4a, the first assertion fails because the launcher receives zero2.yaml from the YAML file, and the command-line --accelerate_config zero3 pair remains in its forwarded arguments:
AssertionError: assert 'zero2.yaml' == 'zero3.yaml'
Expected behavior
The command-line value should take precedence: the launcher should receive --config_file .../zero3.yaml, and neither --accelerate_config token should remain in its arguments.
System Info
- Platform: macOS-26.5.2-arm64-arm-64bit-Mach-O
- Python: 3.13.5
- PyTorch: 2.14.0
- Transformers: 5.16.1
- Accelerate: 1.14.0
- Datasets: 5.0.1
- TRL: 1.13.0.dev0
- Accelerator: CPU
Checklist
- [x] I have checked that my issue isn't already filed.
- [x] I have included my system information.
- [x] Any code provided is minimal, complete, and reproducible.
- [x] Any code provided is properly formatted in code blocks, with no screenshots.
- [x] Any traceback provided is complete.