Skip to content
Discussion options

You must be logged in to vote

Hey @konrad-karanowski, this deadlock happens because all_gather_object is a collective — all ranks must call it, even if they have no data.

Use Lightning's strategy.all_gather instead. It's safer and handles the empty-rank case:

def on_validation_epoch_end(self, trainer: Trainer, pl_module: LightningModule) -> None:
if not self._should_run(trainer):
return

# Gather across all ranks
local_preds = self._predictions
gathered = trainer.strategy.all_gather(local_preds) # List[dict] from all ranks

if not trainer.is_global_zero:
    return
    
# Merge on rank 0 only
merged = {}
for rank_dict in gathered:
    for img_id, blocks in rank_dict.items():
        merged.setdefault(img_id, {}).update…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@konrad-karanowski
Comment options

Answer selected by konrad-karanowski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants