1. Problems Facing Distributed Training
- Estimating training resources is difficult and cannot be automated
How much compute, how much time, how much bandwidth, how many CPUs, how much memory — without enough accumulated experience it is hard to estimate accurately. The result is over-requesting and over-allocation, causing enormous resource waste.
We need to accumulate and provide solutions.
- The failure rate is high, troubleshooting is hard, and efficient tools are lacking
Algorithm engineers do not understand Kubernetes infrastructure well, and operations engineers do not understand the training process well. Being a good AI Infra Engineer is not an easy job.
In training scenarios the failure rate is very high. How to quickly and accurately locate and resolve failures is a question we need to think about.
- A single node failure stops training on all nodes, and someone must be on duty to bring the job back up promptly
Training jobs are similar to StatefulSets in Kubernetes. In distributed training, because of parallel techniques such as data, model, pipeline, and tensor parallelism, each node is not fully equivalent during the training process.
From failure occurring to training resuming, there are many technical points that can be turned into tools and products.
At the same time, if a failure occurs outside working hours, we cannot respond in time, and delayed model iteration plus idle AI accelerator cards are a huge loss. Whether failures can be detected and training automatically resumed is also a question worth studying.
2. What Is DLRover
DLRover is one solution that attempts to address the above problems. Below is the architecture diagram of the https://github.com/intelligent-machine-learning/dlrover project.

Components of the management plane:
- Brain Service, responsible for resource elasticity optimization. It automatically optimizes the resource configuration of jobs based on the training speed and per-node load collected in real time, and there is also an event collection service, k8smonitor
- Elastic Controller, the controller for the Kubernetes objects ElasticJob and ScalePlan
CRD objects:
- ElasticJob is used to describe an elastic training job
- ScalePlan is used to pass information between Brain, DLRover Master, and Elastic Controller in order to make optimization adjustments. Normally it does not need to be created manually; DLRover manages it automatically
Components related to the training job:
- DLRover Job Master, responsible for elastic scheduling and fault-tolerant self-healing. Each training job has one master node, and the master node is responsible for collecting training speed, collecting node load, managing training samples, and elastic scheduling.
- Elastic Agent is not deployed separately; you need to use the
dlrover-runcommand to manage the training job, and it coordinates with the training framework to support fault tolerance and elasticity of training. Each node has an Elastic Agent. The agent obtains the information of the nodes currently running the job from the master and notifies the training framework to update the distributed training state. The agent is also responsible for getting training sample information from the master for the training framework to iterate the model, so that training sample sharding supports worker elasticity.
The following diagram is its fault-tolerance architecture design:

