Skip to content

📋 Allow calling trl cli in sft mode with config file #3380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025

Conversation

CloseChoice
Copy link
Contributor

What does this PR do?

This PR makes it possible to specify all required arguments in a config.yaml file and call this via cli, e.g.

trl sft --config examples/cli_configs/example_config_dummy.yaml --output_dir test-trl-cli --lr_scheduler_type cosine_with_restarts

This line is directly from the trl docs but didn't work since config is no known argument of the TrlParser when calling parse_args which is always called.

Fixes #3102

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

trl/cli.py Outdated
args = parser.parse_args_and_config()[0]
else:
# Parse the arguments normally if no config file is specified
args = parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should check here that dataset_name is in args? I needed to make dataset_name optional so that a call to parser.parse_args() works in the cases further down, checking that args contains dataset_name will then make sure that the same checks are in place as without this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should check here that dataset_name is in args

if you don't provide the dataset, it would fail when trying to load it in the sft script. I think the error will be pretty self-explanatory, no need to add an extra check in my opinion.

@qgallouedec
Copy link
Member

Thanks, your solution is very good, I simplified the test a bit, and the parsing logic, and once the tests are green, we can merge 🎉

@HuggingFaceDocBuilderDev

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.

@CloseChoice
Copy link
Contributor Author

@qgallouedec thanks for the review and improving the PR. Pipelines are passing ;)

@qgallouedec qgallouedec changed the title Allow calling trl cli in sft mode with config file 📋 Allow calling trl cli in sft mode with config file Apr 28, 2025
@qgallouedec qgallouedec merged commit 2bf4847 into huggingface:main Apr 28, 2025
9 checks passed
@CloseChoice CloseChoice deleted the FIX-cli-sft-config branch April 28, 2025 21:23
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.

CLI parameters and error logging
3 participants