torchfoo.distributed.rank_zero_only#

torchfoo.distributed.rank_zero_only(func)[source]#

Decorator that ensures a function only executes on rank 0.

On all other ranks, the function returns None.

Parameters:

func – a function to wrap

Returns:

Wrapped function that is a no-op on non-zero ranks.