An Adaptive Placement and Parallelism Framework for Accelerating RLHF Training

framework 2312.11819
RLHFplacementparallelismdistributed-trainingscheduling

An Adaptive Placement and Parallelism Framework for Accelerating RLHF Training #

Youshao Xiao, Zhenglei Zhou, Fagui Mao, Weichang Wu, Shangchun Zhao, Lin Ju, Lei Liang, Xiaolu Zhang, Jun Zhou | 2023-12 | https://arxiv.org/abs/2312.11819 Category: framework | Tags: RLHF, placement, parallelism, distributed-training, scheduling Read: 2026-04-16

Core Contribution #

FlexRLHF提出两种模型放置策略(Interleaving和Disaggregated),打破RLHF训练中四个模型Co-located在所有设备上的固定范式,通过精细化的设备分配和训练/推理运行时解耦,在大规模场景下实现最高11×的吞吐量提升。


粗读 #

核心三问 #

Figure 1: RLHF Workflow and Stage Duration #

Figure 1: RLHF Workflow and Stage Duration

What it shows: RLHF的三阶段流水线(Generation→Forward→Training)及各阶段耗时占比——Generation占84.6%,Forward占5.1%(其中Actor 0.7%, Critic 1.5%, Ref 1.2%, Reward 1.7%),Training占10.3%。

Why it matters: 直观展示Generation阶段占85%以上时间的瓶颈问题,这是全文motivation的核心依据。图中绿色=trainable model(Actor/Critic),紫色=inference-only model(Ref/Reward),四个模型在三阶段的角色差异为后续放置策略优化提供了依据。

逻辑故事还原 #

Figure 2: Model Placement Strategies Architecture #

Figure 2: Model Placement Strategies Architecture

What it shows: 四种放置策略对比 — (a) Co-located:四个模型绑定在所有设备上, (b) Interleaving:Ref和Reward分配到不同设备组, (c) Disaggregated同构:Shadow Actor/Critic分离到专用推理设备, (d) Disaggregated异构:推理模型放在低端GPU(V100),训练放高端GPU(A100)。

Why it matters: 论文最核心的架构图,一图说清三种策略的本质区别——从"全员共享"到"按需分离"。注意(c)(d)中的虚线椭圆表示Shadow模型,箭头表示参数同步方向。

Key Tables #

Table I: Interleaving vs Co-located (AC-NonShare, DeepSpeed-Chat) #

# GPUsStrategy7B13B33B65B
8DeepSpeed-Chat16.127.320.69OOM
8Interleave₁17.357.630.69OOM
2×8DeepSpeed-Chat32.1515.350.640.14
2×8Interleave₁34.7015.660.640.14
2×8Interleave₂18.278.270.970.24
4×8DeepSpeed-Chat61.9528.600.930.20
4×8Interleave₁69.4428.540.950.20

Takeaway: Interleave₁在小模型(7B/13B)上有7-12%提升;Interleave₂在大模型(33B/65B)+ZeRO-3场景下提升52-71%,因为将Actor限制在单节点内避免了跨节点AllGather。

Table II: Disaggregated vs DeepSpeed-Chat (AC-NonShare) #

# GPUsStrategy33B65B
4×8DeepSpeed-Chat0.930.20
4×8Disaggregated4.761.75
16×8DeepSpeed-Chat2.110.55
16×8Disaggregated10.076.80

Takeaway: Disaggregated策略在大规模场景下碾压式领先,65B@16×8达到11×加速。核心来源于将Generation解耦后可使用节点内TP,避免ZeRO-3的跨节点通信。

Table V: Interleaving vs trlX (AC-Share, Scalability) #

# GPUstrlXInterleavingSpeedup
1×8 (7B)6.2127.274.4×
2×8 (7B)7.7654.717.1×
4×8 (7B)8.87109.1812.3×
1×8 (13B)2.2211.765.3×
4×8 (13B)4.2446.1610.9×

Takeaway: trlX的单卡Reward瓶颈在扩展时完全暴露——设备数增加但吞吐几乎不变。FlexRLHF近乎线性扩展。

