Skip to content

Conversation

@Blaizzy
Copy link

@Blaizzy Blaizzy commented Dec 11, 2025

What does this PR do?

Adds MLX tensor support to BatchFeature and removes the PyTorch-only restriction in fast image processing utilities.

Changes:

  • Added is_mlx_array export to transformers/utils/__init__.py
  • Implemented MLX tensor conversion logic in BatchFeature.convert_to_tensors() (feature_extraction_utils.py)
  • Removed the hardcoded validation that restricted fast image processors to PyTorch tensors only (image_processing_utils_fast.py)

This enables using return_tensors="mlx" with vision models and fast image processors on Apple Silicon, which previously raised:

ValueError: Only returning PyTorch tensors is currently supported. 

Before submitting

Who can review?

@Blaizzy Blaizzy changed the title Fix torch only support Fix torch only support for Processors Dec 11, 2025
@Blaizzy Blaizzy changed the title Fix torch only support for Processors Fix torch only support for fast Processors Dec 11, 2025
@Rocketknight1
Copy link
Member

cc @yonigozlan @molbap but not sure who to tag for MLX!

@Blaizzy
Copy link
Author

Blaizzy commented Dec 12, 2025

@ArthurZucker has some context as well

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: pop2piano

@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants