Local Taylor covers at 0, -inf, +inf - #1633
Open
obround wants to merge 16 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Herbie samples uniformly over floating-point numbers, which means that on many benchmarks, a large fraction of sampled points are "extremely close to zero" or "extremely close to the infinities" (i.e., "oversampling"). This results in Herbie "overfitting" candidates to perform better very close to 0, -inf, +inf rather than on ranges people tend to spend more time thinking about. Additionally, for many functions, one term of its Taylor series is accurate enough to be within 1 ULP for certain intervals near 0, -inf, +inf.
This PR adds Taylor covers for univariate scalar functions at 0, -inf, +inf. Provided$f(x) \approx a_0 x^{k_0} + a_1 x^{k_1}$ , we can use the interval below to say that $a_0 x^{k_0}$ is a good approximation near $0$ .
At the infinities, expand using$1/x$ or $-1/x$ . This is not rigorous, but in practice (on Herbie benchmarks), it tends to always be safe and match the sound Lagrange bound.
Once an interval is determined, covered regions are removed from the search sample, allowing Herbie to spend more effort finding improvements in the harder middle of the input range. Final test accuracy is still measured across the full domain (since this is not a sound bound, I figured it wouldn't be appropriate to affect the test set).
Checks each cover against the original expression before using it, and keeps both covered and uncovered results so harmful or unnecessarily expensive covers can be rejected. This allows the Pareto curve to not lose its tail (more on this below).
Main: https://nightly.cs.washington.edu/reports/herbie/1785132595:main:f8cc7197/
Taylor covers: https://nightly.cs.washington.edu/reports/herbie/1785133546:taylor-near-zero:204f87bd/
Adding up all the changes on the nightly runs of
mainandtaylor-near-zero, we get a +82.8% improvement.Some interesting findings:
mainhad a useful alternative within 1 bit of the best result. To preserve that, we preserve the uncovered alternative in addition to the covered one.maintotaylor-near-zero. Still, doesn't seem like increasing the Taylor order limit past 2 is worthwhile.history.rktclosely related to this branch (so it's addressed here); I'll open a separate issue for that.