Skip to content

load_file errors when device is mps:0 #674

@jakelorocco

Description

@jakelorocco

System Info

  • transformers version: 4.53.3
  • Platform: macOS-15.6-arm64-arm-64bit
  • Python version: 3.12.0
  • Huggingface_hub version: 0.36.0
  • Safetensors version: 0.6.2
  • Accelerate version: 1.11.0
  • Accelerate config: not found
  • DeepSpeed version: not installed
  • PyTorch version (accelerator?): 2.7.0 (NA)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?: no

Information

  • The official example scripts
  • My own modified scripts

Reproduction

from safetensors.torch import load_file
load_file('.../adapter_model.safetensors', device="mps:0") # any adapter_model.safetensors file

Results in:

E       safetensors_rust.SafetensorError: device mps:0 is invalid

Expected behavior

I encounter this issue when loading adapters using Peft, but I believe this is a generic issue with safetensors. I think the expected behavior is that safetensors should load this file using mps. Torch will seems to accept torch.device("mps:0") and will accept .to("mps:0") when moving tensors to a device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions