Skip to content

[whisper] Remove torch from install_requires to eliminate unnecessary runtime bloat - #1458

Open
zhangcheng wants to merge 1 commit into
ml-explore:mainfrom
zhangcheng:whisper-remove-torch-dep
Open

zhangcheng wants to merge 1 commit into
ml-explore:mainfrom
zhangcheng:whisper-remove-torch-dep

Conversation

@zhangcheng

Copy link
Copy Markdown

Summary

Currently, mlx-whisper declares torch in whisper/mlx_whisper/requirements.txt, making it an unconditional dependency for all users who install pip install mlx-whisper.

However, during normal inference (mlx_whisper.transcribe(...) and the CLI mlx_whisper), torch is never imported or used:

  • Pre-converted models (such as mlx-community/whisper-*) use weights.safetensors or .npz, which are loaded directly into Apple Silicon unified memory via mlx.core.load.
  • The only file referencing PyTorch is mlx_whisper/torch_whisper.py, which is solely utilized by whisper/convert.py when converting raw OpenAI PyTorch checkpoints (.pt) and in whisper/test.py for numerical parity verification.

Having torch as a hard runtime dependency introduces:

  • 500MB+ (macOS) to 2GB+ (Linux/CUDA) unnecessary disk footprint (plus transitive dependencies like sympy, networkx, jinja2).
  • Substantial installation time overhead for lightweight Apple Silicon deployment environments.

Changes

  1. Removed torch from whisper/mlx_whisper/requirements.txt.
  2. Added extras_require={"conversion": ["torch"], "dev": ["torch"]} to whisper/setup.py.
  3. Updated whisper/README.md to indicate that torch is only required when converting models with convert.py or running parity tests.

- Remove torch from mlx_whisper/requirements.txt to prevent pulling PyTorch during normal pip install mlx-whisper
- Add torch under extras_require={'conversion': ['torch'], 'dev': ['torch']} in setup.py
- Document in README.md that converting models requires PyTorch
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