ezpz.tp.__init__
¶
ezpz/tp/init.py
modified from: https://github.com/facebookresearch/fairscale/blob/5f484b3545f27eddb19d970fbe1d361b9c5f2b07/fairscale/nn/tensor_parallel/initialize.py
destroy_tensor_parallel()
¶
Set the groups to none.
Source code in src/ezpz/tp/__init__.py
divide_and_check_no_remainder(numerator, denominator)
¶
Divide the numerator by the denominator and check that there is no remainder.
ensure_divisibility(numerator, denominator)
¶
Ensure that numerator is divisible by the denominator.
get_context_parallel_group()
¶
Get the context parallel group the caller rank belongs to.
Source code in src/ezpz/tp/__init__.py
get_context_parallel_rank()
¶
get_context_parallel_ranks()
¶
Return context parallel ranks for the context parallel group.
Source code in src/ezpz/tp/__init__.py
get_context_parallel_world_size()
¶
get_data_parallel_group()
¶
Get the data parallel group the caller rank belongs to.
get_data_parallel_rank()
¶
get_data_parallel_ranks()
¶
Get the data parallel group the caller rank belongs to.
get_data_parallel_world_size()
¶
get_pipeline_parallel_group()
¶
Get the pipeline parallel group the caller rank belongs to.
Source code in src/ezpz/tp/__init__.py
get_pipeline_parallel_rank()
¶
get_pipeline_parallel_ranks()
¶
Get the pipeline parallel group the caller rank belongs to.
Source code in src/ezpz/tp/__init__.py
get_pipeline_parallel_world_size()
¶
get_tensor_parallel_group()
¶
Get the tensor parallel group the caller rank belongs to.
Source code in src/ezpz/tp/__init__.py
get_tensor_parallel_rank()
¶
get_tensor_parallel_ranks()
¶
Get the tensor parallel group the caller rank belongs to.
get_tensor_parallel_src_rank()
¶
Calculate the global rank corresponding to local rank 0 in the TP group.
Source code in src/ezpz/tp/__init__.py
get_tensor_parallel_world_size()
¶
initialize_tensor_parallel(tensor_parallel_size=1, pipeline_parallel_size=1, context_parallel_size=1, tensor_parallel_backend=None, pipeline_parallel_backend=None, context_parallel_backend=None, data_parallel_backend=None, timeout=None)
¶
Initialize tensor data parallel groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor_parallel_size
|
int
|
number of GPUs used to parallelize model. |
1
|
Let's say we have a total of 8 GPUs denoted by g0 ... g7 and we use 2 GPUs to parallelize the model. The present function will create 4 tensor parallel groups and 2 data parallel groups as:
- 4 tensor parallel groups:
-
2 data parallel groups:
Note that for efficiency, the caller should make sure adjacent ranks are on the same DGX box. For example if we are using 2 DGX-1 boxes with a total of 16 GPUs, rank 0 to 7 belong to the first box and ranks 8 to 15 belong to the second box.
process groups initialized in the order of TP, CP, PP, DP.
Let's say we have a total of 16 GPUs denoted by g0 ... g15 and we use 2 GPUs to parallelize the tensor tensor, 2 GPUs to parallelize context(seq len), and 2 GPUs to parallelize the tensor pipeline. The present function will create 8 tensor model-parallel groups, 8 context-parallel group, 8 pipeline model-parallel groups and 8 data-parallel groups as: when alternate_pp_config = False,
- 8 data_parallel groups: [g0, g4], [g1, g5], [g2, g6], [g3, g7], [g8, g12], [g9, g13], [g10, g14], [g11, g15]
- 8 tensor model-parallel groups: [g0, g1], [g2, g3], [g4, g5], [g6, g7], [g8, g9], [g10, g11], [g12, g13], [g14, g15]
- 8 context-parallel groups: [g0, g2], [g1, g3], [g4, g6], [g5, g7], [g8, g10], [g9, g11], [g12, g14], [g13, g15]
- 8 pipeline model-parallel groups: [g0, g8], [g1, g9], [g2, g10], [g3, g11], [g4, g12], [g5, g13], [g6, g16], [g7, g15]
Source code in src/ezpz/tp/__init__.py
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 |
|
split_tensor_along_last_dim(tensor, num_partitions, contiguous_split_chunks=False)
¶
Split a tensor along its last dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor
|
Tensor
|
The tensor to split. |
required |
num_partitions
|
int
|
The number of partitions to split the tensor into. |
required |
contiguous_split_chunks
|
bool
|
Whether to return contiguous split chunks. |
False
|
Source code in src/ezpz/tp/utils.py
tensor_parallel_is_initialized()
¶
Check if tensor and data parallel groups are initialized.