Flash-RL

yaof20MIT长期未更新

用 FP8/INT8 低精度做强化学习训练的 rollout 推理,在 vLLM 上跑出更快采样速度且不掉点,适合想压低 RL 训练推理成本的大模型团队。

Implementation for FP8/INT8 Rollout for RL training without performence drop.

暂无版本309star23fork同步于 2026-11-07 07:28 UTC

怎么上手

由 README 提炼,执行前请确认
pip install flash-llm-rl
export FLASHRL_CONFIG=fp8
硬件要求按 README 说明

README 未说明具体显存要求,仅建议用于 14B 以上、最好 32B+ 的大模型配合长思维链生成;测试环境为 CUDA 12.6 镜像,未列出 GPU 型号。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 vLLM 推理后端打补丁,让 RL 训练用 INT8/FP8 生成 rollout 且不掉精度

用 FP8/INT8 低精度做强化学习训练的 rollout 推理,在 vLLM 上跑出更快采样速度且不掉点,适合想压低 RL 训练推理成本的大模型团队。

核心能力

  • 用环境变量 FLASHRL_CONFIG 切换 bf16/fp8/int8 量化精度
  • 打补丁后仍能拿到精确的 rollout logprob
  • 支持 int8/fp8_channel 的 profiling 与配置生成
  • 可在 DP worker 间混合 16bit 与 8bit 生成
  • 提供 bf16 模式仅修正 logprob 以支持截断重要性采样

容易踩的坑

