Skip to content
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

[Tune] Add trial_name_creator and trial_dirname_creator to TuneConfig #30123

Merged
merged 6 commits into from
Nov 16, 2022

Conversation

justinvyu
Copy link
Contributor

@justinvyu justinvyu commented Nov 9, 2022

Why are these changes needed?

This is a popular user request for these custom trial name and directory name creator functions to be added back to Tuner. Also, this PR updates doc descriptions for recommendations on including some unique trial attribute in the custom names/dirnames that are returned.

tune_config=tune.TuneConfig(
    trial_name_creator=lambda trial: f"{trial.trainable_name}_{trial.trial_id}",
    trial_dirname_creator=lambda trial: f"{trial.trainable_name}_{trial.trial_id}",
),

Open questions that this PR can also address:

  • Is there any additional functionality to be added to these creators?
    • Seems like main use is just removing certain dirname defaults such as the hyperparameter config experiment tag as well as the date. Current functionality is good enough.
  • Is it useful to provide the entire Trial object for flexibility, or should only a subset of Trial attributes be passed in for clarity?
    • The input to each of these methods could be changed to just a subset:
    • trial_name_creator=lambda trainable_name, trial_id, config: f"{trainable_name}_{trial_id}"
    • Users do seem to prefer the flexibility of the Trial, though.

Related issue number

Closes #29255

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>

Add trial_dirname_creator to example as well

Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
@justinvyu justinvyu added the tune Tune-related issues label Nov 9, 2022
@justinvyu justinvyu marked this pull request as ready for review November 9, 2022 21:43
@justinvyu justinvyu requested review from matthewdeng and krfricke and removed request for matthewdeng November 10, 2022 20:37
Copy link
Contributor

@krfricke krfricke left a comment

Choose a reason for hiding this comment

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

This is great, thanks!

@amogkam quick question, do you think we should have this as part of the RunConfig? I know the "trial" concept is mostly relevant for tune, but trainers will also create a trial name and directory, so maybe we want to have this flexibility there as well.

@amogkam
Copy link
Contributor

amogkam commented Nov 10, 2022

Yeah I think it can be useful- a relevant user question here https://discuss.ray.io/t/train-when-resuming-training-a-new-trial-directory-is-created-even-when-resuming-from-checkpoint/7672.

But agreed, we would need a better API for this than exposing the Trial directly.

@justinvyu @krfricke does it make sense to specify in the docstring that these args are alpha for now and the API for these are subject to change?

@krfricke
Copy link
Contributor

Let's mark it as alpha, then we can move this to run config once we converged on the API for non-tune runs

@justinvyu
Copy link
Contributor Author

justinvyu commented Nov 10, 2022

Update: will just flag as alpha for now.

For the user question though, even if we allow this trial dirname to be configured, the checkpoint config num_to_keep would still not be handled correctly, since Trainer(resume_from_checkpoint) creates a completely new experiment (checkpoint manager state doesn't get loaded).

Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
@krfricke
Copy link
Contributor

The current CI failures are due to an early kick-off mismatch. If you merge master and push to this commit, they should go away automatically

@amogkam amogkam merged commit 3266a02 into ray-project:master Nov 16, 2022
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
…onfig` (ray-project#30123)

This is a popular user request for these custom trial name and directory name creator functions to be added back to Tuner. Also, this PR updates doc descriptions for recommendations on including some unique trial attribute in the custom names/dirnames that are returned.

Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tune Tune-related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tune] trial_name_creator and trial_dirname_creator
4 participants