|
9 | 9 |
|
10 | 10 | import torch |
11 | 11 | import torch.nn as nn |
12 | | -from torch.distributed._composable.replicate import replicate |
| 12 | +from torch.distributed._composable.replicate_with_fsdp import replicate |
13 | 13 |
|
14 | 14 | from torch.distributed.device_mesh import DeviceMesh |
15 | 15 | from torch.distributed.fsdp import CPUOffloadPolicy, fully_shard, MixedPrecisionPolicy |
@@ -135,11 +135,13 @@ def parallelize_llama( |
135 | 135 | if job_config.training.enable_cpu_offload: |
136 | 136 | logger.info("Applied CPU Offloading to the model") |
137 | 137 | elif parallel_dims.dp_replicate_enabled: |
138 | | - if world_mesh.ndim > 1: |
139 | | - raise RuntimeError("DDP has not supported > 1D parallelism") |
| 138 | + # if world_mesh.ndim > 1: |
| 139 | + # raise RuntimeError("DDP has not supported > 1D parallelism") |
| 140 | + |
| 141 | + dp_mesh_dim_names = ("dp_replicate", "dp_shard") |
140 | 142 | apply_ddp( |
141 | 143 | model, |
142 | | - world_mesh, |
| 144 | + world_mesh[tuple(dp_mesh_dim_names)], |
143 | 145 | enable_compile=model_compile_enabled, |
144 | 146 | enable_compiled_autograd=job_config.parallelism.enable_compiled_autograd, |
145 | 147 | ) |
@@ -328,6 +330,6 @@ def apply_ddp( |
328 | 330 | else: |
329 | 331 | torch._dynamo.config.optimize_ddp = "ddp_optimizer" |
330 | 332 |
|
331 | | - replicate(model, device_mesh=dp_mesh, bucket_cap_mb=100) |
| 333 | + replicate(model, device_mesh=dp_mesh) |
332 | 334 |
|
333 | 335 | logger.info("Applied DDP to the model") |
0 commit comments