This is an archive of the discontinued LLVM Phabricator instance.

Add two additional float8 types to MLIR and APFloat.
AbandonedPublic

Authored by jakeh-gc on Jan 10 2023, 2:02 PM.

Details

Summary

Graphcore, AMD, and Qualcomm have proposed two new FP8 formats, Float8E4M3FZN and Float8E5M2FZN. These formats are presented in this paper: https://arxiv.org/abs/2206.02915. They are implemented in commercially available hardware and the ISA for this hardware is available here: https://docs.graphcore.ai/projects/isa-mk2-with-fp8/en/latest/_static/TileVertexISA-IPU21-1.3.1.pdf.

This patch adds support for these two types in MLIR and APFloat, alongside the previously added types Float8E4M3FN and Float8E5M2 (D133823, D137760, RFC).

Following the naming scheme from those existing types, the suffix "FZN" here refers to the fact that these types support finite values, positive-only zero (no negative zero), and a NaN encoding. In both types NaN has exactly one encoding 0b10000000.

To support this behaviour I have added another value to the fltNonfiniteBehavior enum to represent this specific NaN encoding. I have also added a new field (fltSignedZeroSupport) to the fltSemantics struct to describe whether signed zero is supported.

Diff Detail

Event Timeline

jakeh-gc created this revision.Jan 10 2023, 2:02 PM
jakeh-gc requested review of this revision.Jan 10 2023, 2:02 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJan 10 2023, 2:02 PM

The build failure is for clang-format on APFloat.cpp. That file has an unusual indentation, so I don't believe I can make that pass without reformatting the whole file. I believe doing that would make this diff harder to review.

I think we have dueling patches that we should reconcile. I've put together https://reviews.llvm.org/D141863 to do the same thing. (it's just now posted because we were waiting to talk to y'all over at GraphCore to finalize naming, etc. ... but since this revision's already up I might as well go and put mine.)

jakeh-gc abandoned this revision.Jan 25 2023, 1:11 AM

I'm going to put up a narrower version of this based on D141863