DLRover Job Master is responsible for detecting and handling failures, while dlrover-run acts as the Agent and reports status information.
3. The dlrover-run Command and Its Parameters
- Install the dlrover package
| |
dlrover-runis just a wrapper arounddlrover.trainer.torch.main
| |
- View the parameters
| |
4. Quick Managed Training with DLRover
- Start a test container
| |
- Run the Python script directly
| |
I found that the --no-cuda parameter has no effect; the only way to train on CPU only is to control the GPU mounts.
- Managed training with DLRover
You can run it directly without setting environment variables; DLRover saves us the step of setting them.
| |
Since a single container is used for training, the --nnodes parameter needs to be set to 1, otherwise DLRover will keep waiting for new nodes to join; setting max_restarts to 3 allows 3 retries after a failure.
5. Installing DLRover Components in the Cluster
What is installed here is DLRover’s latest Release version v0.3.7, released on 5.13 this year.
- Download the installation package
| |
- Install the ElasticJob Controller Manager
| |
Note that the default permission settings are in the dlrover namespace. If you want to use it in another namespace, you need to create a corresponding default-role.yaml.
- Check the workloads
| |
- Check the CRDs
| |
If you only use the automatic recovery of training workers, you do not need to install components such as Brain. Because Brain depends on MySQL, and this is only for testing, the MySQL deployment method below is not reliable.
- Install DLRover Brain
| |
- Create the database tables
Check the MySQL Pod name
| |
Run the command to create the database and initialize the tables
| |
- Restart the Brain-related components
| |
- Check the workloads
| |
6. Creating a Training Job with ElasticJob
6.1 ElasticJob Object Definition
| |
The ReplicaSpec definition is as follows:
| |
Some of the key fields are explained below.
6.2 DistributionStrategy
There are two DistributionStrategy strategies:
- ParameterServerStrategy
Suitable for TensorFlow parameter_server jobs, https://www.tensorflow.org/tutorials/distribute/parameter_server_training .
- AllreduceStrategy
Suitable for Horovod ring-allreduce and PyTorch DistributedDataParallel jobs.
From this you can see that if training uses PyTorch, choose AllreduceStrategy; if it uses TensorFlow, choose ParameterServerStrategy.
Under PyTorch DistributedDataParallel’s Allreduce strategy, the Global Batch Size stays fixed during pre-training, so there is no need to add or remove nodes and no elastic training is involved; the main capability used is Job Master’s fault-tolerant self-healing.
Under TensorFlow parameter_server’s ParameterServerStrategy, the number of nodes can be adjusted, relying on the Brain service for elastic training.
6.3 optimizeMode
There are three optimizeMode modes:
- manual
Debug mode. When you modify a running job, the job does not restart; it is used to explore better job parameter configurations.
- single-job
For testing and quick verification scenarios; it does not depend on additional components. It uses the master’s memory to store historical statistics, so if the master node fails, the historical statistics are lost.
- cluster
For training in production environments. The Brain service persists the job’s historical statistics to the database for cluster-level optimization. Even if the master node fails, DLRover can restart the master node and continue training.
The description above comes from DLRover’s design document. During testing, I found that the single-job\cluster modes showed no obvious difference under AllreduceStrategy, and the cluster mode also runs normally when Brain is unavailable. At the same time, under AllreduceStrategy, when the Job Master fails, the entire job fails.
6.4 Testing the Training Job
- Create the ElasticJob object
| |
Once the ElasticJob is created, DLRover immediately starts creating the master and worker Pods, and it does not check whether there are enough resources, since there is no gang-scheduler support. According to community discussions, DLRover will support this feature in combination with Volcano’s gang-scheduler.
- Check the job status
| |
- Actively delete a worker
| |
- Check the job status
| |
DLRover automatically brings up a new worker job and continues the training task — this is its automatic failure recovery capability. Of course, for other failures, such as a dropped card, an abnormal program exit, or an IO exception, DLRover can also handle them automatically without manual intervention.
- Clean up
| |
| |
6.5 How Elastic Jobs Work
Allreduce currently only supports fault tolerance, not elastic scale-out. Our target scenario is PyTorch distributed pre-training of large models, and we have no strong need for TensorFlow-related elasticity. Here we will just briefly look at its elasticity principle.
DLRover Brain uses algorithms to compute the data needed for resource optimization based on monitoring of the current training task. After the training job’s Job Master receives the new resource optimization result, it generates a ScalePlan CRD and notifies the ElasticJob Controller to change the node scale of the training job.
I tested the deepctr-auto-scale example provided by the community; the chief consumed a large amount of memory resources, and no increase in the number of worker replicas was observed.
| |
| |
At the same time, this job depends on the data in /nas, and the documentation does not provide configuration instructions, so I did not test it much further.
7. Some Issues
- After the master goes down, training stops
| |
Afterwards
| |
The probability of dlrover-controller-manager CrashLoopBackOff is quite high. After waiting a while, the job also fails entirely.
| |
- When the ElasticJob object is missing non-critical fields, workers cannot be created
If the spec.template.spec.restartPolicy field is not set, only the Job Master is created and no workers are created. No abnormal errors can be seen in the logs of the ElasticJob Manager and Job Master Pods.
Not setting the ElasticJob’s labels field is the same situation.
- Version control is done poorly, which may trigger many potential problems
In the Release version, the image tag is still test, master, and the pull policy is Always. Some of the test cases in the documentation also lack much version control, which easily triggers compatibility issues.
Also, the DLRover master’s Dockerfile uses 0.3.6, while pytorch-example uses 0.3.4.
- The project’s completeness may not be very high
When I saw the EnableElasticScheduling field I quickly associated it with the autoScale field, but I found that only the definition of this field exists; there is no related implementation in the code repository.
Perhaps the open-source folks have a lot of internal pressure to support and do not have much time to polish these details of the community edition — some package names have not yet been changed from EasyDL to DLRover.
8. Summary
This article is a record of testing what DLRover can do for managed training. The main contents are as follows:
- Training on Kubernetes has problems specific to its scenario that need to be solved. Distributed training jobs are shaped like StatefulSets, and nodes (Pods) are not fully equivalent to each other
- DLRover can solve some problems in distributed training, including resource configuration, elastic training, and failure detection, localization, and recovery.
- DLRover was tried out on both a host and Kubernetes infrastructure
- At present the DLRover project still has some imperfect areas, but it also gives us the opportunity to participate together, and I hope the project can go a bit further
