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 aggregate microbatches bug #711

Merged
merged 4 commits into from
Aug 1, 2023
Merged

Conversation

BulatVakhitov
Copy link
Contributor

chunked_output[0].size != 1 always true when passing torch.Tensor(size is a method). Changed it to get_size() function. Also the np.mean function falls, when passing torch tensors with device cuda, so I added .item() to all elements of chunked_output.

This reverts commit 1e08f77.
@@ -1551,7 +1551,7 @@ def aggregate_microbatches(self, outputs, chunked_outputs, chunk_sizes, single_o
for chunk_output, chunk_size in zip(chunked_output, chunk_sizes)], dim=0)
result.append(output_)
else:
result.append(np.mean(chunked_output))
result.append(np.mean([chunk_output.item() for chunk_output in chunked_output]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way we get here (in this method) an instance of torch.Tensor is when the data was explicitly left on device by setting transfer_from_device=False. It is rather strange to return a np.scalar, which is on CPU, in that case

@SergeyTsimfer SergeyTsimfer merged commit d21e528 into master Aug 1, 2023
19 checks passed
@SergeyTsimfer SergeyTsimfer deleted the fix-aggregate-microbatches-bug branch August 1, 2023 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants