vllm.distributed.device_communicators.ray_communicator
RayPPCommunicator ¶
Bases: Communicator
Communicator to be used for pipeline parallelism in Ray Compiled Graph. This is wraps around the vLLM _PP GroupCoordinator.
This class is not thread-safe.
Source code in vllm/distributed/device_communicators/ray_communicator.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
__init__ ¶
__init__(
world_size: int,
comm_id: Any,
rank: Optional[int],
actor_handles: list[ActorHandle],
cuda_stream: Optional[Stream],
use_communication_streams: bool = False,
)
Initialize a RayPPCommunicator that can be used to communicate with other Ray Compiled Graph actors for pipeline parallelism.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
world_size | int | The number of participating actors. | required |
comm_id | Any | A unique communicator ID. This is just to conform with the Ray Communicator API and is not used. | required |
rank | Optional[int] | The rank of this actor. If None, then the caller is not a participant of the RayPPCommunicator group (e.g., the Ray driver). | required |
actor_handles | list[ActorHandle] | A list of actor handles. | required |
cuda_stream | Optional[Stream] | A CUDA stream to dispatch communication ops to. This is not supported. | required |
use_communication_streams | bool | Whether to use communication streams. This is not supported. | False |
Source code in vllm/distributed/device_communicators/ray_communicator.py
_build_actor_rank_mapping ¶
Use collective communication to build a mapping from actor IDs to ranks. This should be called once during initialization.
Source code in vllm/distributed/device_communicators/ray_communicator.py
allgather ¶
allreduce ¶
destroy ¶
get_rank ¶
get_rank(actor: ActorHandle) -> int
Return the given actor's rank using device communicator collective ops.
Source code in vllm/distributed/device_communicators/ray_communicator.py
get_self_rank ¶
recv ¶
Receive a torch.Tensor from a peer and synchronize the current stream.
After this call returns, the receive buffer is safe to read from from any stream. An RayChannelError will be raised if an error occurred (e.g., remote actor died), and the buffer is not safe to read.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape | tuple[int] | The shape of the tensor to receive. | required |
dtype | dtype | The dtype of the tensor to receive. | required |
peer_rank | int | The rank of the actor to receive from. | required |
allocator | TorchTensorAllocator | The allocator to use to create the received tensor. This is ignored for this implementation. | required |
Source code in vllm/distributed/device_communicators/ray_communicator.py
reducescatter ¶
send ¶
Send a torch.Tensor to a peer.
This returns when the send kernel has been queued, but the kernel may not have completed. Therefore, the caller should ensure that there are no concurrent writes to the sent buf
until the send has finished. That is, either all writes should be submitted on the current stream (self._cuda_stream) or, if on a different stream, that stream should synchronize with the current stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buf | Tensor | The torch.Tensor to send. It should already be on this actor's default device. | required |
peer_rank | int | The rank of the actor to send to. | required |