TorchLean API

FloatLib.Floats.Formats.OCP.MX.Standard.Core

Concrete OCP MX block representations #

Profile lists the six concrete element encodings in Table 1 of the OCP Microscaling Formats (MX) Specification, version 1.0, September 2023. Block stores exactly 32 elements and an E8M0 scale. The existing arbitrary-length MX.BlockCode remains a separate raw interchange API.

INT8 uses two's complement with six fractional bits (§5.3.4). This profile uses the permitted asymmetric range, including code 0x80, which denotes -2. It does not reinterpret the bytes as sign-magnitude integers. Physical placement of the scale and element words is unspecified by the standard and by this structure.

Decoding follows §5.1: a NaN scale poisons every lane; otherwise element infinities and NaNs survive unchanged. For finite products beyond binary32's range, this implementation retains the exact rational product, one of the implementation choices left open by that section.

Reference: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf.

The six concrete element encodings specified by OCP MX 1.0, Table 1.

Instances For

    Number of stored bits per element.

    Instances For

      Binary descriptor for floating elements; INT8 is a fixed-point two's-complement encoding.

      Instances For

        Exponent of the largest positive power of two representable by an element (§6.3).

        Instances For
          @[reducible, inline]

          A complete element word, whose width is enforced by its profile.

          Instances For

            Decode a binary floating element, retaining signed zero, infinity, and canonical NaN.

            Instances For

              Exact scalar observation before applying the block scale.

              Instances For

                Finite rational interpretation, forgetting only the sign of zero.

                Instances For

                  The stored sign bit, including the sign of floating zero.

                  Instances For

                    OCP MX 1.0 concrete blocks have one scale and exactly 32 elements of one profile.

                    • scale : E8M0

                      Shared eight-bit E8M0 scale; every byte, including NaN, is an admissible encoding.

                    • values : Vector (Element profile) 32

                      Element count and storage width are part of the type.

                    Instances For
                      def FloatLib.Floats.Formats.OCP.MX.Standard.instDecidableEqBlock.decEq {profile✝ : Profile} (x✝ x✝¹ : Block profile✝) :
                      Decidable (x✝ = x✝¹)
                      Instances For
                        @[instance_reducible]
                        @[instance_reducible]

                        Exact multiplication by a positive binary scale, preserving a finite zero's sign.

                        Instances For
                          def FloatLib.Floats.Formats.OCP.MX.Standard.Block.ofArray? {profile : Profile} (scale : E8M0) (values : Array (Element profile)) :
                          Option (Block profile)

                          Accept an array exactly when it has the standard lane count.

                          Instances For

                            Decode one lane according to the shared-scale and per-element rules of §5.1.

                            Instances For

                              Complete lane-wise observation; exceptional elements do not erase their finite neighbors.

                              Instances For

                                Whole-block finite observation for generic conversion. A block with any non-finite lane is reported as NaN here; decode retains each lane's individual classification and sign.

                                Instances For

                                  Canonical block NaN. Element bits are immaterial when the shared scale is NaN.

                                  Instances For