Skip to content

Commit 100892f

Browse files
committed
fix(scripts): single-device sharding for compute_norm_stats torch path
Salvage of #438 by @tlpss — rebased to main. Size-1 batches cannot shard across multi-GPU meshes; pin SingleDeviceSharding for norm-stats collection convenience.
1 parent 15a9616 commit 100892f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

scripts/compute_norm_stats.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import openpi.training.config as _config
1515
import openpi.training.data_loader as _data_loader
1616
import openpi.transforms as transforms
17+
import jax
1718

1819

1920
class RemoveStrings(transforms.DataTransformFn):
@@ -47,9 +48,12 @@ def create_torch_dataloader(
4748
else:
4849
num_batches = len(dataset) // batch_size
4950
shuffle = False
51+
# Single-device sharding: batch size is often 1 for stats; multi-GPU default
52+
# mesh sharding cannot split size-1 batches (see openpi#438).
5053
data_loader = _data_loader.TorchDataLoader(
5154
dataset,
5255
local_batch_size=batch_size,
56+
sharding=jax.sharding.SingleDeviceSharding(jax.devices()[0]),
5357
num_workers=num_workers,
5458
shuffle=shuffle,
5559
num_batches=num_batches,

0 commit comments

Comments
 (0)