Herbie 2.1 Release Notes

The Herbie developers are excited to announce Herbie 2.1! This release focuses performance, both in the generated code and in the Herbie kernel itself.

What is Herbie? Herbie automatically improves the accuracy of floating point expressions. This avoids the bugs, errors, and surprises that so often occur with floating point arithmetic. Visit the main page to learn more about Herbie.

OOPSLA, ASPLOS, and POPL Reviewers, please do not read further, because some of the work described below is submitted for publication to these venues.

The Herbie 2.1 team at UW and U of U

Faster Generated Code

A comparison of speed-accuracy curves for Herbie 2.0 and
         2.1, showing much faster low-accuracy code in Herbie 2.1.
Herbie 2.0 (green) and 2.1 (blue) speed-accuracy curves on the Hamming test suite, showing that Herbie 2.1 generates much faster code, especially at low accuracy levels. The impact is due to both typed extraction (described on the plot as egg-serialize) and the cost opportunity heuristic (described on the plot as cost localization). The orange curve shows that both components are necessary to achieve the best results.

Last year, Herbie 2.0 released pareto mode, in which Herbie generates multiple expressions with different speeds and accuracies. Herbie 2.1 now makes Herbie's generated code, especially at the highest-performance/lowest-accuracy level, dramatically better. Some features that contribute to these improvements:

While Herbie's generated results are much better, these changes alone would make Herbie more than twice as slow. This leads to the second category of changes.

Faster Herbie Kernel

Iteration 0Iteration 1Iteration 2
OperationPrecisionTime (µs)PrecisionTime (µs)PrecisionTime (µs)
Tuning22.921.0
cos7875.959298.91695173.1
add8311.0210710.0269811.0
cos788.159399.11695176.0
sub7310.07310.07311.0
Total105.0241.0392.1
A precision-tuned execution of cos(x) - cos(x + ɛ) when x = 10300 and ɛ = 10-300. Each row of the table represents one mathematical operation (or the time spent precision-tuning), and each pair of columns describes one iteration precision and execution time for that operation. Each operation's precision is chosen independently, so the precision column is not uniform.

Nearly every part of Herbie has been sped up, often significantly, meaning that Herbie 2.1 overall—despite the much faster generated code—is only 20% or so slower than Herbie 2.0.

The most challenging improvement is a complete rewrite of Herbie's real evaluation system, Rival. Herbie 2.1 uses precision tuning to reduce the time and memory costs by approximately 40%, with the biggest impacts to the largest and slowest expressions. Moreover, Rival has been packaged for use in other projects.

Other optimizations to Herbie include:

New Features: Platforms and Explanations

(define-accelerator (sind real) real
  (λ (x) (sin (* x (/ (PI) 180)))))
(define-accelerator (cosd real) real
  (λ (x) (cos (* x (/ (PI) 180)))))
(define-accelerator (tand real) real
  (λ (x) (tan (* x (/ (PI) 180)))))
A snippet from the Herbie "platform" for the Julia language, describing special library functions cosd, sind, and tand, which Julia provides. When using this platform, Herbie will use these functions in its generated code.

Two new features are in development and available in an undocumented alpha state in this release: platforms and explanations.

Platforms allow Herbie to generate code specific to a given programming language, library, or hardware platform. Herbie can use platform-specific operators, cost models, and compilation styles, which leads to faster and more accurate code. We hope to clean up the platforms code and release it for real in Herbie 2.2.

Explanations describe what floating-point errors Herbie found and what inputs they occur for. This should make Herbie easier to understand and a more valuable tool for learning about floating-point error.

Sister Projects

The Odyssey numerics workbench is releasing version 1.1 today, featuring FPTaylor support and expression export. Odyssey and supporting tools like Herbie and FPTaylor can be installed and run locally through the Odyssey VSCode extension. New features include:

The Rival real-arithmetic package is releasing version 2.0 today, featuring the correct-rounding code from Herbie (#804), including the new precision tuning algorithm and a newly-build profiling system.

Development Improvements

Other improvements

Try it out!

We want Herbie to be more useful to scientists, engineers, and programmers around the world. We've got a lot of features we're excited to work on in the coming months. Please report bugs or contribute.


If you find Herbie useful, let us know!