A mesh shape for hybrid (i.e., ICI and DCN) parallelism. For example, with mesh axes (data, model): - Pure fsdp on a v4-8: HybridMeshShape(ici_mesh_shape=(1, 4), dcn_mesh_shape=(1, 1)) - Two-way data parallelism over 2 H100 nodes, and fsdp within-node: HybridMeshShape(ic
| 93 | |
| 94 | @dataclasses.dataclass |
| 95 | class HybridMeshShape: |
| 96 | """A mesh shape for hybrid (i.e., ICI and DCN) parallelism. |
| 97 | |
| 98 | For example, with mesh axes (data, model): |
| 99 | - Pure fsdp on a v4-8: |
| 100 | HybridMeshShape(ici_mesh_shape=(1, 4), dcn_mesh_shape=(1, 1)) |
| 101 | - Two-way data parallelism over 2 H100 nodes, and fsdp within-node: |
| 102 | HybridMeshShape(ici_mesh_shape=(1, 8), dcn_mesh_shape=(2, 1)) |
| 103 | """ |
| 104 | |
| 105 | ici_mesh_shape: MeshShape |
| 106 | dcn_mesh_shape: MeshShape |
| 107 | |
| 108 | def __post_init__(self) -> None: |
| 109 | if len(self.ici_mesh_shape) != len(self.dcn_mesh_shape): |
| 110 | raise ValueError( |
| 111 | f"{self.ici_mesh_shape=} should have the same length as {self.dcn_mesh_shape}." |
| 112 | ) |
| 113 | |
| 114 | def __len__(self): |
| 115 | assert len(self.ici_mesh_shape) == len(self.dcn_mesh_shape) |
| 116 | return len(self.ici_mesh_shape) |
| 117 | |
| 118 | |
| 119 | # "device" = Accelerator memory, e.g. HBM. |
no outgoing calls