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 Replicated Sqrt operation #1051

Merged
merged 6 commits into from
Apr 19, 2022
Merged

Add Replicated Sqrt operation #1051

merged 6 commits into from
Apr 19, 2022

Conversation

yanndupis
Copy link
Member

@yanndupis yanndupis commented Apr 14, 2022

One more for the road. When working on a PyMoose example, I realized that sqrt was missing to compute pearson correlation. So here it is.

  • Add replicated sqrt. We compute the square root using log2 and pow2. There are other algorithm which could much more efficient but it should be good enough for the initial implementation.
  • Add sqrt to logical dialect.
  • Add sqrt to the edsl.

@yanndupis yanndupis requested a review from mortendahl April 14, 2022 23:58
Copy link
Contributor

@rdragos rdragos left a comment

Choose a reason for hiding this comment

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

This looks good to me, Yann! One small request, could you test a bit the bounds that this sqrt function provides accurate results? This way we would know how to calibrate the magnitude of our inputs when we operate with sqrt

@kkloberdanz
Copy link
Contributor

kkloberdanz commented Apr 19, 2022

Looks good! Perhaps a small proof in the comments would help a future reader?

2^(0.5 * log_2 x) = (2^log_2 x)^0.5 = x^0.5 = sqrt(x)

@rdragos
Copy link
Contributor

rdragos commented Apr 19, 2022

We should add a followup issue to implement the square root as we've described in our whitepaper.

@yanndupis
Copy link
Member Author

Thank you both for the review.

@rdragos good question. I checked the bounds. With 10 fractional precision, we get accurate result for [0.001, 1000] with error threshold set to 0.1 and for 20 fractional precision we get accurate result [0.01, 500000] for error threshold set to 0.001.

Sounds good, I will open a follow up issue to implement sqrt as described in the whitepaper.

Thanks

@yanndupis
Copy link
Member Author

#1058

@yanndupis yanndupis merged commit c74b87e into main Apr 19, 2022
@yanndupis yanndupis deleted the rep-sqrt-op branch April 19, 2022 23:51
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.

3 participants