TorchLean API

FloatLib.Floats.Formats.OCP.MX.E8M0.Core

Exponent-only scaling formats #

OCP microscaling uses E8M0 for a scale shared by a block of narrow elements. E8M0 is not a member of the sign/exponent/fraction family: it has no sign bit, no zero, and no explicit fraction. Codes 0 through 254 denote powers of two from 2^-127 through 2^127; code 255 is NaN.

Keeping this scale type beside, rather than inside, FloatFormat prevents artificial optional fields and invalid combinations in the ordinary float API.

References:

Exact E8M0 storage word.

The transparent definition has the same compiled representation as BitVec 8, while retaining the exponent-only format identity for proof-aware type inspection.

Instances For

    E8M0 exponent bias.

    Instances For
      @[inline]

      Construct an E8M0 word from its raw code.

      Instances For
        @[inline]

        Raw code as a natural number.

        Instances For
          @[simp]

          Re-encoding an E8M0 word's complete byte pattern preserves it.

          @[simp]
          theorem FloatLib.Floats.Formats.OCP.MX.E8M0.toNatBits_ofNatBits_of_lt (bits : ) (bits_lt : bits < 2 ^ 8) :
          (ofNatBits bits).toNatBits = bits

          An in-range byte pattern is unchanged by E8M0 encoding.

          @[inline]

          The sole NaN encoding (0xff).

          Instances For
            @[inline]

            Unbiased power-of-two exponent, or none for NaN.

            Instances For
              @[inline]

              Exact positive dyadic scale, or none for NaN.

              Instances For
                @[inline]

                Apply an E8M0 scale to an exact dyadic by adding its power-of-two exponent.

                Instances For
                  @[inline]

                  Decode and scale one element of a microscaling block.

                  none records either the E8M0 NaN code or a non-finite element. The operation is exact: scaling by a power of two changes only the dyadic exponent.

                  Instances For

                    Exact mathematical decoding of a microscaling block with one shared E8M0 scale.

                    This function decodes an already encoded block; it does not choose the shared scale. An empty array succeeds without inspecting the scale. On a nonempty array, a NaN scale or any non-finite element causes decoding to fail.

                    Instances For

                      Encode an in-range exponent; return none outside [-127, 127].

                      Instances For

                        Encode an exponent after clamping it to the finite E8M0 range.

                        Instances For

                          Every successfully decoded E8M0 scale has significand one.

                          Every successfully decoded E8M0 scale has its sign bit clear.