Computers calculate transcendental functions by approximating them through the composition of a few limited-precision instructions. For example, an exponential can be calculated with a Taylor series. These approximation methods were developed over the centuries by mathematicians, who emphasized the attainability of arbitrary precision. Computers, however, operate on few limited precision types, such as the popular float32. In this study, we show that when aiming for limited precision, existing approximation methods can be outperformed by programs automatically discovered from scratch by a simple evolutionary algorithm. In particular, over real numbers, our method can approximate the exponential function reaching orders of magnitude more precision for a given number of operations when compared to previous approaches. More practically, over float32 numbers and constrained to less than 1 ULP of error, the same method attains a speedup over baselines by generating code that triggers better XLA/LLVM compilation paths. In other words, in both cases, evolution searched a vast space of possible programs, without knowledge of mathematics, to discover previously unknown optimized approximations to high precision, for the first time. We also give evidence that these results extend beyond the exponential. The ubiquity of transcendental functions suggests that our method has the potential to reduce the cost of scientific computing applications.
翻译:计算机通过组合少量有限精度指令来逼近计算超越函数。例如,指数函数可通过泰勒级数计算。这些逼近方法由数学家历经数百年发展而来,强调任意精度的可实现性。然而,计算机仅使用少数有限精度类型(如流行的float32)运行。本研究表明,当目标为有限精度时,通过简单进化算法从零开始自动发现的程序可超越现有逼近方法。具体而言,在实数域上,我们的方法能在给定运算次数下以数量级更高的精度逼近指数函数。更实际的应用是,在float32数值上且在误差小于1 ULP的约束下,相同方法通过生成触发更优XLA/LLVM编译路径的代码,实现了对基线的加速。换言之,在这两种情况下,进化算法无需数学知识即可在庞大的程序空间中搜索,首次发现了此前未知的高精度优化逼近方法。我们同时给出证据表明,这些结果可推广至指数函数之外。超越函数的普遍性意味着我们的方法有望降低科学计算应用的成本。