-
Notifications
You must be signed in to change notification settings - Fork 916
trainer: add XGBoost distributed training user guide #4342
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
google-oss-prow
merged 4 commits into
kubeflow:master
from
Krishna-kg732:docs/xgboost-trainer-user-guide
Mar 13, 2026
+55
−0
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| +++ | ||
| title = "XGBoost Guide" | ||
| description = "How to run XGBoost on Kubernetes with Kubeflow Trainer" | ||
| weight = 20 | ||
| +++ | ||
|
|
||
| This guide describes how to use TrainJob to run distributed | ||
| [XGBoost](https://xgboost.readthedocs.io/) training on Kubernetes. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before exploring this guide, make sure to follow | ||
| [the Getting Started guide](/docs/components/trainer/getting-started/) | ||
| to understand the basics of Kubeflow Trainer. | ||
|
|
||
| --- | ||
|
|
||
| ## XGBoost Distributed Overview | ||
|
|
||
| XGBoost supports distributed training through the | ||
| [Collective](https://xgboost.readthedocs.io/en/latest/tutorials/kubernetes.html) | ||
| communication protocol (historically known as Rabit). In a distributed setting, | ||
| multiple worker processes each operate on a shard of the data and synchronize | ||
| histogram bin statistics via AllReduce to agree on the best tree splits. | ||
|
|
||
| Kubeflow Trainer integrates with XGBoost by: | ||
|
|
||
| - Deploying worker pods as a [JobSet](https://github.com/kubernetes-sigs/jobset). | ||
| - Automatically injecting the `DMLC_*` environment variables required by XGBoost's | ||
| Collective communication layer (`DMLC_TRACKER_URI`, `DMLC_TRACKER_PORT`, | ||
| `DMLC_TASK_ID`, `DMLC_NUM_WORKER`). | ||
| - Providing the rank-0 pod with the tracker address so user code can start a | ||
| `RabitTracker` for worker coordination. | ||
| - Supporting both CPU and GPU training workloads. | ||
|
|
||
| The built-in runtime is called `xgboost-distributed` and uses the container image | ||
| `ghcr.io/kubeflow/trainer/xgboost-runtime:latest`, which includes XGBoost with | ||
| CUDA 12 support, NumPy, and scikit-learn. | ||
|
|
||
| ### Worker Count | ||
|
|
||
| The total number of XGBoost workers is calculated as: | ||
|
|
||
| ```text | ||
| DMLC_NUM_WORKER = numNodes × workersPerNode | ||
| ``` | ||
|
|
||
| - **CPU training**: 1 worker per node. Each worker uses OpenMP to parallelize | ||
| across all available CPU cores. | ||
| - **GPU training**: 1 worker per GPU. The GPU count is derived from | ||
| `resourcesPerNode` limits in the TrainJob. | ||
|
|
||
| --- | ||
Krishna-kg732 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Further Information | ||
|
|
||
| For comprehensive documentation including complete training examples (Python SDK | ||
| and kubectl YAML), best practices (`QuantileDMatrix`, early stopping, | ||
| checkpointing, logging), and common issues, see the XGBoost documentation: | ||
|
|
||
| **[Distributed XGBoost on Kubernetes — XGBoost Tutorial](https://xgboost.readthedocs.io/en/latest/tutorials/kubernetes.html)** | ||
Krishna-kg732 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can also use the Kubeflow Trainer distributed XGBoost notebook example: | ||
|
|
||
| **[xgboost-distributed.ipynb](https://github.com/kubeflow/trainer/blob/master/examples/xgboost/distributed-training/xgboost-distributed.ipynb)** | ||
Krishna-kg732 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.