Note

Check the version number of this documentation against the gfloat version you are using. “Latest” refers to the head on https://github.com/graphcore-research/gfloat, while pypi versions installed using pip install will have corresponding vX.Y.Z tags.

GFloat: Generic floating point formats in Python

GFloat is designed to allow experimentation with a variety of floating-point formats in Python. Formats are parameterized by the primary IEEE-754 parameters of:

  • Width in bits (k)

  • Precision (p)

  • Maximum exponent (emax)

with additional fields defining the encoding of infinities, Not-a-number (NaN) values, and negative zero, among others (see gfloat.FormatInfo.)

This allows an implementation of generic floating point encode/decode logic, handling various current and proposed floating point types:

The library favours readability and extensibility over speed - for fast implementations of these datatypes see, for example, ml_dtypes, bitstring, MX PyTorch Emulation Library.

To get started with the library, we recommend perusing the notebooks, otherwise you may wish to jump straight into the API.