@@ -201,10 +201,10 @@ class MultiheadAttention(torch.nn.Module):
201201 parameters and if the DTensor DeviceMesh includes dimensions that do not
202202 shard weights, such as in the case of HSDP (DP-Replicate x DP-Shard).
203203 For example:
204- - device_mesh["dp"] for FSDP.
205- - device_mesh["dp_cp"] if using CP ranks in FSDP.
206- - device_mesh["tp"] if using TP.
207- - device_mesh["dp_cp_tp"] if strided-sharding with FSDP-TP.
204+ - device_mesh["dp"] for FSDP.
205+ - device_mesh["dp_cp"] if using CP ranks in FSDP.
206+ - device_mesh["tp"] if using TP.
207+ - device_mesh["dp_cp_tp"] if strided-sharding with FSDP-TP.
208208
209209 Optimization parameters
210210 -----------------------
@@ -648,12 +648,9 @@ def set_device_mesh(
648648 """
649649 if tp_mesh is not None :
650650 # Validate TP DeviceMesh / Group. Must be consistent with tp_size.
651- assert (
652- tp_mesh .ndim == 1 and self .tp_size == tp_mesh .size (),
653- (
654- f"TransformerEngine { self .__class__ .__name__ } TP init size ({ self .tp_size } ) "
655- f"does not match the size of the provided TP DeviceMesh ({ tp_mesh .size ()} )."
656- ),
651+ assert tp_mesh .ndim == 1 and self .tp_size == tp_mesh .size (), (
652+ f"TransformerEngine { self .__class__ .__name__ } TP init size ({ self .tp_size } ) "
653+ f"does not match the size of the provided TP DeviceMesh ({ tp_mesh .size ()} )."
657654 )
658655 # Set the tensor parallel group from the mesh.
659656 self .set_tensor_parallel_group (tp_mesh .get_group ())
@@ -662,7 +659,7 @@ def set_device_mesh(
662659 # Iterate through child sub-modules without deep recursion.
663660 # Automatically detects TransformerEngine TP modules and
664661 # the capability to call this method at any level.
665- for name , child in self .named_children ():
662+ for child in self .children ():
666663 if hasattr (child , "set_device_mesh" ):
667664 child .set_device_mesh (tp_mesh , weight_mesh )
668665
0 commit comments