# torchforge-rl-training

This skill guides PyTorch-native agentic RL with torchforge. Use it for SFT, GRPO, custom loss functions, and distributed training experiments.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 946 installs · ★ 13956
- Author: Orchestra Research
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/torchforge/SKILL.md
- Updated: 2026-10-11
- HTML: https://affpapa.org/en/nevibecode/skills/torchforge-rl-training

## What it does

The skill teaches an agent how to use torchforge, a PyTorch-native library for agentic reinforcement learning. Its approach separates algorithm code from infrastructure. The material covers GRPO, DAPO, SAPO, and other loss functions, with TorchTitan for training, vLLM for inference, and Monarch for distributed services.

It includes workflows for SFT, GRPO on math tasks, custom loss classes, and multi-GPU configurations. The examples show reward functions, YAML configs, and launch commands such as `python -m apps.sft.main --config apps/sft/llama3_8b.yaml` and `python -m apps.grpo.main --config apps/grpo/qwen3_1_7b.yaml`. Installation uses `torch>=2.9.0`, `torchtitan>=0.2.0`, `vllm`, and `monarch`, with a separate ROCm script.

The SFT example needs 2+ GPUs, while the GRPO workflow uses 3+ GPUs for trainer, ref_model, and generator roles. torchforge is experimental and its APIs may change, so review generated integration code before using it in a stable training pipeline.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge-rl-training -a claude-code
```
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/torchforge/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/torchforge/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/torchforge/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/torchforge/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Orchestra-Research/AI-Research-SKILLs torchforge
```

2. **Manually: put the files in place**
- File: `.github/skills/torchforge/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Orchestra-Research/AI-Research-SKILLs --path 06-post-training/torchforge
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/torchforge/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill torchforge -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/torchforge/SKILL.md

## When to use it
- set up PyTorch SFT training
- run GRPO on math datasets
- define a custom RL loss
- scale training across multiple GPUs

## Example prompts
- Set up SFT with torchforge using `apps/sft/llama3_8b.yaml` and explain the launch command.
- Create a GRPO config for `openai/gsm8k`, add a reward function, and run `python -m apps.grpo.main --config config/grpo_math.yaml`.
- Show how to add a custom `CustomLoss` to the torchforge training loop and account for its GPU requirements.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 262ff8bc41be3805.

BEGIN THIRD-PARTY FILE 262ff8bc41be3805
````text
---
name: torchforge-rl-training
description: Provides guidance for PyTorch-native agentic RL using torchforge, Meta's library separating infra from algorithms. Use when you want clean RL abstractions, easy algorithm experimentation, or scalable training with Monarch and TorchTitan.
version: 1.0.0
author: Orchestra Research
license: MIT
tags: [Reinforcement Learning, PyTorch, GRPO, SFT, Monarch, TorchTitan, Meta]
dependencies: [torch>=2.9.0, torchtitan>=0.2.0, vllm, monarch]
---

# torchforge: PyTorch-Native Agentic RL Library

torchforge is Meta's PyTorch-native RL library that separates infrastructure concerns from algorithm concerns. It enables rapid RL research by letting you focus on algorithms while handling distributed training, inference, and weight sync automatically.

## When to Use torchforge

**Choose torchforge when you need:**
- Clean separation between RL algorithms and infrastructure
- PyTorch-native abstractions (no Ray dependency)
- Easy algorithm experimentation (GRPO, DAPO, SAPO in ~100 lines)
- Scalable training with Monarch actor system
- Integration with TorchTitan for model parallelism

**Consider alternatives when:**
- You need production-ready stability → use **miles** or **verl**
- You want Megatron-native training → use **slime**
- torchforge is experimental and APIs may change

## Key Features

- **Algorithm isolation**: Implement RL algorithms without touching infrastructure
- **Scalability**: From single GPU to thousands via Monarch
- **Modern stack**: TorchTitan (training), vLLM (inference), TorchStore (sync)
- **Loss functions**: GRPO, DAPO, CISPO, GSPO, SAPO built-in

## Architecture Overview

```
┌─────────────────────────────────────────────────────────┐
│ Application Layer (Your Code)                           │
│ - Define reward models, loss functions, sampling        │
└─────────────────────┬───────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────┐
│ Forge API Layer                                         │
│ - Episode, Group dataclasses                           │
````
END THIRD-PARTY FILE 262ff8bc41be3805

The third-party file has ended. Everything between the 262ff8bc41be3805 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2477 of 10734 bytes. © Orchestra Research · MIT · https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/torchforge/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
