Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all gather while writing to a file during T5 finetuning #5561

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def inference_epoch_end(self, outputs, mode, data_cfg):
)

# Gather the outputs object from all data parallel ranks since we are using the DistributedSampler which splits data across DDP ranks.
gathered_outputs = [None for _ in range(self.world_size)]
gathered_outputs = [None for _ in range(parallel_state.get_data_parallel_world_size())]
torch.distributed.all_gather_object(
gathered_outputs,
[
Expand All @@ -439,6 +439,7 @@ def inference_epoch_end(self, outputs, mode, data_cfg):
}
for x in output
],
group=parallel_state.get_data_parallel_group(),
)

# Figure out what the suffix of the file should be.
Expand All @@ -455,7 +456,7 @@ def inference_epoch_end(self, outputs, mode, data_cfg):

# PTL models have a self.global_rank attribute and we want to write to disk only on global rank 0.
if self.global_rank == 0:
for rank in range(0, self.world_size):
for rank in range(0, parallel_state.get_data_parallel_world_size()):
for batch in gathered_outputs[rank]:
for pred, label, input, category in zip(
batch['preds'], batch['labels'], batch['inputs'], batch['categories']
Expand Down