vLLM 集成 Ray RDT 实现万亿参数模型分片权重传输:重叠预处理与通信以加速在线 RL

作者:Aaron Hao, Sumanth Hegde, Gal Meirom, Istvan Haller, Kourosh Hakhamaneshi, Gavin Parnaby, Moein Khazraee, Omri Kahalon原标题:Large-Scale Sharded Weight Transfer with Ray Direct Transport (RDT) in vLLM
68AI 研判分

vLLM 推出基于 Ray Direct Transport (RDT) 的原生分片权重传输引擎,专门解决在线强化学习(RL)中大规模模型权重同步的瓶颈。该方案支持稠密、MoE 及量化模型,通过 API 简化框架接入,并创新性地重叠数据收集、传输与后处理步骤,显著降低内存占用并提升 Kimi K2 等超大模型的训练效率。

报道正文

本文目录6 个章节

Introduction

In online RL setups, model weights must be synced periodically to ensure that rollouts are generated from a recent weight version. As open source models continue to scale to trillion+ parameter counts, efficient weight transfer becomes important to bound memory consumption and transfer time.

In this blog, we detail a sharded weight transfer implementation in vLLM leveraging Ray Direct Transport (RDT). Our contributions are as follows:

  • A native sharded weight-transfer engine in vLLM that works across a range of models — dense, MoE with fused or per-expert checkpoints, and quantized, utilizing the native RL APIs in vLLM.
  • A simple API for RL frameworks to adopt, in which a framework can simply describe how its weights are laid out and the engine owns the entire transport.
  • An optimized implementation that overlaps preprocessing with transport, so that the gather, the transfer, and the post-processing overlap with each other.
  • A fault-tolerant rollout demonstration that illustrates the fault tolerance properties of RDT with NIXL.

We are able to achieve sharded weight transfer for the Kimi K2 model in BF16 in 7.53 seconds on 48 8xH100 nodes (32 nodes for the trainer, 16 for inference). The implementation is available in vLLM with an end-to-end example in SkyRL.

Overview: Broadcast-based weight transfer vs sharded weight transfer with RDT(NIXL backend). With NCCL, trainer rank 0 forms a collective communication group with all the inference ranks and transfers full weights via broadcast. With the sharded weight transfer engine, we utilize all trainer ranks in the transfer and further only send the shard that is needed. The transfer is further optimized to avoid gathering weights across PP ranks, and skips gathering expert layers.

Overview: Broadcast-based weight transfer vs sharded weight transfer with RDT(NIXL backend). With NCCL, trainer rank 0 forms a collective communication group with all the inference ranks and transfers full weights via broadcast. With the sharded weight transfer engine, we utilize all trainer ranks in the transfer and further only send the shard that is needed. The transfer is further optimized to avoid gathering weights across PP ranks, and skips gathering expert layers.

Background

The standard weight sync is a NCCL broadcast. The trainer all-gathers each parameter into the HuggingFace format and broadcasts it to every inference worker. For models at modest scale this is fine, but as models grow it has the following drawbacks:

  1. Every worker receives the whole model: Under TP8 a worker keeps ⅛ of each weight and discards the rest. This is worse for large MoE models like Kimi K2 (often deployed under wide-expert parallelism) where the full parameters per layer can still be quite large (10s of GBs), hurting peak memory as well as transfer speeds.
  2. A broadcast is a collective: NCCL requires synchronous participation from all ranks, which can be problematic in dynamic scenarios. At large scale, you can have straggler ranks that can stall the collective, or even replica failures.

While there’s previous work in large-scale sharded weight transfer (1, 2), our primary focus is generality on two axes:

  • Across models and layouts, being compatible with almost any model supported by vLLM.
  • Across RL frameworks, allowing other RL frameworks to adopt the optimized weight transfer implementation.

Weight loading in vLLM

The journey of a weight

When a new weight tensor in HuggingFace format arrives at a vLLM worker, it must undergo the following operations:

  1. Fuse: weight partitions are fused, for example Q, K and V tensors in the attention layer
  2. Relayout: Weights can be transposed or reshaped depending on the format of the original weights
  3. Split/select: The fused tensor can be chunked or a subset of parameters can be selected (e.g., expert parallelism)
  4. Shard: The weight can be sliced for tensor parallelism
  5. Copy Into Buffer: The weights are copied back into a buffer allocated per layer (“layerwise buffer”). These layerwise buffers are staging buffers allocated by vLLM during weight loading.
  6. Process: Weights are optionally quantized, with some kernel-specific operations like padding, striding, etc.
  7. Copy: The final processed weights are copied into already allocated GPU memory

Operations 1-5 happen in vLLM’s weight loader, via layerwise reloading. Layerwise reloading helps ensure that weight updates preserve CUDA graphs while keeping memory usage bounded.

Overview of operations in layerwise reloading (Source)

Ideally, during weight transfer, we transmit the final processed weights (after step 6.) from the trainer and write directly into the storage of the live weights. However, in order to support a wide range of post-processing operations in step 6, we focus on weight transfer of sharded but unprocessed weights in BF16 format (i.e., after step 4.) and let the engine handle the rest. This allows us to also support different quantization schemes with vLLM.

Custom weight loading behaviors

Moving steps 1-4 to the trainer means the trainer has to know, for every worker and every weight, which bytes that worker will end up keeping.

The obvious way to get that is to compute it: read the parallel configuration, work out which band of which tensor belongs to which rank, and send accordingly. However, the exact operations to be performed can vary depending on the layer as well as the model. Two examples are:

  1. QKV fusion under grouped-query attention: Three tensors (q_proj, k_proj, v_proj) are fused into one tensor. Under GQA, there can be fewer KV heads than TP ranks - so two workers can pull different Q tensors but identical K and V tensors. This is different from standard MHA models where the TP sharding is consistent for Q, K and V tensors.
  2. Llama-4's fused expert: In Llama-4, the expert tensor in HuggingFace format is transposed, split into gate_proj and up_proj, from which the vLLM worker’s experts are selected.

These two illustrate the diverse set of operations that a weight loader can have. With the various architectures that vLLM supports, implementing steps 1-4 on the trainer would involve bespoke operations per model and layer. The only way to avoid this is by recording the exact set of operations in steps 1-4 for the given configuration at runtime.

Solution: a “recording tensor” dry run

To support custom weight loading behaviors as above, our solution is as follows: at engine initialization, we hand vLLM's loaders a “recording tensor” - a tensor subclass that reports the correct shape and dtype but owns no data. Every transformation - view, narrow, transpose, reshape, etc - gets appended to a chain of operations. When the loader copies into a parameter, we record what it copied from and where it landed. We utilize this sequence of operations (a “sharding plan”) during weight sync to transform full tensors on the trainer to sharded tensors required by the vLLM worker.

Because the plan comes from vLLM's own loaders, it is correct by construction for whatever those loaders do across different layers and models.

Thus, we perform steps 1-4 on the trainer, and transfer sharded weights in BF16 format to each vLLM rank. After receiving the sharded weights, we perform the remaining steps 5-7 to update the live weights on each rank.