关键细节与启示 #

Summary #

RLHF训练涉及4个模型(Actor、Critic、Ref、Reward)的复杂协同,现有框架采用Co-located策略将所有模型放在每个设备上,导致内存冗余和通信开销严重,且Generation阶段成为性能瓶颈(占85%+时间)。

FlexRLHF提出两种创新的模型放置策略:(1) Interleaving策略将无依赖的Ref和Reward模型放在不同设备组,减半内存冗余和通信参与者数;(2) Disaggregated策略引入Shadow Actor/Critic模型,将训练和推理物理分离到不同设备组,允许各自使用最优的并行策略(训练用ZeRO/Megatron,推理用TP+DP)。框架通过Model Placement Ratio抽象简化配置,支持异构GPU集群。

实验在Llama 7B-65B模型、A100集群上验证,Disaggregated策略在65B@16×8 GPU配置下达到11×加速(vs DeepSpeed-Chat),Generation阶段占比从93%降至56%。对比trlX的AC-Share结构,Interleaving策略在4×8 GPU下实现12×加速,得益于消除了trlX的单卡Reward瓶颈。

Key Findings #

Limitations #

Infrastructure Impact #


Deep Analysis (framework) #

1. System Scope #

2. Architecture & Data Flow #

2a. End-to-End Data Flow #


[Prompt Dataset] → [Generation Stage] → [Forward Stage] → [Training Stage] → [Model Update]
                     ↓ Actor.generate()    ↓ All 4 models    ↓ Actor + Critic
                     ↓ Auto-regressive     ↓ forward          ↓ PPO loss
                     ↓ 85%+ total time     ↓ ~5% time         ↓ ~10% time

Co-located策略下的数据流:

StageInput → OutputLocationCommunicationDuration %
GenerationPrompts → ResponsesAll GPUs (Actor)AllGather params in ZeRO-3~85%
Actor Forward(Q,R) → logitsAll GPUsZeRO comm~2%
Ref Forward(Q,R) → ref_logitsAll GPUsZeRO comm~2%
Reward Forward(Q,R) → scoresAll GPUsZeRO comm~1%
Critic Forward(Q,R) → valuesAll GPUsZeRO comm~1%
Experience BufferAll outputs → bufferCPU/GPU memoryNonenegligible
Actor TrainingBuffer batch → grad updateAll GPUsZeRO allreduce~5%
Critic TrainingBuffer batch → grad updateAll GPUsZeRO allreduce~5%

Figure 3: Co-located vs Interleaving Execution Timeline #

Figure 3: Co-located vs Interleaving Execution Timeline

What it shows: (a) Co-located策略下所有模型在W1、W2两个设备上的执行时间线——Ref和Reward均占两个Worker,batch size=6。(b) Interleaving策略将Ref放W1、Reward放W2后的时间线——batch size提升至12,Ref和Reward并行执行。颜色编码:蓝=Generate,黄=Forward,绿=Forward & Backward。

Why it matters: 直观展示Interleaving的两个加速来源:(1) Ref/Reward各只需一个设备,内存冗余减半,batch size翻倍;(2) Ref和Reward在不同设备上并行执行Forward,无需设备间通信。注意(b)中Ref(W1)和Reward(W2)的Forward块完全并行。

Disaggregated策略下的数据流:

StageInput → OutputLocationCommunication
GenerationPrompts → ResponsesInference GPUs (Shadow Actor, TP+DP)Intra-node TP only
Forward(Q,R) → all outputsInference GPUs (Shadow Actor/Critic + Ref + Reward)P2P within inference group
Data TransferExperience data → Training GPUsCross-groupP2P send/recv
TrainingBuffer → grad updateTraining GPUs (Actor + Critic, Megatron)Intra-group ZeRO/TP
Param SyncTrained params → Shadow modelsCross-groupBroadcast/P2P (periodic)

Figure 4: Disaggregated Strategy Execution Timeline #

Figure 4: Disaggregated Strategy Execution Timeline

