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

Add shifted data algorithm for variance computation to OnePassMeanVarStd #154

Merged
merged 3 commits into from
Apr 11, 2024

Conversation

ordabayevy
Copy link
Contributor

Addresses #113

@ordabayevy ordabayevy linked an issue Mar 27, 2024 that may be closed by this pull request
self.x_squared_sums = self.x_squared_sums + (x_ng**2).sum(dim=0)
self.x_size = self.x_size + x_ng.shape[0]
elif self.algorithm == "shifted_data":
if self.x_shift is None:
Copy link
Member

Choose a reason for hiding this comment

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

So... you get shift from the very first minibatch? I think it is an improvement over naive, but doesn't really close the issue ;-) we should implement Welford's online algorithm for that: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have worked on that initially but then it turned out to be that it is either unstable or hard to implement merging results from multiple GPUs. Can't remember which one it was 🙃

@ordabayevy ordabayevy merged commit 3e7739b into main Apr 11, 2024
5 checks passed
@ordabayevy ordabayevy deleted the onepass2 branch April 11, 2024 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix floating point overflow issues in OnePassMeanVarStd
2 participants