# Molt

> A small, PyTorch-native framework for fully asynchronous agentic RL on LLMs

- Category: Training & Fine-Tuning / RLHF & Alignment
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/NVIDIA-NeMo/labs-molt
- Canonical page: https://ai-tldr.dev/tools/molt/

## In short

Molt is an open-source reinforcement learning framework for research on LLM agents, published under the NVIDIA-NeMo GitHub organisation. It sits in the RLHF & Alignment category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0. To get started: clone the repository.

## Overview

Molt is an open-source reinforcement learning framework for research on LLM agents, published under the NVIDIA-NeMo GitHub organisation. It covers both supervised fine-tuning and online RL, and describes itself as agentic-first and PyTorch / Hugging Face-native: the agent is the program, the trainer is a single actor, and the reward is any Python you write inside an environment or chat agent — graders, multi-turn tools, vision-language environments or LLM-as-judge calls.

The whole stack is three components. Ray handles placement and the asynchronous queues between them, vLLM generates rollouts, and NVIDIA AutoModel with FSDP2 trains the model in plain PyTorch. Rollout, training and weight sync overlap, and the README reports roughly 9.2K lines of RL code that scale from an 8B model to trillion-parameter-class mixture-of-experts models such as DeepSeek-V3 using tensor, expert and context parallelism. Molt is based on OpenRLHF and keeps much of its package layout.

Every RL run points at one Python module that exports an AgentRunner. You either subclass Env, a Gymnasium-style step/reset interface where the framework drives vLLM and tokenization, or ChatAgent, where your own code drives the loop through the OpenAI or Anthropic SDK against an auto-launched local server. Token ids, logprobs, rewards and multimodal tensors stay aligned from rollout to training, so multi-turn, vision and tool-call traces share one format.

## What it does

- Two agent interfaces: a Gymnasium-style Env with step() and a ChatAgent that speaks OpenAI Chat Completions or Anthropic Messages to the rollout engines
- Fully asynchronous runtime on Ray with async rollout queues, partial rollout and weight sync to vLLM
- Advantage estimators including REINFORCE, RLOO, GRPO, Dr. GRPO, PPO with a GAE critic, FlashREINFORCE and on-policy distillation to a frozen teacher
- NVIDIA AutoModel + FSDP2 training with tensor, expert and context parallelism and Adam CPU offload for the largest actors
- MoE stability tools: rollout routing replay (R3), router freeze and importance-sampling correction for train/rollout logprob mismatch
- Configured entirely through CLI flags, with LoRA support and ready-made recipes for Qwen3, Nemotron-Omni and GLM models on a single node or Slurm

## Getting started

Molt is run from a clone of the repository. The README recommends its Docker image, which bakes in the CUDA 13 stack (PyTorch, vLLM, TransformerEngine, NVIDIA AutoModel) for A100, H100, H200, B200 and GB200 GPUs; a local editable install requires CUDA 13.

1. Clone the repository

   The launch scripts, reference agents and recipes live in the repo, and the container mounts this checkout.

```bash
git clone https://github.com/NVIDIA-NeMo/labs-molt.git
cd labs-molt
```

2. Get the container, or install locally

   Pull the published image (recommended). For development outside the container, install in editable mode with the vLLM extra; the PyPI package is not a supported install path.

```bash
docker pull hijkzzz/molt:latest

# or, outside the container (CUDA 13 required)
pip install -e ".[vllm]"
```

3. Write an agent

   An RL run needs one module exporting AgentRunner. The Env path returns a Result with the reward from step(); four reference agents ship under examples/python/agents/.

```python
from molt.agents import Env, Result, StepEnvRunner

class MathEnv(Env):
    async def step(self, state) -> Result:
        # state: observation_text, action_text, label, sampling_params
        reward = grade(state["action_text"], state["label"])
        return Result(reward=reward, terminated=True)

class AgentRunner(StepEnvRunner):
    def __init__(self):
        super().__init__(MathEnv)
```

4. Launch RL training

   Point the trainer at a model, a prompt dataset and the agent module. Add flags such as --rollout.n_samples_per_prompt with grpo or rloo, or --train.async_queue_size to decouple rollout from training.

```bash
python3 -m molt.cli.train_rl_ray \
  --actor.model_name_or_path /path/to/automodel \
  --data.prompt_dataset /path/to/prompts.jsonl \
  --data.input_key input \
  --train.agent_path examples/python/agents/math.py \
  --vllm.num_engines 2 \
  --vllm.tensor_parallel_size 2 \
  --rollout.batch_size 128 \
  --train.batch_size 128 \
  --train.micro_batch_size 1 \
  --algo.advantage.estimator reinforce \
  --algo.kl.init_coef 0 \
  --fsdp.attn_implementation te \
  --ckpt.output_dir ./ckpt/rl
```

5. Or start from a recipe

   Reference launch scripts under examples/scripts/ cover single-node quick starts and Slurm runs.

```bash
MODEL_PATH=/path/to/Qwen3-4B bash examples/scripts/quick_start/rl_qwen3_4b.sh
```

## When to use it

- Research new RL algorithms or loss terms for LLMs in a codebase small enough to read end to end
- Train a multi-turn, tool-using or vision-language agent with RL, using any Python function as the reward
- Run RL on an agent that already talks to an OpenAI- or Anthropic-compatible API by pointing its client at Molt's session server
- Scale the same RL or distillation script from a single-node dense model to a large mixture-of-experts model on a Slurm cluster
