Skip to content

Commit e6b0f97

Browse files
haozhx23haozhx23mreso
authored
Fix hsdp_device_mesh=None when enable HSDP and HYBRID_SHARD (meta-llama#402)
Co-authored-by: haozhx23 <[email protected]> Co-authored-by: Matthias Reso <[email protected]>
1 parent 4e1466c commit e6b0f97

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/llama_recipes/finetuning.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ def main(**kwargs):
163163
wandb_run.config.update(peft_config)
164164
model.print_trainable_parameters()
165165

166-
167-
hsdp_device_mesh = None
166+
hsdp_device_mesh_plan = None
168167
if fsdp_config.hsdp and fsdp_config.sharding_strategy == ShardingStrategy.HYBRID_SHARD:
169-
hsdp_device_mesh = hsdp_device_mesh(replica_group_size=fsdp_config.replica_group_size, sharding_group_size=fsdp_config.sharding_group_size)
168+
hsdp_device_mesh_plan = hsdp_device_mesh(replica_group_size=fsdp_config.replica_group_size, sharding_group_size=fsdp_config.sharding_group_size)
170169
print("HSDP device mesh is ready")
171170

172171
#setting up FSDP if enable_fsdp is enabled
@@ -189,7 +188,7 @@ def main(**kwargs):
189188
cpu_offload=CPUOffload(offload_params=True) if fsdp_config.fsdp_cpu_offload else None,
190189
mixed_precision=mixed_precision_policy if not fsdp_config.pure_bf16 else None,
191190
sharding_strategy=fsdp_config.sharding_strategy,
192-
device_mesh=hsdp_device_mesh,
191+
device_mesh=hsdp_device_mesh_plan,
193192
device_id=device_id,
194193
limit_all_gathers=True,
195194
sync_module_states=train_config.low_cpu_fsdp,

0 commit comments

Comments
 (0)