Local deployment of large-scale music AI models on commodity hardware

Xun Zhou, Charlie Ruan, Zihe Zhao, Tianqi Chen, Chris DonahuearXiv 2024 · DOI

Introduction

Researchers from Carnegie Mellon University have introduced MIDInfinite, a web application designed to run large-scale symbolic music AI models locally within a browser. By leveraging the Machine Learning Compilation (MLC) framework to port the Anticipatory Music Transformer, the team has enabled high-speed, private, and low-latency music generation on standard consumer hardware, such as MacBooks. This approach bypasses the traditional reliance on expensive cloud APIs or complex, dependency-heavy Python environments.

The Ecosystem Gap in Music AI

A significant "ecosystem gap" currently exists in the field of music AI. State-of-the-art generative models are typically developed in Python and require high-end NVIDIA GPUs for inference. Conversely, the music technology industry is built on C++, VST plugins, and the need for low-latency performance on consumer-grade laptops.

For music software developers, integrating modern Large Language Models (LLMs) into a Digital Audio Workstation (DAW) often involves a "nightmare" of dependency management. While cloud-based APIs offer a temporary solution, they introduce latency and privacy concerns that are unacceptable for live performance. This research explores bridging this gap by bringing heavy models directly to "commodity hardware" using web-native technologies.

Methodology: Bridging the Gap with MLC

The authors propose a multi-stage workflow to transition models from research environments to production-ready applications.

The MIDInfinite workflow: from model compilation to on-device deployment.
  1. Model Porting: The Anticipatory Music Transformer (a GPT-2 based model) was ported to the MLC-LLM framework. This involved defining the architecture in TVM’s Relax frontend and compiling it into optimized kernels for backends including C++, WebGPU, and Metal.
  2. Infinite Generation: To overcome the fixed-length sequence limits (341 notes) of the original model, a "chunk-wise" generation strategy was implemented. Music is generated in 170-note blocks, using the tail of the previous block as context to ensure continuity.
  3. Grammar Enforcement: To prevent the model from "hallucinating" invalid MIDI data, the team extended the WebLLM platform with a LogitProcessor. This enforces a context-free grammar, ensuring the output adheres to strict MIDI structures (onset, duration, and pitch).
  4. Ensemble Control: A heuristic-based approach was introduced to encourage instrument diversity. By tracking the time since an instrument was last used and biasing logits accordingly, the system can force the AI to compose for a full ensemble.

Experimental Setup and Datasets

The Anticipatory Music Transformer used in this study was pre-trained on the Lakh MIDI dataset, a standard collection of over 170,000 MIDI files. Benchmarks were conducted using both "Small" (128M parameters) and "Medium" (360M parameters) variants of the model.

Performance Results

The transition from standard PyTorch to MLC-compiled kernels yielded substantial performance improvements across various hardware configurations.

Performance benchmarks comparing PyTorch and MLC across different hardware and model sizes.
  • Throughput: On an M3 Max MacBook Pro, the "Small" model achieved 155 tokens per second (tok/s) using MLC, a significant increase over the 92 tok/s achieved with PyTorch.
  • Real-time "Streamability": The authors define "streamable" generation as the ability to generate notes faster than they are played back. On the M3 Max, the small model met this threshold for 72.9% of generations. With a modest 2-second buffer, this success rate rose to 86.3%.
  • Browser Efficiency: On a standard M2 chip, the MLC-compiled model in a browser environment was nearly twice as fast as the PyTorch baseline (84 tok/s vs 44 tok/s).
  • Scaling to Medium Models: The 360M parameter model achieved 90 tok/s on the M3 Max, demonstrating viability for complex composition tasks even if real-time streaming is more challenging.

Key Insights and Discussion

The most significant takeaway is the role of MLC as a universal translator. It allows AI researchers to provide "compiled libraries" that music software developers can integrate into familiar environments (browsers, mobile apps) without needing to manage Python environments. By moving inference to the device via WebGPU, the system achieves the zero-latency feel required for creative tools.

Limitations and Future Work

Despite these gains, several challenges remain:

  • Model Scale: Current tests are limited to models up to 360M parameters; scaling to multi-billion parameter models in the browser remains a future goal.
  • Control Heuristics: The current ensemble density control relies on simple additive heuristics. More sophisticated methods for structural control are needed.
  • Hardware Variance: While performance is excellent on M-series Macs, older integrated GPUs still struggle with the "Medium" models.
  • DAW Integration: The next step is moving beyond the web-based proof-of-concept into standard plugin formats like VST or AU for direct use in professional DAWs like Ableton Live.

Summary updated

BibTeX
@misc{zhou2024local,
  author = {Xun Zhou and Charlie Ruan and Zihe Zhao and Tianqi Chen and Chris Donahue},
  title = {{Local deployment of large-scale music AI models on commodity hardware}},
  year = {2024},
  eprint = {2411.09625},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.09625},
}
Figure