vllm.distributed.weight_transfer.packed_tensor ¶
Packed tensor utilities for efficient weight transfer.
DEFAULT_PACKED_BUFFER_SIZE_BYTES module-attribute ¶
packed_broadcast_consumer ¶
packed_broadcast_consumer(
iterator: Iterator[tuple[str, tuple[list[int], dtype]]],
group: Any,
src: int,
post_unpack_func: Callable[
[list[tuple[str, Tensor]]], None
],
buffer_size_bytes: int = DEFAULT_PACKED_BUFFER_SIZE_BYTES,
num_buffers: int = DEFAULT_PACKED_NUM_BUFFERS,
) -> None
Consume packed tensors and unpack them into a list of tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterator | Iterator[tuple[str, tuple[list[int], dtype]]] | Iterator of parameter metadata. Returns (name, (shape, dtype)) | required |
group | Any | Process group (PyNcclCommunicator) | required |
src | int | Source rank (0 in current implementation) | required |
post_unpack_func | Callable[[list[tuple[str, Tensor]]], None] | Function to apply to each list of (name, tensor) after unpacking | required |
buffer_size_bytes | int | Size in bytes for each packed tensor buffer. Both producer and consumer must use the same value. | DEFAULT_PACKED_BUFFER_SIZE_BYTES |
num_buffers | int | Number of buffers for double/triple buffering. Both producer and consumer must use the same value. | DEFAULT_PACKED_NUM_BUFFERS |
Source code in vllm/distributed/weight_transfer/packed_tensor.py
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 | |
packed_broadcast_producer ¶
packed_broadcast_producer(
iterator: Iterator[tuple[str, Tensor]],
group: Any,
src: int,
post_iter_func: Callable[[tuple[str, Tensor]], Tensor],
buffer_size_bytes: int = DEFAULT_PACKED_BUFFER_SIZE_BYTES,
num_buffers: int = DEFAULT_PACKED_NUM_BUFFERS,
) -> None
Broadcast tensors in a packed manner from trainer to workers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterator | Iterator[tuple[str, Tensor]] | Iterator of model parameters. Returns a tuple of (name, tensor) | required |
group | Any | Process group (PyNcclCommunicator) | required |
src | int | Source rank (0 in current implementation) | required |
post_iter_func | Callable[[tuple[str, Tensor]], Tensor] | Function to apply to each (name, tensor) pair before packing, should return a tensor | required |
buffer_size_bytes | int | Size in bytes for each packed tensor buffer. Both producer and consumer must use the same value. | DEFAULT_PACKED_BUFFER_SIZE_BYTES |
num_buffers | int | Number of buffers for double/triple buffering. Both producer and consumer must use the same value. | DEFAULT_PACKED_NUM_BUFFERS |