Cosmos-RL is an asynchronous reinforcement learning (RL) framework from NVIDIA for large language models (LLMs). You can run Cosmos-RL on PAI-DLC by creating a Custom job.
How Cosmos-RL works
The Cosmos-RL architecture consists of three core roles:
-
Controller: Manages the training topology, distributes tasks, and aggregates status across the cluster. Each job has exactly one Controller instance.
-
Policy: Performs model parameter updates (training). Multiple Policy instances can run in parallel using data parallelism (DP), tensor parallelism (TP), and pipeline parallelism (PP).
-
Rollout: Generates training data by interacting with the environment using the current policy model. Multiple Rollout instances can run in parallel to produce data concurrently.
Custom job type
PAI-DLC Custom jobs support flexible multi-role configurations, making them suitable for frameworks like Cosmos-RL that require coordinated roles.
Key capabilities of Custom jobs:
-
Custom role configurations and launch dependencies, with multiple run policies and elastic scaling.
-
Built-in runtime variables for roles and replicas to structure job code for different configurations.
-
Predefined common settings such as service exposure, passwordless SSH, and local disk mounting.
-
Built-in distributed launch modes for common training frameworks (PyTorch, MPI, and others), compatible with existing PAI-DLC job types.
Procedure
This example fine-tunes the Qwen2.5-32B-Instruct model with GRPO (Group Relative Policy Optimization), using the GSM8K math dataset for training. The following steps show how to create a Cosmos-RL job on PAI-DLC.
Step 1: Prepare the dataset and model
Download the dataset and pre-trained model, then upload them to Object Storage Service (OSS). The DLC job mounts this storage path at runtime.
-
Prepare the training dataset
Run the following command to download the dataset:
modelscope download --dataset AI-ModelScope/gsm8k --local_dir gsm8kUpload the dataset to OSS. For example, the OSS path after upload:
oss://cri-*****-registry.oss-cn-wulanchabu-internal.aliyuncs.com/test/modelscope/cache/AI-ModelScope/gsm8k. -
Prepare the pre-trained model
modelscope download --model Qwen/Qwen2.5-32B-Instruct --local_dir .Upload the model to OSS. For example, the OSS path after upload:
oss://cri-*****-registry.oss-cn-wulanchabu-internal.aliyuncs.com/test/modelscope/cache/Qwen/Qwen2.5-32B-Instruct.
Step 2: Create a DLC job
-
Log in to the PAI console. In the top navigation bar, select the target region. In the left-side navigation pane, select the target workspace, and then click Go to DLC.
-
On the Deep Learning Containers (DLC) page, click Create Task.
-
Configure the following key parameters. Adjust other parameters as needed:
-
Image Configuration: Select Image Address and enter the following address:
dsw-registry-vpc.cn-wulanchabu.cr.aliyuncs.com/pai-build/rl:rl-py310-cuda12.4-torch2.6-202506251931 -
Storage Mount: Mount the storage path to read training data and models and to store training outputs. Example configuration:
-
URI:
oss://cri-*****-registry.oss-cn-wulanchabu-internal.aliyuncs.com/test/ -
Mount path:
/mnt/data/
-
-
Start Command: Enter the following command:
-
Source: Select Public Resources.
-
Framework: Select Custom.
-
Job Resource:
-
Type: Define three node types:
Controller,Policy, andRollout. -
Nodes: Set to 1.
-
Resource Type: To fine-tune
Qwen2.5-32B-Instruct, use the following recommended instance types:-
Controller: Select a CPU instance, such asecs.g5.2xlarge. -
Policy: Select a GPU instance, such asecs.gn7i-c16g1.4xlarge. -
Rollout: Select a GPU instance, such asecs.gn7i-c16g1.4xlarge.
-
-
-
-
Click Confirm to create the job.
Appendix: Cosmos-RL overview
Cosmos-RL offers the following advantages in training efficiency and fault tolerance:
-
High training efficiency. Cosmos-RL runs policy training, rollout generation, and dispatcher topology management in parallel, achieving 2–3x throughput over traditional co-located training frameworks.
-
Strong fault tolerance. If a Policy or Rollout node fails, the cluster reorganizes and resumes the current training step without a restart. The dispatcher also supports multi-node backup.
-
Seamless scaling. Step-level topology management allows nodes to be added or removed during training without disrupting the overall process.
-
Modular algorithm and dataset support. Cosmos-RL supports mainstream LLM RL algorithms such as GRPO, DAPO, and AIPO, as well as custom algorithms. To add a dataset, create a dataset description file and a Data Packer.
-
Physical AI training support. Cosmos-RL natively supports scenario data for Cosmos inference models, with built-in image and video tensor preprocessing and caching to reduce CPU overhead and improve GPU utilization.
The following figure shows the Cosmos-RL architecture and data flow:
