+- **FP8 (`ILGPU.Float8E4M3` + `ILGPU.Float8E5M2`) now works on all 6 backends** (CPU, OpenCL, WebGPU, WebGL, Wasm, CUDA). The two OCP FP8 8-bit float formats - E4M3FN (1/4/3, bias 7, no Inf, saturates to +-448, the forward/inference format) and E5M2 (1/5/2, bias 15, IEEE Inf/NaN, the backward/gradient format) - as full `INumber<T>` value types (FP32-based `[MathIntrinsic]`/`[CompareIntrinisc]`/`[ConvertIntrinisc]` operators) + `BasicValueType.Float8E4M3`/`Float8E5M2` IR primitives (append-only). FP8 computes as f32 in-register (the f32-register model) and is converted at the 1-byte load/store boundary. The FP8<->f32 conversion (exponent rebias 127->7/15, RNE rounding, subnormal normalize, variant specials) is emitted per backend: callable helper functions on OpenCL (`_e4m3/_e5m2_bits_to_f32` + inverse), WGSL, and GLSL; inline WebAssembly bytecode on Wasm (`EmitFP8ToF32`/`EmitF32ToFP8`, subnormal-normalize unrolled for bit-exactness); inline PTX bit-manipulation on CUDA (`EmitFP8BitsToF32`/`EmitF32ToFP8Bits`, branchless setp/selp - FP8 has no portable native PTX cvt). All byte-identical to the CPU-verified managed conversion. Gate: `BackendTestBase.PrecisionConvert_Float8E{4M3,5M2}_RoundTripBitExact` (pure `ConvertFromSingle(ConvertToSingle(x))` bit-exact vs the concrete `(T)(float)x` cast) on every backend; the `relu(x*scale+bias)` generic `INumber<T>` kernel 257/257 on CPU+OpenCL+CUDA. FP8 radix-sort keys (`Interop.FloatAsInt`) are a tracked follow-up.
0 commit comments