Skip to main content

veRL: Volcano Engine Reinforcement Learning for LLM

Project description

veRL: Volcano Engine Reinforcement Learning for LLM

veRL (HybridFlow) is a flexible, efficient and industrial-level RL(HF) training framework designed for large language models (LLMs). veRL is the open-source version of HybridFlow paper.

veRL is flexible and easy to use with:

  • Easy to support diverse RL(HF) algorithms: The Hybrid programming model combines the strengths of single-controller and multi-controller paradigms to enable flexible representation and efficient execution of complex Post-Training dataflows. Allowing users to build RL dataflows in a few lines of code.

  • Seamless integration of existing LLM infra with modular API design: Decouples computation and data dependencies, enabling seamless integration with existing LLM frameworks, such as PyTorch FSDP, Megatron-LM and vLLM. Moreover, users can easily extend to other LLM training and inference frameworks.

  • Flexible device mapping: Supports various placement of models onto different sets of GPUs for efficient resource utilization and scalability across different cluster sizes.

  • Readily integration with popular Hugging Face models

veRL is fast with:

  • State-of-the-art throughput: By seamlessly integrating existing SOTA LLM training and inference frameworks, veRL achieves high generation and training throughput.

  • Efficient actor model resharding with 3D-HybridEngine: Eliminates memory redundancy and significantly reduces communication overhead during transitions between training and generation phases.

| Documentation | Paper |

Installation

For installing the latest version of veRL, the best way is to clone and install it from source. Then you can modify our code to customize your own post-training jobs.

# install verl together with some lightweight dependencies in setup.py
git clone https://github.com/volcengine/verl.git
cd verl
pip3 install -e .

You can also install veRL using pip3 install

# directly install from pypi
pip3 install verl

Dependencies

veRL requires Python >= 3.9 and CUDA >= 12.1.

veRL support various backend, we currently release FSDP and Megatron-LM for actor training and vLLM for rollout generation.

To install the dependencies, we recommend using conda:

conda create -n verl python==3.9
conda activate verl

The following dependencies are required for all backends.

# install torch [or you can skip this step and let vllm to install the correct version for you]
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121

# install vllm
pip3 install vllm==0.5.4
pip3 install ray==2.10 # other version may have bug

# flash attention 2
pip3 install flash-attn --no-build-isolation

FSDP

We recommend using FSDP backend to investigate, research and prototype different models, datasets and RL algorithms.

The pros, cons and extension guide for using FSDP backend can be found in PyTorch FSDP Backend

Megatron-LM

For users who pursue better scalability, we recommend using Megatron-LM backend. Please install the above dependencies first.

Currently, we support Megatron-LM@core_v0.4.0 and we fix some internal issues of Megatron-LM. Here's the additional installation guide.

The pros, cons and extension guide for using Megatron-LM backend can be found in Megatron-LM Backend

# FOR Megatron-LM Backend
# apex
pip3 install -v --disable-pip-version-check --no-cache-dir --no-build-isolation \
         --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" \
         git+https://github.com/NVIDIA/apex

# transformer engine
pip3 install git+https://github.com/NVIDIA/TransformerEngine.git@v1.7

# megatron core v0.4.0
cd ..
git clone -b core_v0.4.0 https://github.com/NVIDIA/Megatron-LM.git
cd Megatron-LM
cp ../verl/patches/megatron_v4.patch .
git apply megatron_v4.patch
pip3 install -e .
export PYTHONPATH=$PYTHONPATH:$(pwd)

Getting Started

Visit our documentation to learn more.

Running an PPO example should follow:

For code explanation and advance usage (extension):

Contribution

Code formatting

We use yapf (Google style) to enforce strict code formatting when reviewing MRs. To reformat you code locally, make sure you installed yapf

pip3 install yapf

Then, make sure you are at top level of verl repo and run

yapf -ir -vv --style ./.style.yapf verl single_controller examples

Citation

@article{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},
  year    = {2024},
  journal = {arXiv preprint arXiv: 2409.19256}
}

@inproceedings{zhang2024framework,
  title={A Framework for Training Large Language Models for Code Generation via Proximal Policy Optimization},
  author={Zhang, Chi and Sheng, Guangming and Liu, Siyao and Li, Jiahao and Feng, Ziyuan and Liu, Zherui and Liu, Xin and Jia, Xiaoying and Peng, Yanghua and Lin, Haibin and Wu, Chuan},
  booktitle={In NL2Code Workshop of ACM KDD},
  year={2024}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verl-0.1rc0.tar.gz (222.7 kB view details)

Uploaded Source

Built Distribution

verl-0.1rc0-py2.py3-none-any.whl (332.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file verl-0.1rc0.tar.gz.

File metadata

  • Download URL: verl-0.1rc0.tar.gz
  • Upload date:
  • Size: 222.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for verl-0.1rc0.tar.gz
Algorithm Hash digest
SHA256 5e13b84588a76d73f7edb30020428aeaba5081ddc643260aa470b067c403b2f1
MD5 a3a1ab54cc15aede6bdb422f96ae5c59
BLAKE2b-256 c31ef08abc3db1fade00aac8797d5e21bbc3f198cc91d64772ba219cea0d9a3a

See more details on using hashes here.

File details

Details for the file verl-0.1rc0-py2.py3-none-any.whl.

File metadata

  • Download URL: verl-0.1rc0-py2.py3-none-any.whl
  • Upload date:
  • Size: 332.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for verl-0.1rc0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2db37387cc2ca600d9989ec67285c561b9f3acf5152c15801b4de892cf1be139
MD5 b1efd659375b4f66ff50308245af97fa
BLAKE2b-256 9f86496edb88346dafe6a0476247aae75f6ec1662af25c077d03026dc7cd9edf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page