How to validate in DistributedDataParallel correctly?

Do you mean how you would go about performing a validation pass using all ranks?

Your validation loop will operate very similar to your training loop where each rank will operate on a subset of the validation dataset. The only difference is that you will want to keep track of the validation metrics you care about and then share the results using the methods in the link I gave.

Sometimes its quicker to just let the main rank perform validation depending on the specific task.