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

[train] Setup xgboost CommunicatorContext automatically #44883

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

justinvyu
Copy link
Contributor

Why are these changes needed?

This PR uses the recently added Backend(train_func_context) configuration to automatically set up the xgboost CommunicatorContext for users so they don't have to call it manually in their training code. Users do not need to change their single worker code as much.

Related issue number

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 :(

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.


@@ -53,17 +51,16 @@ def train_fn_per_worker(config: dict):
"max_depth": 2,
}

# 2. Do distributed data-parallel training with the `CommunicatorContext`.
# 2. Do distributed data-parallel training.
# Ray Train sets up the necessary coordinator processes and
Copy link
Member

Choose a reason for hiding this comment

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

Shall we mention CommunicatorContext here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there's no need to explain it in this example since the user shouldn't need to think about it. I could add it to the XGBoostConfig docstring since that's how users would customize the params passed into the CommunicatorContext.

# Ray Train sets up the necessary coordinator processes and
# environment variables for your workers to communicate with each other.
with CommunicatorContext():
Copy link
Member

Choose a reason for hiding this comment

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

What would happen when using a single worker for training? Will the context manager here be a noop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it works with single worker

@justinvyu justinvyu merged commit 8fe3ac4 into ray-project:master Apr 25, 2024
5 checks passed
@justinvyu justinvyu deleted the xgb_context branch April 25, 2024 18:00
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 7, 2024
…t#44883)

Automatically set up the xgboost `CommunicatorContext`
for users so they don't have to call it manually in their training code.

---------

Signed-off-by: Justin Yu <[email protected]>
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

3 participants