MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / VLLMWeightTransferEngine

Class VLLMWeightTransferEngine

trinity/utils/distributed.py:136–170  ·  view source on GitHub ↗

A helper class to manage NCCL weight synchronization using vLLM's API.

Source from the content-addressed store, hash-verified

134
135
136class VLLMWeightTransferEngine(WeightTransferEngine):
137 """A helper class to manage NCCL weight synchronization using vLLM's API."""
138
139 def __init__(self, master_address: str, master_port: int, world_size: int, group_name: str):
140 """Initialize the NCCL process group for weight sync with vLLM's API."""
141 from vllm.distributed.weight_transfer.nccl_engine import (
142 NCCLWeightTransferEngine,
143 )
144
145 del group_name # vLLM's NCCL engine does not require a group name
146 self._model_update_group = NCCLWeightTransferEngine.trainer_init(
147 dict(
148 master_address=master_address,
149 master_port=master_port,
150 world_size=world_size,
151 )
152 )
153
154 def sync_weight(self, iterator):
155 """Perform the NCCL weight sync using vLLM's API."""
156 from vllm.distributed.weight_transfer.nccl_engine import (
157 NCCLTrainerSendWeightsArgs,
158 NCCLWeightTransferEngine,
159 )
160
161 NCCLWeightTransferEngine.trainer_send_weights(
162 iterator=iterator,
163 trainer_args=NCCLTrainerSendWeightsArgs(
164 group=self._model_update_group,
165 packed=True,
166 ),
167 )
168
169 def teardown(self):
170 self._model_update_group.destroy()
171
172
173class SGLangWeightTransferEngine(WeightTransferEngine):

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected