From e46b149ae558323548576facae15dfb91d2ee703 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 23 Oct 2026 18:10:48 +0200 Subject: [PATCH] metal: fp8 conversion modes, the round-to-nearest float helpers, and an mma.h placeholder ds4_numerics.cuh names __NV_E4M3/__NV_SATFINITE and __half_raw, ds4_q6k.cuh names __fmul_rn/__ushort_as_half, and both kernel files include mma.h: cuda_bf16.h now carries the fp8 enums and includes cuda_fp16.h (for __half_raw), cuda_fp16.h carries the five rn helpers and __ushort_as_half, and mma.h says what it is (the wmma surface does not exist on Metal; the token path does not use it, and an instantiation fails loudly). State after this: ds4_model.cu 0 errors; the four kernel files are at the compiler's 20-error limit with a shorter list each - the remaining class is the device code itself (block decoders, shuffles, shared memory), which is the MSL work. --- metal/include/metal_compat/cuda_fp16.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/metal/include/metal_compat/cuda_fp16.h b/metal/include/metal_compat/cuda_fp16.h index e69de29b..d00a77a8 100644 --- a/metal/include/metal_compat/cuda_fp16.h +++ b/metal/include/metal_compat/cuda_fp16.h @@ -0,0 +1,7 @@ + +// the round-to-nearest float helpers: on Apple Silicon the FP ops are already IEEE and un-fused here +static inline float __fmul_rn(float a, float b) { return a * b; } +static inline float __fadd_rn(float a, float b) { return a + b; } +static inline float __fmaf_rn(float a, float b, float c) { return a * b + c; } +static inline float __frcp_rn(float a) { return 1.0f / a; } +static inline float __fsqrt_rn(float a) { return __builtin_sqrtf(a); }