Skip to content

pytorch_utils.py > isin_mps_friendly > RuntimeError: Expected elements.dtype() == test_elements.dtype() to be true, but got false. #37423

Description

@f2janyway

I just followed this tutorial. but got error

https://huggingface.co/learn/audio-course/en/chapter2/tts_pipeline

from transformers import pipeline

pipe = pipeline("text-to-speech", model="suno/bark-small")

text = "Ladybugs have had important roles in culture and religion, being associated with luck, love, fertility and prophecy. "
output = pipe(text)
RuntimeError: Expected elements.dtype() == test_elements.dtype() to be true, but got false.

return torch.isin(elements, test_elements)

so I just added this code. and works fine. when I took a log with bug code the elements.dtype shown 'int32' but others elements.dtype, and test_elements.dtype 'int64'

        if elements.dtype != test_elements.dtype:
            elements = elements.to(dtype=test_elements.dtype)
        # Note: don't use named arguments in `torch.isin`, see https://github.com/pytorch/pytorch/issues/126045
        return torch.isin(elements, test_elements)

my env:

macbook pro m1

conda

transformers-cli env
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

  • transformers version: 4.51.1
  • Platform: macOS-15.3.1-arm64-arm-64bit
  • Python version: 3.10.12
  • Huggingface_hub version: 0.30.2
  • Safetensors version: 0.5.3
  • Accelerate version: 1.6.0
  • Accelerate config: not found
  • DeepSpeed version: not installed
  • PyTorch version (GPU?): 2.6.0 (False)
  • 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. In fact. I don't know. I didn't set about these.

Who can help?

@gante

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

just run above code.

Expected behavior

RuntimeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions