Skip to content

fix: Add Float64 dtype support for safetensors conversion#309

Open
ymote wants to merge 1 commit intooxiglade:mainfrom
ymote:fix/float64-safetensors
Open

fix: Add Float64 dtype support for safetensors conversion#309
ymote wants to merge 1 commit intooxiglade:mainfrom
ymote:fix/float64-safetensors

Conversation

@ymote
Copy link

@ymote ymote commented Jan 23, 2026

Summary

  • Add Float64 (f64) dtype support in the TryFrom<&Array> for TensorView implementation

Problem

Previously, attempting to convert an f64 MLX Array to a safetensors TensorView would fall through to the Complex64 error case, making it impossible to save f64 arrays to safetensors files.

Solution

Add the missing Dtype::Float64 match arm that properly converts f64 arrays to safetensors format.

Dtype::Float64 => {
    let data = value.as_slice::<f64>();
    cast_slice(data)
},

Use Case

This is needed for loading/saving certain model weights (e.g., some normalization layers) that use f64 precision.

Test plan

  • Verified compilation
  • Manual testing with f64 arrays

🤖 Generated with Claude Code

Previously, attempting to convert an f64 Array to a safetensors TensorView
would fall through to the Complex64 error case. This adds proper handling
for Float64 dtype, enabling save/load of f64 arrays via safetensors.

This is needed for loading certain model weights (e.g., some normalization
layers) that use f64 precision.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@minghuaw minghuaw changed the base branch from old-main to main February 26, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant