-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🕹️ CLI refactor #2380
🕹️ CLI refactor #2380
Conversation
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we will need to move all example scripts from examples/scripts
to trl/scripts
right? I am wondering if this causes some downstream issues if people have linked their websites to examples/scripts
and whether it will be harder for people to find the scripts now since it's somewhat uncommon to include such objects in the package directly.
I agree that in general we want to have a robust CLI that isn't afflicted by all the symlink issues you've noted, but let's also see what @lvwerra thinks since him and Younes were the architects of that feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the main question. Sorry I didn't have time to go into detail about my thoughts in the original post (still under construction).
downstream issues if people have linked their websites
Right. The links wouldn't be dead in all cases, as files like https://github.com/huggingface/trl/blob/adac644f7fe1a5a37f9cca10044ed81b594eae32/examples/scripts/dpo.py would allow redirection.
As far as this point is concerned, I think refraining to move these files is a case of the snake biting its own tail, because the number of link will grow.
harder for people to find the scripts
Probably slightly harder yes.
I'd say these are the two main drawbacks (link issues and harder to find) to weigh in the balance.
uncommon to include such objects in the package directly
True, examples aren't included in the package. But I think here, it's more scripts that can be used as examples, rather than true examples. I think this mostly because:
- we have full argparsing support,
- they are used in the CLI.
I had a short discussion with @lvwerra (I don't want to change what you said, feel free to correct me).
As a first iteration, we could only move dpo, sft, and chat (current cli support). |
* First changes * Other files * Finally * rm comment * fix nashmd * Fix example * Fix example [ci skip]
* fix chat for windows * add some tests back * Revert "add some tests back" This reverts commit 350aef5.
* datast_config_name * Update trl/utils.py [ci skip] * sort import * typo [ci skip] * Trigger CI * Rename `dataset_config_name` to `dataset_config`
* Remove unused deepspeed code * add model prep back * add deepspeed even if it doesn't work * rm old code
…o cli-refactor
What does this PR do?
Historically
The example scripts were initially placed outside the package directory (
.examples/scripts
) because they were not intended for runtime use. However, with the introduction of the TRL CLI in #1419, these scripts became executable at runtime through the CLI. Unfortunately, the scripts could not be directly imported from the package. To address this, we implemented a workaround insetuptools
by creating a symbolic link fromtrl/trl/commands
toexamples/scripts
.Motivations for this refactor
Recurrent issues with the simlink not properly created: trl CLI doesn't work #1716, Not find sft.py #1829 Fix dev install #2369 (comment)
Populating the CLI with new command isn't flexible [CLI] Extend training support to all trainers #2101 populate SUPPORTED_COMMANDS cli #2157
We implement our own parser based on
sys.argv
to have our own subparsing logic, whileargparse
have everything we need for subparsingWe don't have the usual parsing associated features like the help etc:
Building the package will soon not be possible because of the simlink to the examples, see Fix dev install #2369 (review)
Recurrent and enigmatic CI failures:
Operation was cancelled
example here (I'm not sure this will solve the problem, we'll see)Alternatives
Solution
Reference structure for the new CLI: https://github.com/qgallouedec/turbo-spoon
Project structure
Setup file
to
Why this solution?
From the setuptools user guide
Consequently, if we want to have access to the example with the CLI (at runtime then)
Examples and scripts
What we've called examples are now actual scripts.
But these scripts are still relevant as examples, and are widely used as examples not only in our documentation, but also externally. That's why we need to ensure that these scripts are still referenced in order to avoid creating dead link:
This PR will only handle the commands currently supported:
sft
,dpo
andchat
. We will deal with the other scripts one by one in subsequent PRs.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines.
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.