UniVR README

The project's README from github.com/FlagOpen/UniVR. As one markdown file: README.md.

UniVR: SFT & RL Training Framework for Emu3.5 Series Unified Models

UniVR Overview


What is This?

UniVR is an end-to-end SFT and Reinforcement Learning (GRPO) training framework specifically built for Emu3.5 series unified generative models. It is designed to be easily adapted for your own tasks — you only need to swap in your own data loader and RL reward function.

Key framework features:


Customizing for Your Own Task

Step 1 — Replace the Data Loader (SFT)

The SFT stage reads training samples in a unified format: [query image, textual instruction, visual reasoning trajectory]. To use your own data, implement a custom PyTorch Dataset that returns samples in this format and plug it into UniVR_SFT/train.py.

No changes to the training loop, DeepSpeed config, or model code are needed.

Step 2 — Replace the Reward Function (RL)

The RL stage calls a reward server via HTTP to score rollout trajectories. To use your own reward:

  1. Implement your reward logic as an HTTP server (see UniVR_RL/verl/ for the existing VLM-based reward server reference).
  2. Set VLLM_PATH in UniVR_RL/examples/emu3_grpo_lora.sh to point to your reward server endpoint.
  3. Optionally adjust worker.rollout.enable_image_decode_for_reward in examples/config_emu3.yaml depending on whether your reward consumes raw image tokens or decoded pixel images.

The GRPO training loop, rollout engine, and Emu3.5 vLLM backend remain unchanged.


Research Context (UniVR)

This framework was developed for UniVR, a system that learns complex visual reasoning, fine-grained physical dynamics, and long-term planning from pure visual demonstrations — without relying on dense image-text pairs or task-specific heuristics.

UniVR uses VR-GRPO, a reinforcement learning paradigm combining:

Training and evaluation use VR-X, a benchmark of 1.5M raw samples from 16 diverse sources spanning manipulation, spatial puzzles, and physical reasoning.


Architecture

UniVR adopts Emu3.5 (34B) as its backbone — a unified generative model that tokenizes images and text into a shared discrete vocabulary via a VQ-VAE-style encoder. The model autoregressively generates visual reasoning traces (future frames) given an image sequence and instruction, with no intermediate text chain.

Training is a two-stage pipeline:

Stage Module Data Description
1. Cold Initialization UniVR_SFT 310k VR-X samples SFT to instill visual reasoning priors
2. Reinforcement Learning UniVR_RL 3k curated samples VR-GRPO with composite reward

Repository Structure

UniVR/
├── install.sh            # One-shot environment setup for both subprojects
├── UniVR_SFT/            # Supervised Fine-Tuning (cold initialization)
│   ├── train.py          # ← Replace dataset here for your task
│   ├── inference.py
│   ├── scripts/
│   │   ├── train_sft_lora.sh
│   │   ├── train_sft_full.sh
│   │   └── inference.sh
│   ├── configs/          # Inference configs
│   └── src/
│       ├── patch/        # vLLM source patches for Emu3.5 (no-CFG + LoRA)
│       └── tokenizer_emu3_ibq/
└── UniVR_RL/             # Reinforcement Learning (VR-GRPO)
    ├── examples/
    │   ├── emu3_grpo_lora.sh  # ← Set your reward server endpoint here
    │   └── config_emu3.yaml
    ├── verl/             # Modified verl framework with Emu3.5 HybridEngine
    └── src/

Installation

bash install.sh

Installs all dependencies (torch==2.8.0, transformers==4.57.3, vllm==0.11.0, flash-attn==2.8.3, deepspeed), applies the vLLM source patches for Emu3.5, and installs the verl-based RL framework.

See UniVR_SFT/README.md and UniVR_RL/README.md for detailed usage of each subproject.


Quick Start

SFT (LoRA, 2 nodes × 8 GPUs)

# Edit scripts/train_sft_lora.sh to set MODEL_PATH, TOKENIZER_PATH, OUTPUT_DIR
cd UniVR_SFT
bash scripts/train_sft_lora.sh

SFT (Full parameter, 4 nodes × 8 GPUs)

bash scripts/train_sft_full.sh

RL (VR-GRPO)

# Edit examples/emu3_grpo_lora.sh to set MODEL_PATH, TOKENIZER_PATH, VQ_MODEL_PATH, VLLM_PATH
cd UniVR_RL
bash examples/emu3_grpo_lora.sh

UniVR (FlagOpen/UniVR)

Searching Database…

178 ·GitHub
这是什么?UniVR 是专为 Emu3.5 系列统一生成模型打造的端到端 SFT 和强化学习(GRPO)训练框架,让你通过换入自己的数据加载器和奖励函数来训练视觉推理任务。
这是开箱即用的模型,还是训练框架?它是一个训练框架,不是独立模型:UniVRSFT 负责多节点监督微调(LoRA 或全参数),UniVRRL 负责 GRPO 强化学习,两者都围绕 Emu3.5 主干构建。
怎么把它跑起来?安装锁定版本的依赖组合,应用自带的针对 Emu3.5 的 vLLM 源码补丁,然后按 UniVRSFT/README.md 或 UniVRRL/README.md 里的快速开始脚本启动 SFT 或 RL 训练。
用它训练需要多 GPU 节点吗?需要。快速开始示例假定 LoRA SFT 用 2 节点 x 8 GPU,全参数 SFT 用 4 节点 x 8 GPU,RL 阶段还需要自定义的 vLLM/verl rollout 引擎。
我可以接入任意主干模型,还是它绑定了 Emu3.5?它与 Emu3.5(34B)主干紧密耦合——vLLM 补丁、HybridEngine 和训练循环都是专门为它构建的;只有数据加载器(SFT)和奖励函数(RL)设计为可替换。
VR-GRPO 是什么?VR-GRPO 是 UniVR 使用的强化学习范式,把格式奖励、由 VLM 全局评判的完成度奖励,以及针对最不确定子步骤(通过 CLIP 特征方差找出)的步骤聚焦奖励组合起来,公式为 Rreason = Rg - lambda|Rg - Rs|。
VR-X 基准是什么?VR-X 是 UniVR 背后的基准:来自 16 个多样来源的 150 万条原始样本,涵盖操作、空间谜题和物理推理,其中 31 万条用于 SFT 冷启动,3 千条精选样本用于 RL。
这个仓库为什么需要定制版 vLLM?它附带 vLLM 源码补丁,在 RL rollout 期间为 Emu3.5 启用快速的无 CFG 并行推理,吞吐量比标准 CFG 模式大约翻倍,并在 vLLM 里加入了对 Emu3.5 的 LoRA 支持。
模型需要为每个推理步骤提供文本标签吗?不需要。它直接从图像序列学习视觉推理,不需要密集的图文对,以自回归方式生成未来帧,而不是生成中间文本链。
What are similar projects?halo, Intern-Decision, open-r1, OraRL, verl, verl, jeeves, minimind
Creator
FlagOpen
Size
31.7 MB
Stars
178
Updated
CommitJul 25
Age
1mo
Commits · 90 Days