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+rllib] Enforce input type for Experiment(config) to handle rllib AlgorithmConfigs #42816

Merged
merged 1 commit into from Jan 30, 2024

Conversation

justinvyu
Copy link
Contributor

@justinvyu justinvyu commented Jan 30, 2024

Why are these changes needed?

#42116 resulted in params.json saving the wrong data due to dumping an AlgorithmConfig object rather than a dict, which is the expected type for Experiment.config.

The fix should be to force the user to call AlgorithmConfig.to_dict to satisfy the Ray Tune API, rather than adding more rllib specific instance checks in Ray Tune, as is done in this other PR. The _Config class is a hack that is used in one place, but we should not add more of this class throughout the codebase when possible.

The fix to the user post linked below:

experiment_spec = tune.Experiment(..., config=ppo_config.to_dict())`
tune.run_experiments(...)

Related issue number

#41370

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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@anyscale.com>
Copy link
Contributor

@matthewdeng matthewdeng left a comment

Choose a reason for hiding this comment

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

Makes sense; chances are there other places in the codebase that follow the Dict typehint.

@justinvyu justinvyu merged commit 5ec3691 into ray-project:master Jan 30, 2024
9 checks passed
@justinvyu justinvyu deleted the revert_rllib_tune branch January 30, 2024 18:06
@justinvyu
Copy link
Contributor Author

@sven1977 @simonsays1980 @ahmedammar Just a heads up, I switched to an alternate solution that would involve fewer changes in Ray Tune. See the PR description for the new recommended usage (converting to dict before passing into Ray Tune APIs). Ray Tune expects a dict in many other places, and we should not do this typecheck in every case.

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.

None yet

2 participants