Skip to content

Commit 0acaeeb

Browse files
committed
Adding data sharding
1 parent 2e8a893 commit 0acaeeb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/maxdiffusion/models/wan/autoencoder_kl_wan.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def __call__(self, x: jax.Array, cache_x: Optional[jax.Array] = None, idx=-1) ->
136136

137137
if self.mesh is not None:
138138
# (B, D, H, W, C)
139-
x_padded = with_sharding_constraint(x_padded, PartitionSpec('data', None, None, 'fsdp', None))
139+
if x_padded.shape[0] % self.mesh.shape['data'] == 0:
140+
x_padded = with_sharding_constraint(x_padded, PartitionSpec('data', None, None, 'fsdp', None))
141+
else:
142+
x_padded = with_sharding_constraint(x_padded, PartitionSpec(None, None, None, 'fsdp', None))
140143

141144
out = self.conv(x_padded)
142145
return out

0 commit comments

Comments
 (0)