From d6204534dec57f2cab47d6fcb73a501c1a16286a Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Fri, 24 Apr 2026 17:04:28 +0200 Subject: [PATCH] Add ST_F8_E8M0 No conversion is performed, this just allows safetensors files to be loaded. I think this should help load the native DeepSeek checkpoints without conversion, as the attention scales use F8_E8M0. --- mlx/io/safetensors.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mlx/io/safetensors.cpp b/mlx/io/safetensors.cpp index 0243a2eb40..a8d8627bac 100644 --- a/mlx/io/safetensors.cpp +++ b/mlx/io/safetensors.cpp @@ -28,6 +28,7 @@ using json = nlohmann::json; #define ST_U32 "U32" #define ST_U64 "U64" #define ST_F8_E4M3 "F8_E4M3" +#define ST_F8_E8M0 "F8_E8M0" // Note: Complex numbers aren't in the spec yet so this could change - // https://github.com/huggingface/safetensors/issues/389 @@ -97,6 +98,8 @@ Dtype dtype_from_safetensor_str(std::string_view str) { return complex64; } else if (str == ST_F8_E4M3) { return uint8; + } else if (str == ST_F8_E8M0) { + return uint8; } else { std::ostringstream msg; msg << "[safetensor] unsupported dtype" << str;