Skip to main content

Music source separation with MLX acceleration.

Project description

demucs-mlx

Split any song into its individual stems — vocals, drums, bass, and other instruments — directly on your Mac.

demucs-mlx is a fast, native Apple Silicon port of Meta's Demucs music source separation model, built on MLX. No PyTorch required.

Features

  • ~67x realtime on Apple Silicon — 2.4x faster than Demucs with PyTorch MPS
  • Bit-exact parity with upstream Demucs stems (within floating-point tolerance)
  • Custom fused Metal kernels (GroupNorm+GELU, GroupNorm+GLU, OLA)
  • Metal-free fallbacks for non-Apple platforms (Linux)
  • No PyTorch required at inference time
  • Audio I/O via mlx-audio-io
  • STFT/iSTFT via mlx-spectro

Requirements

  • Python >= 3.10
  • macOS with Apple Silicon (recommended) or Linux with MLX

Install

pip install demucs-mlx

On first run, demucs-mlx will automatically download and convert the PyTorch weights to MLX format. This requires the convert extra:

pip install 'demucs-mlx[convert]'

Once weights are cached in ~/.cache/demucs-mlx, the convert extra is no longer needed.

CLI usage

demucs-mlx /path/to/audio.wav

Options:

-n, --name          Model name (default: htdemucs)
-o, --out           Output directory (default: separated)
--shifts            Number of random shifts (default: 1)
--overlap           Overlap ratio (default: 0.25)
-b, --batch-size    Batch size (default: 4)
--write-workers     Concurrent writer threads (default: 1)
--list-models       List available models
-v, --verbose       Verbose logging

Python usage

from demucs_mlx import Separator

separator = Separator()
origin, stems = separator.separate_audio_file("song.wav")

# stems is a dict: {"drums": array, "bass": array, "other": array, "vocals": array}
for name, audio in stems.items():
    print(f"{name}: {audio.shape}")

To keep outputs as MLX arrays (avoids GPU-to-CPU copy):

origin, stems = separator.separate_audio_file("song.wav", return_mx=True)

Performance

Benchmarked on a 3:15 stereo track (44.1 kHz, 16-bit) using htdemucs with default settings:

Package Backend Time Speedup
demucs 4.0.1 PyTorch (CPU) 52.3s 0.1x
demucs 4.0.1 PyTorch (MPS) 6.9s 1x
demucs-mlx 1.0.0 MLX + Metal 2.9s 2.4x

Apple M4 Max, 128 GB. All runs use htdemucs with default settings and a single warm-up pass before timing.

Models

Model Sources Description
htdemucs 4 Hybrid Transformer Demucs (default)
htdemucs_ft 4 Fine-tuned HTDemucs
htdemucs_6s 6 6-source (adds piano, guitar)
hdemucs_mmi 4 Hybrid Demucs MMI
mdx 4 Music Demixing model
mdx_extra 4 MDX with extra training

MLX model cache

Pre-converted MLX weights are cached under ~/.cache/demucs-mlx. Delete to force re-conversion.

Documentation

  • API reference: docs/api.md
  • Development workflow: docs/development.md
  • Platform notes: docs/platform.md

License

MIT. Based on Demucs by Meta Research. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demucs_mlx-1.0.0.tar.gz (55.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

demucs_mlx-1.0.0-py3-none-any.whl (62.2 kB view details)

Uploaded Python 3

File details

Details for the file demucs_mlx-1.0.0.tar.gz.

File metadata

  • Download URL: demucs_mlx-1.0.0.tar.gz
  • Upload date:
  • Size: 55.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for demucs_mlx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d4c5155cd5ee8150233d1427a175cbdd922f49818261d81dcc7f36b7ea6676c1
MD5 7870f6d55e324b001669cf69a9c47ad7
BLAKE2b-256 d81b1d75f9f30387cdcad1cc572f565602580a5bcbd19e07b08f712d608f2a50

See more details on using hashes here.

Provenance

The following attestation bundles were made for demucs_mlx-1.0.0.tar.gz:

Publisher: release-pypi.yml on ssmall256/demucs-mlx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file demucs_mlx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: demucs_mlx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 62.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for demucs_mlx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0533676a5c0b7f1b3cd3b47ba12dde1feb469205fab87d44bbc0bc35ec9d28
MD5 6d26bf9e5f0b8bfcc212d7f3b2a4360f
BLAKE2b-256 eaecda028ac0a6b37e1466837ba42d19bbabb5d08c0f62a376130565e9f56884

See more details on using hashes here.

Provenance

The following attestation bundles were made for demucs_mlx-1.0.0-py3-none-any.whl:

Publisher: release-pypi.yml on ssmall256/demucs-mlx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page