This repository contains the RL training and evaluation component of SpaceTools, a tool-augmented spatial reasoning system for VLMs. It is a fork of verl v0.8.0-dev with extensions for multi-turn tool interaction during RL training.
This repo is intended to be used as a submodule of the SpaceTools parent repository. See the parent repo for full pipeline instructions.
Core modifications for multi-turn tool interaction during RL:
| File | Change |
|---|---|
verl/protocol.py |
Multimodal DataProto support (string image paths) |
verl/workers/fsdp_workers.py |
Granular vision/language/projection model freezing |
verl/trainer/ppo/ray_trainer.py |
Multi-turn rollout orchestration, validation-only mode |
verl/utils/dataset/rl_dataset.py |
Multimodal dataset loading, aspect-ratio-preserving resize |
verl/utils/dataset/vision_utils.py |
Image preprocessing for Qwen2.5-VL |
verl/experimental/agent_loop/tool_agent_loop.py |
Toolshed agent loop integration |
verl/utils/reward_score/ |
14 SpaceTools reward modules |
examples/toolshed/
├── run_rl.sh # RL training (V1 or V2)
├── run_rl_roborefer.sh # Roborefer-only RL (standalone, resumable)
├── run_eval.sh # Evaluation on paper benchmarks
├── generate_toolshed_config.py # Auto-generate tool config from live actors
├── toolshed_v1_config.yaml # V1 tool schemas (11 tools, no robot)
├── toolshed_v2_config.yaml # V2 tool schemas (17 tools, with robot)
└── README.md # Toolshed integration details
analysis/
└── analyze_grasp_result.py # Grasp evaluation analysis
GRPO training with live Toolshed tool execution. Takes an SFT checkpoint (produced by SpaceTools-SFT) as input.
Required environment variables:
| Variable | Description |
|---|---|
SFT_CHECKPOINT |
Path to SFT checkpoint (output of run_sft.sh) |
ROBOREFER_MODEL |
Path to RoboRefer-8B-SFT model |
DEPTH_CHECKPOINT |
Path to depth_pro.pt checkpoint |
Optional environment variables:
| Variable | Default | Description |
|---|---|---|
VERSION |
v1 |
v1 (7 tools) or v2 (8 tools + mock_robot) |
OUTPUT_DIR |
experiments/rl_<version>_<timestamp> |
Output directory (reuse for resume) |
GPUS_PER_NODE |
8 |
GPUs per node |
SAVE_FREQ |
5 |
Checkpoint save frequency in steps (-1 to disable) |
Usage:
conda activate spacetools-rl
SFT_CHECKPOINT=/path/to/sft_checkpoint \
ROBOREFER_MODEL=/path/to/RoboRefer-8B-SFT \
DEPTH_CHECKPOINT=/path/to/depth_pro.pt \
bash examples/toolshed/run_rl.sh
# V2 (with mock robot):
VERSION=v2 SFT_CHECKPOINT=... ROBOREFER_MODEL=... DEPTH_CHECKPOINT=... \
bash examples/toolshed/run_rl.shSLURM (multi-node, wall-time resubmission):
The script requires 2 nodes and must be launched via SLURM. Training typically takes 8-12 hours (~86 steps at ~5-7 min/step), which may exceed wall-time limits. The script auto-resumes from the latest checkpoint in OUTPUT_DIR, so you can resubmit the same job after a wall-time kill:
# Create a wrapper script that sets env vars and sources run_rl.sh,
# then submit via sbatch:
sbatch --nodes=2 --gpus-per-node=8 --exclusive --time=4:00:00 my_wrapper.sh
# After wall-time kill, resubmit the same script to resume:
sbatch --nodes=2 --gpus-per-node=8 --exclusive --time=4:00:00 my_wrapper.shSee examples/toolshed/README.md for a full wrapper example.
Standalone RL training with roborefer detect_one only. Trains from base Qwen model (no SFT checkpoint required). Automatically resumes from existing checkpoints.
ROBOREFER_MODEL=/path/to/RoboRefer-8B-SFT \
bash examples/toolshed/run_rl_roborefer.shEvaluates a model checkpoint on the paper's 9 benchmarks with live tool execution.
Usage:
# All benchmarks
ROBOREFER_MODEL=/path/to/model DEPTH_CHECKPOINT=/path/to/depth_pro.pt \
bash examples/toolshed/run_eval.sh /path/to/model_checkpoint
# Specific benchmarks
bash examples/toolshed/run_eval.sh /path/to/model robospatial bopgrasp blinkdepthAvailable benchmarks:
| Key | Paper metric |
|---|---|
robospatial |
RoboSpatial (VQA, Vacant, Overall) |
reflocation, refplacement, refunseen |
RefSpatial (averaged) |
blinkdepth |
BLINK Relative Depth |
cvb2drelation |
CVBench 2D Relation |
cvb3ddepth |
CVBench 3D Depth |
boppose |
BOP-ask Pose |
bopgrasp |
BOP-ask Grasp (MACE + SR) |
Custom reward functions in verl/utils/reward_score/:
| Module | Benchmark |
|---|---|
refspatial.py |
RefSpatial RL reward |
refspatial_bench.py |
RefSpatial eval metric |
robos_tool_singleturn.py |
RoboSpatial single-turn reward |
robos_all.py |
RoboSpatial multi-turn reward |
robos_vision.py |
RoboSpatial vision-only reward |
bopask_tool_singleturn.py |
BOP-ask RL reward |
bop_ask_bench.py |
BOP-ask eval metric |
blink_relative_depth.py |
BLINK Depth eval metric |
cvbench_2d_relation.py |
CVBench 2D eval metric |
cvbench_3d_depth.py |
CVBench 3D eval metric |
spatialbench_positional.py |
SpatialBench positional metric |
erqa_choice.py |
ERQA choice metric |
RL training requires 2 nodes (16 GPUs total). Tool actors are packed onto one node via a Ray placement group, and training uses the full second node.
Node 1 — Tool actors (8 GPUs):
| Tool | Actors | GPU each |
|---|---|---|
| RoboRefer | 6 | 0.6 |
| VLM (Molmo) | 2 | 0.6 |
| SAM2 | 5 | 0.2 |
| Depth estimator | 5 | 0.2 |
| Bounding box | 5 | 0.1 |
| Grasp generator | 5 | 0.1 |
| Vision ops | 8 | 0 (CPU) |
| Mock robot (V2) | 2 | 0 (CPU) |
Node 2 — Training (8 GPUs):
FSDP training + sglang rollout engine, using trainer.n_gpus_per_node=8.
The script automatically detects the SLURM node allocation and starts a multi-node Ray cluster.
Uses the spacetools-rl conda environment. See the parent repo setup guide.
Key dependencies: sglang==0.5.6, ray==2.47.1, torch==2.9.1, flash-attn, numpy<2.0.0.
Critical: Set LD_LIBRARY_PATH before running any script:
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${CONDA_PREFIX}/lib/python3.11/site-packages/nvidia/cuda_runtime/lib:${CONDA_PREFIX}/lib/python3.11/site-packages/nvidia/cudnn/lib:${LD_LIBRARY_PATH:-}"This repository is built on verl (Volcano Engine Reinforcement Learning for LLMs) by the ByteDance Seed team. We thank the verl team for their flexible and efficient RL training framework.
@inproceedings{sheng2024hybridflow,
title={HybridFlow: A Flexible and Efficient RLHF Framework},
author={Guangming Sheng and Chi Zhang and Zilingfeng Ye and Xibin Wu and Wang Zhang and Ru Zhang and Yanghua Peng and Haibin Lin and Chuan Wu},
booktitle={The Twentieth European Conference on Computer Systems (EuroSys)},
year={2025},
url={https://arxiv.org/abs/2409.19256v2}
}@misc{chen2025spacetoolstoolaugmentedspatialreasoning,
title={SpaceTools: Tool-Augmented Spatial Reasoning via Double Interactive RL},
author={Siyi Chen and Mikaela Angelina Uy and Chan Hee Song and Faisal Ladhak and Adithyavairavan Murali and Qing Qu and Stan Birchfield and Valts Blukis and Jonathan Tremblay},
year={2025},
eprint={2512.04069},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2512.04069}
}