多机训练时每个节点都要安装 flash-llm-rl;int8 或 fp8_channel 需先跑 flashrl profile 和 flashrl setup 生成配置,fp8/bf16 不需要;量化有额外开销,小模型或短生成场景不建议用;目前只支持 vLLM 和 VeRL。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    FlashRL patches the inference backend to generate RL rollouts in INT8 & FP8, with accurate rollout logprob.

    DAPO 32B run Figure 1. Left: AIME accuracy of Qwen2.5-32B DAPO training with INT8 and BF16 precisions for rollout generation using vLLM engine. Right: Training throughput (updates per hour) in the DAPO training (vLLM + BF16 FSDP).

    ⚡ Quick Start

    Installation (Auto Patch)

    pip install flash-llm-rl # need to be installed in all nodes in multi-node training
    

    (Optional) there are two options to verify the FlashRL install: 1) set FLASHRL_LOGGING_LEVEL to DEBUG and compare the log with the provided ones; 2) for more details / debugging, please follow the Tutorial.

    Manual Patch

    When the FlashRL patch conflicts with environments / other setups, an alternative approach is to:

    1. cleanup FlashRL patch via flashrl cleanup, this will disable the auto patch;
    2. manually add import flash_rl as in https://github.com/yaof20/verl/pull/1

    Rollout Generation w. FP8 Quantization

    FlashRL is implemented as a plug-in-and-play manner, using environment variables FLASHRL_CONFIG to control the quantization precision. Note that, due to quantization overhead, it is only recommended to use quantized rollout in the combination of large model (i.e., 14B+, preferrable 32B+) and long cot generation (DAPO training instead of GSM8K training).

    # for single-node job
    export FLASHRL_CONFIG=fp8
    bash verl/examples/ppo_trainer/run_qwen2.5-32b.sh
    
    # alternatively, for multi-node jobs via `ray submit`, fp8 online quantization will be turned on via
    # > echo "  FLASHRL_CONFIG: 'fp8'" | tee -a verl/trainer/runtime_env.yaml # add `FLASHRL_CONFIG: 'fp8'` to runtime env
    # > bash verl/recipe/dapo/run_dapo_qwen2.5_32b.sh # this can be any scripts
    

    RL Logprob Patch Only

    Setting the config to bf16 to extract precise logprob used in sampling without rollout quantization. This is useful for applying the Truncated Importance Sampling.

    #  for single-node job
    export FLASHRL_CONFIG=bf16
    bash verl/examples/ppo_trainer/run_qwen2.5-32b.sh
    
    # alternatively, for multi-node jobs via `ray submit`, RL Logprob Patch Only will be turned on via
    # > echo "  FLASHRL_CONFIG: 'bf16'" | tee -a verl/trainer/runtime_env.yaml # add `FLASHRL_CONFIG: 'fp8'` to runtime env
    # > bash verl/recipe/dapo/run_dapo_qwen2.5_32b.sh # this can be any scripts
    

    Usage Guide

    FlashRL has 3 major functionality, profiling, configure helper, and patcher.

    Profiling (optional for fp8 and bf16)

    This step is not needed for the native fp8 online quantization supported by vLLM, and the logprog-only path bf16, and is needed for int8 or fp8_channel quantization. Specifically, profilling compares a bf16 model and a quantized model to decide how the online quantization should be performed for an updated model. Please find below an example for Qwen/Qwen2.5-32B and Qwen/Qwen2.5-0.5B-Instruct. The quantized model can be any w8a8/fp8 model produced by llm-compressor. Note that, Redhat AI provides various quantized models, and can be used here as in the 0.5B-Instruct example.

    # for `Qwen/Qwen2.5-32B`
    flashrl profile -m Qwen/Qwen2.5-32B -qm LiyuanLucasLiu/Qwen2.5-32B-quantized.w8a8 -o ${PROFILE_PATH:-"$HOME/profile.32b.pt"} --fn int8
    
    # for `Qwen/Qwen2.5-0.5B-Instruct`
    flashrl profile -m Qwen/Qwen2.5-0.5B-Instruct -qm RedHatAI/Qwen2.5-0.5B-Instruct-quantized.w8a8 -o ${PROFILE_PATH:-"$HOME/profile.0_5b.pt"} --fn int8
    

    Configure Helper (optional for fp8 and bf16)

    This step is not needed for the native fp8 online quantization supported by vLLM, and the logprog-only path bf16, and is needed for int8 or fp8_channel quantization. Specifically, configure helper creates a yaml file for the patcher to use. Please find below an example for Qwen/Qwen2.5-32B and Qwen/Qwen2.5-0.5B-Instruct.

    # for `Qwen/Qwen2.5-32B`
    flashrl setup -m LiyuanLucasLiu/Qwen2.5-32B-quantized.w8a8 -p $HOME/profile.32b.pt --fn int8 -o ${CONFIG_PATH:-"$HOME/.flashrl_config.32b.yaml"}
    
    # for `Qwen/Qwen2.5-0.5B-Instruct`
    flashrl setup -m RedHatAI/Qwen2.5-0.5B-Instruct-quantized.w8a8 -p $HOME/profile.0_5b.pt --fn int8 -o ${CONFIG_PATH:-"$HOME/.flashrl_config.0_5b.yaml"}
    

    (Optional) to reduce the gap between rollout generation and gradient computation, FlashRL provides the functionality to conduct rollout generation in 16bits and 8bits in a hybrid manner across DP workers. Particularly, running the below command will append a second config to the existing config yaml.

    flashrl setup -a --fn bf16 -o ${CONFIG_PATH:-"$HOME/.flashrl_config.0_5b.yaml"}
    

    Then, when FlashRL loading the appended the config yaml file, FlashRL will force vllm to conduct bf16 generation in half of DP workers, and 8bit generation in the other half. Futher appending two bf16 profiles will make the ratio to be bf16 generation in 3/4 of DP workers and 8bit generation in 1/4 of DP workers.

    Patcher

    Patcher would check the environment variable and operates accordingly. Please find the supported environment variables as below.

    Environment VariableUsage
    FLASHRL_CONFIGapplies patcher if configured, supports bf16, fp8, local profile paths (e.g., $HOME/.flashrl_config.32b.yaml), and uploaded profiles (e.g., LiyuanLucasLiu/Qwen2.5-0.5B-Instruct-quantized.w8a8-RedHatAI/flashrl_config.yaml)
    FLASHRL_LMHEAD_FP32if set to 1, forcing vLLM conducting lm head compute in bf16
    FLASHRL_LOGGING_LEVELset to DEBUG to turn on verbose logging for FlashRL functions
    FLASHRL_LOGGING_FILEif set, will save the log to files as well
    FLASHRL_TEST_RELOADfunctionality provided to test FlashRL install, check this guide for more details

    Examples

    Run DetailScriptCommandLog
    INT8 Rollout for Qwen2.5-0.5B-Instruct on GSM8KScriptbash recipe/flash_rl/gsm8k_qwen0_5b_int8.sh flash-int8-TIS-2 2Wandb Log
    INT8 Rollout for Qwen2.5-32B-Instruct on DAPOScriptbash recipe/flash_rl/dapo_qwen32b_int8.sh flash-int8-TIS-8 8Wandb
    FP8 Rollout for Qwen2.5-0.5B-Instruct on DAPOScriptbash recipe/flash_rl/gsm8k_qwen0_5b_fp8.sh flash-fp8-TIS-2 2Wandb Log
    FP8 Rollout for Qwen2.5-32B-Instruct on DAPOScriptbash recipe/flash_rl/dapo_qwen32b_fp8.sh flash-fp8-TIS-8 8IN Progress

    Tested Environments

    Below are the combinations of the environments that we have tested on.

    ImageCUDARayvLLMverlflash-rlGSM8K 8bit exampleDAPO INT8 example
    hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.3-flashinfer0.2.2-cxx11abi012.62.43.00.8.3flash-rl1.0.1✅ Tested✅ Tested
    hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.4-flashinfer0.2.2-cxx11abi012.62.43.00.8.4flash-rl1.0.1✅ Tested
    hiyouga/verl:ngc-th2.7.0-cu12.6-vllm0.9.112.62.43.00.9.1flash-rl-vllm0.9.11.0.2✅ Tested
    hiyouga/verl:ngc-th2.7.1-cu12.6-vllm0.10.012.62.48.00.10.0flash-rl-vllm0.9.11.0.2✅ Tested

    🚧 Roadmap & Future Improvements

    We're working on several improvements to Flash-RL:

    • Support of Other RL Toolkits: Currently Flash-RL only supports VeRL, we are working on rolloing out support for other packages like OpenRLHF
    • Support of Other LLM Inference Toolkits: Currently Flash-RL only supports vLLM, we are working on rolloing out support for other tollkits like SgLang
    • Further Throughput Optimization: We are working on implementing efficient GPU kernels to accelerate online quantization

    📚 Citation

    If you find our work useful, please cite us:

    @misc{yao2025offpolicy,
      title = {Your Efficient RL Framework Secretly Brings You Off-Policy RL Training},
      url = {https://fengyao.notion.site/off-policy-rl},
      author = {Yao, Feng and Liu, Liyuan and Zhang, Dinghuai and Dong, Chengyu and Shang, Jingbo and Gao, Jianfeng},
      journal = {Feng Yao's Notion},
      year = {2025},
      month = aug,
    }
    @misc{yao2025flashrl,
      title = {FlashRL: 8Bit Rollouts, Full Power RL},
      url = {https://fengyao.notion.site/flash-rl},
      author = {Liu, Liyuan and Yao, Feng and Zhang, Dinghuai and Dong, Chengyu and Shang, Jingbo and Gao, Jianfeng},
      journal = {Feng Yao's Notion},
      year = {2025},
      month = aug,
    }
    

    Questions?

    If you have any questions related to the code or the blog, feel free to reach out to us at Liyuan Liu and Feng Yao.