What it shows: (a) 同构Disaggregated策略——W1-W2为训练设备,W3-W4为推理设备(含Shadow Actor/Critic、Ref、Reward)。Generation(G)和Training(F&B)通过micro-batching pipeline化执行。(b) 异构Disaggregated策略——更大规模(7个Worker),Shadow Actor独占W6-W7,展示12个micro-batch的pipeline调度。斜线填充=Shadow模型。

Why it matters: 展示Disaggregated策略的核心机制——训练和推理物理分离后可以pipeline并行执行。(a)中bubble几乎被micro-batching完全隐藏(G1/G2完成后F1/F2立即开始,无需等待G3/G4)。灰色斜线块=参数同步开销,仅在每轮PPO训练后执行一次。

2b. Data Movement Hotspots #

  1. ZeRO-3 AllGather during Generation (Co-located): 每次Generation需要AllGather完整模型参数到每张卡,对65B模型约130GB参数。频率:每个Generation step一次。Disaggregated策略完全消除此开销——Shadow Actor使用TP,参数常驻。
  2. Interleaving策略的AllGather+AlltoAll: Ref/Reward模型在Forward前需要AllGather收集所有(Q,R)数据,Forward后AlltoAll分发结果。频率:每rollout step一次。通过计算-通信重叠隐藏。
  3. Disaggregated的P2P Experience Transfer: 推理设备→训练设备的experience数据传输。频率:每micro-batch一次。通过pipeline化执行与计算重叠。
  4. Control plane vs Data plane: 未明确分离。Execution Engine作为control plane管理设备分配和通信拓扑;模型计算和数据传输为data plane。

    Failure handling: 论文未讨论容错机制,这是一个明显缺失。

    3. Key Innovations #

    InnovationMechanismBenefitCost/Tradeoff
    Interleaving Placement将无依赖模型(Ref/Reward)放在不同设备组,各占50%设备减半内存冗余,减少ZeRO通信参与者,增大batch size新增AllGather+AlltoAll通信(但可被重叠隐藏);大模型+ZeRO-3时Interleave₁无效
    Disaggregated Placement创建Shadow Actor/Critic用于推理,物理分离训练和推理到不同设备组Generation可用TP代替ZeRO-3 AllGather,训练/推理pipeline并行需额外GPU内存存放Shadow模型;需周期性参数同步;不适合小规模场景
    Model Placement Ratio用0-1比例值配置每个模型的设备分配比例,自动生成设备映射用户只需设[1,1,0.5,0.5]即可配置Interleaving最优比例仍需手动调优或依赖guideline
    Pipeline Micro-batchingDisaggregated策略中Generation/Forward/Training按micro-batch pipeline执行隐藏bubble开销,提高设备利用率增加实现复杂性;micro-batch数需调优
    Heterogeneous Device SupportDisaggregated分离后,推理模型可放低端GPU(V100),训练放高端GPU(A100)利用闲置异构资源,降低成本不同GPU间只能用以太网连接,通信受限;实验仅14.49%提升

    4. Scheduling & Resource Management #

    • Batch formation: 静态batch,最大化内存利用(填到95%内存上限前停止)。不同策略下最大batch size不同。
    • Memory management: 依赖底层框架(DeepSpeed ZeRO / Megatron)的内存管理。Interleaving策略的核心价值就是通过减少每设备模型数来释放内存。
    • GPU utilization: Co-located策略下训练模型在Generation阶段大量idle但占用内存;Disaggregated通过物理分离消除这种浪费。Pipeline micro-batching进一步减少bubble。
    • Multi-tenancy: 不支持。单训练任务独占集群。
    • Priority/SLO-aware: 无。纯throughput优化,无延迟约束。

    批判性评价: 调度仍然较为静态——设备分组和比例在训练前确定,运行时不动态调整。如果不同stage的workload随训练进度变化(如Generation越来越快或慢),无法自适应调节资源分配。

    5. Target Scenarios #

    ScenarioWorkload PatternGoalWhy existing fails
    中小模型RLHF (7B-13B)4模型全放单节点/少节点最大化throughputCo-located浪费内存冗余
    大模型RLHF (33B-65B) 同构多节点,ZeRO-3必须最大化throughputZeRO-3跨节点AllGather开销巨大
    大模型RLHF 异构 (A100+V100)混合GPU集群利用闲置资源Co-located无法在异构GPU上运行
    AC-Share结构Reward模型需独立放置消除单卡瓶颈trlX把Reward放单卡,扩展性差

    Primary bottleneck per scenario:

    • 7B-13B: Memory-bound(内存冗余限制batch size)→ Interleaving解决
    • 33B-65B: Communication-bound(ZeRO-3跨节点AllGather)→ Disaggregated + 节点内TP解决
    • 异构: Communication-bound(不同GPU间以太网带宽低)→ Disaggregated隔离通信域
    • AC-Share: Scheduling-bound(单卡Reward瓶颈)→ Interleaving分布式化Reward

    6. Performance Evaluation #

    6a. Metrics #

    MetricDefinitionUnitHigher/Lower
    Sample Throughput端到端每秒处理的样本数samples/secHigher
    Maximum Batch Size不OOM情况下最大可用batch size# samplesHigher
    Generation Stage Duration %Generation阶段占总时间的比例%Lower

    批判: 指标过于单一。缺少GPU utilization、通信占比、内存效率、cost/sample等关键指标。未报告P99延迟或per-step time breakdown。

    6b. Before-After Comparison #

    OptimizationMetricBaselineAfterImprovementConditions
    Interleave₁Throughput16.1217.35+7.6%7B, 8 GPUs, AC-NonShare, ZeRO-2
    Interleave₁Throughput61.9569.44+12.1%7B, 4×8 GPUs, AC-NonShare
    Interleave₂Throughput0.140.24+71%65B, 2×8 GPUs, ZeRO-3
    DisaggregatedThroughput0.934.765.1×33B, 4×8 GPUs, ZeRO-3
    DisaggregatedThroughput0.556.8012.4×65B, 16×8 GPUs, ZeRO-3
    DisaggregatedGen Stage %93.31%56%-37pp33B, 4×8 GPUs
    Interleaving (vs trlX)Throughput6.2127.274.4×7B, 1×8, AC-Share, GC-ON
    Interleaving (vs trlX)Throughput8.87109.1812.3×7B, 4×8, AC-Share, GC-ON
    Interleaving (vs trlX)Max Batch25025×13B, AC-Share
    HeterogeneousThroughput0.690.79+14.5%33B, 8 A100 + 8 V100

    6c. Bottleneck Shift Analysis #

    
    Co-located baseline: Communication-bound (ZeRO-3 AllGather during Generation, 93% time)
      → After Interleaving: Still Generation-bound but reduced (fewer comm participants)
      → After Disaggregated: Generation reduced to 56%, Training becomes more visible
         Remaining bottleneck: Generation still dominant; pipeline bubble overhead; param sync cost
    

    Figure 7: Generation vs Training Duration — Disaggregated vs DeepSpeed-Chat #

    Figure 7: Generation vs Training Duration

    What it shows: AC-NonShare场景下Llama 33B在4×8 GPU上的per-step耗时分解。DeepSpeed-Chat:总耗时~400秒(Generation 93.31% + Training 6.69%)。Disaggregated策略:总耗时~30秒(Generation 56.52% + Training 43.48%)。

    Why it matters: 最直观的加速效果图——Disaggregated策略将Generation从~370秒压缩到~17秒(约22×加速),总step时间从~400秒降至~30秒(约13×加速)。Generation占比从93%降至56%,bottleneck开始向Training转移,说明进一步优化需要同时关注两个阶段。

    关键观察: Disaggregated策略成功地将Generation从93%降到56%,但并没有完全消除Generation瓶颈。进一步优化需要更强的推理引擎(如vLLM/SGLang的speculative decoding等)。

    6d. Baselines & Fairness #

    • Baseline公平性: 对比DeepSpeed-Chat和trlX,使用相同硬件、模型、数据集,公平性可接受
    • 但存在问题:
    • DeepSpeed-Chat的Hybrid Engine本身实现可能不是最优的(它也在持续改进)
    • trlX将Reward放在单卡是一个明显的设计缺陷,FlexRLHF赢得太容易
    • 未对比Colossal-AI的RLHF实现、后来的OpenRLHF等
    • 序列长度固定256,现代RLHF通常用2048+
    • 所有模型同大小的假设不太实际(Reward模型通常比Actor小得多)
    • Baseline何时胜出: Co-located在极小规模(单卡、小模型)时因无额外通信开销可能更优;Interleave₁在大模型+ZeRO-3时无效(Table I中33B/65B与baseline相同)

    7. API & Usability #

    • API: 自定义Python API,非标准化。通过Model Placement Ratio ([1, 1, 0.5, 0.5]) 配置策略
    • Model support: 基于PyTorch + DeepSpeed/Megatron,支持HuggingFace格式
    • Deployment: 需要在DGX集群上部署,依赖NCCL/InfiniBand
    • Configuration: 需要设定4个模型各自的placement ratio + 每个模型的parallelism策略 + batch size。虽然提供了guideline,但仍有较多knobs需要调优

    Guideline总结:

    1. 资源有限 → Interleaving(Ref/Reward可放单节点时)或 Co-located
    2. 资源充足 → Disaggregated(30-50%设备给Shadow Actor)
    3. 异构集群 → Heterogeneous Disaggregated(低端GPU做推理,高端做训练)
    4. 8. Infrastructure Impact #

      LayerImpact
      Algorithm为PPO训练提供了高效分布式范式,但PPO正在被DPO/GRPO替代;Disaggregated的训练-推理分离思想对GRPO(也有generation阶段)同样适用
      Kernel不依赖自定义kernel,使用标准DeepSpeed/Megatron/vLLM kernel。Disaggregated策略的价值在于允许推理端自由选择最优kernel
      LLM支持标准Transformer架构(Llama系列),MoE模型的支持未验证——MoE的expert parallelism会增加placement的复杂度
      AgentN/A — 纯训练框架
      Ops缺乏自动化配置能力,需要人工根据guideline确定最优配置;无自动profiling或auto-tuning功能

      9. Comparison Matrix #

      FeatureFlexRLHFDeepSpeed-ChattrlXOpenRLHF (后发)
      Model PlacementInterleaving + Disaggregated + Co-locatedCo-located onlyCo-located variant (Reward单卡)Ray-based placement
      Training-Inference分离✅ (Disaggregated)❌ (Hybrid Engine混合)✅ (vLLM integration)
      异构GPU支持部分支持
      Pipeline执行✅ (micro-batching)❌ (sequential)❌ (sequential)
      AC-Share支持
      AC-NonShare支持
      推理引擎集成Megatron TPHybrid EngineHuggingFacevLLM
      配置简易度中等(Placement Ratio + guideline)低(自动但不灵活)高(Ray自动调度)
      开源
      扩展性 (>64 GPU)✅ (tested 128 GPUs)❌ (单卡瓶颈)
      容错未提及CheckPoint未提及CheckPoint

      10. Adoption & Maturity #

      • Open source: 未开源,这是最大的限制。论文来自蚂蚁集团,可能作为内部训练基础设施使用
      • Community: 无公开社区。论文被引用约50次(截至2025),主要作为RLHF系统设计的reference
      • Production: 论文提到在蚂蚁集团内部使用,但无公开的production deployment案例
      • Adoption barrier:
      • 未开源,无法直接复现或使用
      • 核心思想(训练-推理分离、灵活placement)已被OpenRLHF等开源框架吸收
      • 如今RLHF训练更多采用DPO/GRPO等不需要4模型的方法,PPO的重要性相对降低
      • Historical significance: 作为较早系统性分析RLHF分布式训练效率问题的工作,其Interleaving和Disaggregated的思想有持续影响力。特别是"训练-推理运行时分离"的理念已成为后续系统的标配