NeMo RL

repository·main·Indexed 23 days ago

https://github.com/nvidia-nemo/rl

A scalable and efficient post-training library for models ranging from 1 GPU to 1000s, and from tiny to >100B parameters. Includes nrl-k8s, a config-driven launcher for running NeMo-RL recipes on Kubernetes clusters using the KubeRay operator to automate RayCluster deployment, daemon management, and training job execution.

Tokens
145.9K
Snippets
317
Records
561
Agent score
83%

What's inside nemo-rl

  1. Overview of nemo-rl-session-memory skill

    main

    The nemo-rl-session-memory skill provides coding agents with durable working-session memory. It allows agents to preserve and recover context across various interruptions, such as:

    • Disconnects or VS Code restarts
    • Long-running work sessions
    • Handoffs between agents or users
    • Branch switches

    Important state is written periodically to the repository's session directory to ensure continuity.

  2. Overview of available NeMo RL features

    main

    The NeMo RL project provides a Ray-based infrastructure for distributed Reinforcement Learning (RL) training. Key capabilities include:

    • Distributed Training & Parallelism: Uses Ray-based infrastructure with support for advanced parallelism via DTensor (PyTorch FSDP2, TP, CP, SP) and Megatron Core (TP/PP/CP/SP/EP/FSDP) through the NeMo Megatron Bridge. Includes sequence packing for both paths.
    • Learning Algorithms: Supports GRPO, GSPO, DAPO, SFT (with LoRA), DPO, and on-policy distillation.
    • Inference & Generation: Optimized inference via vLLM backend and Megatron Inference. Supports FP8 low-precision generation and speculative decoding (planned).
    • Environment & Isolation: Supports multi-environment training, dependency isolation, and process isolation between RL Actors to prevent global state issues. Includes NeMo-Gym integration.
    • Advanced RL Capabilities: Supports Multi-Turn RL (for tool use/games) and Async RL (asynchronous rollouts and replay buffers for off-policy training, including fully asynchronous GRPO).
    • Model Support: Support for Vision Language Models (VLM) for SFT and GRPO, Hugging Face integration (via DTensor path or Megatron Bridge), and GB200 container support.
  3. Overview of GRPO in NeMo RL

    main

    Group Relative Policy Optimization (GRPO) in NeMo RL is an implementation designed for reinforcement learning from human feedback (RLHF) or similar processes. The implementation covers four primary pillars:

    1. Data Handling: Managing datasets for training.
    2. Policy Model Training: The core optimization process.
    3. Fast Generation: Efficiently sampling from the policy.
    4. GRPO Loss Function: The mathematical implementation of the GRPO objective.

    For specific configuration details, refer to the examples/configs/grpo_math_1B.yaml configuration file.

  4. Overview of NeMo RL

    main

    NeMo RL is an open-source post-training library within the NeMo Framework. It is designed to streamline and scale reinforcement learning (RL) methods for multimodal models, including Large Language Models (LLMs) and Vision-Language Models (VLMs).

    Key features include:

    • Modular Design: Allows for easy integration and customization.
    • Ray Integration: Provides efficient resource management and scalable deployment across various hardware configurations.
    • Research Prototyping: Offers native PyTorch-only paths for rapid experimentation.
    • High Performance: Utilizes Megatron Core to support advanced parallelism techniques for large models and long context lengths.
    • Hugging Face Compatibility: Enables seamless use of a wide range of pre-trained models and tools.
  5. Understand model-family guidance for NeMo RL post-training

    main

    NeMo RL provides model-family specific guidance for post-training tasks. This guidance covers recipe selection, recommended generation settings, and known issues.

    Key Principles:

    • Source of Truth: While documentation explains the when and why of choosing a recipe, the actual recipe YAML files located under examples/configs/recipes/ are the definitive source of truth for configuration.
    • Model Support: For a complete list of supported models, refer to the model-support.md documentation.
  6. Supported training algorithms in NeMo RL

    main

    NeMo RL provides support for various training algorithms used in the post-training of large language models. These algorithms are categorized by their deployment capability on Single Node or Multi-node configurations.

    Supported Algorithms

    • GRPO: Group Relative Policy Optimization.
    • DAPO: Direct Alignment from Preference Optimization.
    • CISPO: (Specific configuration and async recipes available).
    • On-policy Distillation: Supported on Single Node, Multi-node, and via the PyTorch DTensor path.
    • MOPD: Multi-Teacher On-Policy Distillation (Multi-node only).
    • SFT: Supervised Fine-Tuning.
    • DPO: Direct Preference Optimization.
    • PPO: Proximal Policy Optimization.
    • RM: Reward Modeling.
  7. Qwen model guidance in NeMo RL

    main
    The Qwen landing page provides model-specific guidance for using Qwen variants within NeMo RL. It directs users to version-specific subpages containing recipes, backend support details, and performance notes. For a complete list of all supported Qwen models, refer to the central model-support.md documentation.
  8. What is Cross-Tokenizer (X-Token) Off-Policy Distillation?

    main

    Cross-Tokenizer (X-Token) distillation allows NeMo RL to perform off-policy distillation between a student model and a teacher model that use different tokenizers (e.g., distilling a Qwen3-4B teacher into a Llama-3.2-1B student).

    Because the vocabularies only partially overlap, the system uses a projection matrix to bridge the gap. This matrix is a sparse [V_student, top_k] tensor that maps each student token to the teacher tokens it most plausibly corresponds to. During training, the student's logits are multiplied by this matrix to project them into the teacher's vocabulary space, allowing for a direct comparison of probability distributions.

  9. What is Multi-Teacher On-Policy Distillation (MOPD)?

    main

    Multi-Teacher On-Policy Distillation (MOPD) is a training paradigm that distills one or more teacher models into a student policy. It replaces the standard GRPO reward-based advantage with a token-level distillation advantage.

    Key characteristics:

    • Mechanism: It uses a stop-gradient teacher-minus-student log-probability gap as the advantage signal.
    • Integration: It runs on top of the GRPO trainer (selected via adv_estimator: opd) and utilizes NeMo Gym for rollouts.
    • Learning Signal: The teacher distillation serves as the entire learning signal; no reference-policy KL penalty is used.
    • Efficiency: Unlike forward-KL logit distillation, MOPD only requires the teacher's log-probability for the sampled token, rather than the full vocabulary distribution.
    • Asynchronous Execution: Teachers are served from dedicated, non-colocated worker groups during asynchronous collection.
  10. What is Dual-Clip Asymmetric Policy Optimization (DAPO)?

    main

    Dual-Clip Asymmetric Policy Optimization (DAPO) is an extension of GRPO that introduces asymmetric clipping. Unlike standard GRPO or PPO, which use identical values for minimum and maximum clipping, DAPO allows for distinct ratio_clip_min and ratio_clip_max parameters. This provides more fine-grained control over policy updates by setting asymmetric bounds on the probability ratio.

    Technically, DAPO is implemented using the same ClippedPGLossFn as GRPO, making it fully compatible with existing GRPO training infrastructure and configurations.

  11. Ensure consistent tokenization via the vLLM /tokenize endpoint

    main
    To prevent re-tokenization drift between the generation (inference) and training phases, NeMo RL extracts Token IDs directly at the vLLM layer using the /tokenize endpoint. This ensures that the tokenization used during training exactly matches the model and tokenizer used during generation.
  12. Advanced NeMo RL features and optimization

    main

    NeMo RL includes advanced capabilities for optimizing large-scale model training:

    • Quantization: Support for FP8 quantization and Quantization-Aware RL (using NVIDIA ModelOpt) to accelerate training and inference.
    • Speculative Decoding: Use Eagle3 workflows (offline and online) with vLLM to accelerate rollout generation.
    • Long-Context Training: Extend context windows using YaRN RoPE scaling on the Megatron backend.
    • Parameter-Efficient Fine-Tuning (PEFT): Support for LoRA across different backends.
    • Weight Refit: Various transport methods including colocated IPC, NCCL, sparse delta, and NIXL to update model weights.