arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.16709cs.MS
收藏

低精度Fortran——在现代Fortran中启用低精度浮点运算

Low Precision Fortran -- Enabling Low Precision Floating Point Arithmetic in Modern Fortran

Max Planck Institute for Dynamics of Complex Technical Systems(马克斯·普朗克复杂技术系统动力学研究所)

Martin Köhler, Peter Benner

AI总结:

针对Fortran缺乏低精度浮点类型支持的问题,提出LPF库,将binary16、bfloat16等类型无缝集成到Fortran中,并扩展低精度BLAS操作,便于利用加速器高性能。

摘要:

尽管Fortran已有近70年历史,该语言仍在不断发展以跟上计算机科学的进步。特别是,引入了一个灵活的类型系统,允许开发者指定浮点数和整数的大小。在Fortran标准的最新修订版中,增加了IEEE 754 binary64(双精度,real64)和binary32(单精度,real32)的可移植类型变体。然而,AI工具包和加速器硬件的快速发展使得人们高度关注比binary32更低精度和更低内存占用的浮点类型。虽然IEEE 754-2019标准定义了表示半精度数的binary16类型,但Fortran标准并未在类型系统中提供real16变体。相比之下,大多数C编译器支持这种数据类型。在数值线性代数中,人们强烈希望利用加速器设备的高性能来执行核心算法,如矩阵分解或迭代求解器。特别是当双精度、单精度和半精度之间的性能比约为1:2:20(如当前NVidia H100加速器)时,使用低精度类型变得非常有益。然而,在追求性能之前,必须验证低于单精度运算的正确性和准确性。在本文中,我们介绍了低精度Fortran(LPF)库,该库使得低精度类型——binary16、bfloat16、fp8_e4m3和fp8_e5m2——能够像Fortran中的任何其他浮点类型一样使用。此外,我们引入了支持低精度BLAS操作的扩展,并展示了如何轻松地将现有例程重写为使用这些数据类型。

英文摘要:

Although Fortran is almost 70 years old, the language continues to evolve in order to keep pace with developments in computer science. In particular, a flexible type system was introduced that allows developers to specify the sizes of floating-point numbers and integers. In the latest revisions of the Fortran standard, portable type variants for IEEE 754 binary64 (double precision, real64) and binary32 (single precision, real32) were added. However, the rapid development of AI toolkits and accelerator hardware has created a strong focus on floating-point types of lower precision and lower memory usage than binary32. While the IEEE 754-2019 standard defines the binary16 type for representing half-precision numbers, the Fortran standard does not provide the real16 variant in the type system. In contrast, most C compilers support such a data type. In numerical linear algebra, there is strong interest in exploiting the high performance of accelerator devices for core algorithms like matrix decompositions or iterative solvers. Especially when the performance ratio between double, single, and half precision is on the order of 1:2:20, as on current NVidia H100 accelerators, it becomes highly beneficial to use lower-precision types. Yet, before performance can be targeted, correctness and accuracy must be verified when operating below single precision. In this article, we present our Low Precision Fortran (LPF) library that enables the use of low-precision types -- binary16, bfloat16, fp8_e4m3, and fp8_e5m2 -- just like any other floating-point type in Fortran. Furthermore, we introduce extensions that support BLAS operations in low precision and show how easily existing routines can be rewritten to use these data types.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