Sound & music · Research feature

TinyMusician: On-Device Music Generation with Knowledge Distillation and Mixed Precision Quantization

A new music generation model, TinyMusician, achieves high audio quality on mobile devices by reducing size and computational needs through distillation and quantization.

Adapted from research by Hainan Wang, Mehdi Hosseinzadeh, Reza Rawassizadeh.

arXiv preprint revision · 2025-08-31 · Attribution & reuse
In this article
Comparison of Training Loss on different KL-Divergence Methods
Figure 2: Comparison of Training Loss on different KL-Divergence Methods

Editor’s introduction

The study evaluates TinyMusician, a lightweight music generation model derived from MusicGen, by comparing its performance and efficiency to the original model. Researchers assessed the impact of a stage-mixed bidirectional KL divergence loss and adaptive mixed-precision quantization on audio fidelity and model size. The study includes ablation analysis to isolate the contributions of knowledge distillation and quantization, confirming both techniques improve efficiency without significant quality loss. Findings are benchmarked against state-of-the-art systems, demonstrating a favorable balance between generation quality and computational demands. The evidence supports the model’s capability to run on edge devices, though performance comparisons are limited to specific metrics and do not include broader user experience or genre diversity assessments.

Introduction

Music, reflecting culture, social classes, ethnic identities, and historical eras, has woven itself into humanity’s shared heritage through centuries of evolution. Today, artificial intelligence (AI) has demonstrated remarkable breakthroughs across multimodal domains, including image generation, inpainting, outpainting, short video production, etc.

Large-Language Models (LLMs) showed excellent modeling capabilities in obtaining complex relationships in long-term contexts, which the music genre inherited. In view of this, MusicLMs and many subsequent works successfully applied LLMs in music generation, capitalizing on their ability to capture intricate patterns in musical sequences.

There are several efforts to reduce the model size, especially in Transformer architecture, such as efficient self-attention mechanisms. Furthermore, several approaches such as Mixture of Experts (MoE), and Low-Ranked Adaptation (LoRA) are used to reduce the computational cost of feed-forward layers of transformer architecture.

On the other hand, several approaches focus on enabling the neural network models’ deployment on consumer electronics, such as Federated Learning and model compression techniques. Three common approaches focus on model compression and reducing the size of a neural network, including Knowledge Distillation, pruning, and quantization.

In short, knowledge distillation transfers knowledge from a teacher model (baseline model) to a student model (smaller model), which ensures fidelity of results while having a smaller number of model parameters. This technique has demonstrated its efficacy across multiple AI domains. For instance, proposed JITNet, employing MRCNN as the teacher model, and reduced the number of parameters from 300 million to 7 million. A cited study introduced Patient Knowledge Distillation, which distills the 12-layer BERT-original into a 6-layer BERT while preserving 97% of its performance.

In addition to the knowledge distillation, neural network quantization has emerged as another paradigm of critical model compression. By converting high-precision model weights into compact low-bit representations without altering the network architecture, this technique has been proven effective in domains such as audio processing, Deep Reinforcement Learning and image processing.

The third common approach is pruning, which includes removing neurons that are not contributing much to the final output. Pruning could be determined based on the weight, activation value, or even the entire neuron and its connections.

In this work, we present TinyMusician, a novel lightweight model for mobile, on-device music generation, distilled from the state-of-the-art MusicGen-Small architecture, integrating Stage-mixed Bidirectional KL-divergence in Knowledge Distillation with temperature annealing strategy to enhance knowledge transfer fidelity between teacher and student models. To further enhance inference efficiency, we also implement adaptive mixed-precision quantization and achieve 55% reduction in model size compared to the original MusicGen with 9.5% sacrificing melodic or harmonic fidelity.

Synthetic Music Generation

Previous to neural network advances, the Markov chain, rule-based models, and evolutionary algorithms are three main groups of methods that are mainly used to generate music. These methods are typically parameter-based, requiring human input of parameters or configurations to guide music generation. Music generated by these methods remained quite limited.

Later, with the development of deep neural networks, generative models show incredible ability in sequential data construction, including music. Several types of generative models have been developed to meet the high-quality requirement of music generation, including RNN models, GAN based-models, and VAE based-models. For example, Jukebox, one of the first VAE-based models, can generate full vocal music. Although the quality is limited and slow, it still demonstrates the ability to produce music that aligns with the inputs of the lyric, artist, and Genre.

Recently, diffusion models and transformer-based models have emerged as the mainstream in music generation models. The learning process of diffusion models involves two core steps: a forward process that gradually adds noise to a sample and a reverse process that aims to denoise and reconstruct the original data. ERNIE-Music is a diffusion-based architecture specifically designed for music, and it involves a forward step of gradually adding Gaussian noise to music waveforms and a reverse denoising process to reconstruct the original audio, using a U-Net with conditional self-attention to integrate text prompts from an ERNIE-M text encoder for direct text-to-waveform translation.

Transformer-based models, on the contrary, are experts in modeling long-range dependencies and structural patterns, such as melodic repetition, harmonic progression, or rhythmic patterns, by processing musical sequences as tokenized events (notes, pitches, instruments) with positional encoding. However, the strong performance of transformer models also comes with a tradeoff: the transformer-based architecture requires substantial computational resources, which hinders their deployment on small battery-powered devices.

These evidences show that directly deploying such models not only incurs significant resource costs but also triggers long inference times. Additionally, deploying these models on edge devices such as mobile phones is impossible due to their limited storage and computing resources.

Model Compression

Quantization methods have some advantages over Pruning and Knowledge Distillation. In particular, first, they are cost-effective, and most of the quantization methods don’t need to retrain the entire model, making them easier for researchers with limited computing resources. Second, they support effective compression, because the weights of models from 32-bit Float to 8-bit or 4-bit Int could drastically compress model size to approximately 1/4 or 1/8. Third, quantization is highly compatible with most other model compression methods and thus flexible.

Quantization-aware training (QAT) and Post- Training quantization (PTQ) is a common Quantization method. QAT aims to quantize the model during the training phase, while PTQ considers the quantization after training. Due to the cost-effectiveness of time and computational resources, PTQ is more popular. Most PTQ approaches quantize parameters in weights and activations in each layer, and can be divided into three subsets: Weight-only Quantization, Key-Value (KV) Cache Quantization, and Weight-activation Quantization. PTQ advancements have reshaped model efficiency. For example, GPTQ is a Weight-only method that can compress popular open-source models down to 3 and 4 bits. SmoothQuant, in contrast, introduces joint weight-activation quantization, balancing their dynamic ranges to reduce error propagation in vision transformers. While PTQ methods have improved model efficiency, their application to music generation models remains underexplored.

Unlike text or images, music synthesis demands precise preservation of temporal dynamics and spectral fidelity, which are highly sensitive to quantization errors in both weights and activations. Applying uniform quantization across all model weights and activations, as commonly done in other domains, risks significant degradation in musical quality. To address these challenges, for music generation, a mixed-precision quantization approach is essential. In contrast, introduce joint weight-activation quantization, balancing their dynamic ranges to reduce error propagation in vision transformers. While PTQ methods have improved model efficiency, their application to music generation models remains underexplored. Unlike text or images, music synthesis demands precise preservation of temporal dynamics and spectral fidelity, which are highly sensitive to quantization errors in both weights and activations.

Applying uniform quantization across all model weights and activations, as commonly done in other domains, risks significant degradation in musical quality. To address these challenges, a mixed-precision quantization approach is essential, and our model, TinyMusician implements it.

Knowledge Distillation (KD), based on how to design the loss function, can be further categorized into two groups: logit-based KD, and feature-based KD. Logit-based KD typically uses KL-Divergence or Mean Square Error (MSE) to minimize the logits between the teacher and the student. DistilBERT, for example, is a KD of BERT, which is 40% smaller, 60% faster, retains 97% of BERT’s language understanding capabilities, and is trained with a triple loss during pre-training, demonstrating its effectiveness in various downstream tasks. Cited researchers propose an offline KD training method from high-performance yet complex Transformer models to efficient CNN models. It constructs different audio tagging models with different complexities, outperforming previous solutions in terms of model size, computational efficiency, and prediction performance, assessed via Frechet Audio Distance (FAD), which quantifies audio by comparing feature distributions, and CLAP scores, which measure text-audio semantic alignment via contrastive learning, and achieving a new single-model state-of-the-art mean average precision of 0.483 on the AudioSet dataset.

Feature-based KD aims to minimize the intermediate features between the teacher and the student. PKD introduced MSE as a loss function and proposed two strategies: the student learns the last few layers in the teacher, and the others learn every two layers’ representations of the teacher. MT-BERT method uses multiple teacher pre-trained language models with a new finetuning framework and new loss functions to better compress PLMs and outperforms single-teacher and some multi-teacher distillation methods. However, as with Quantization, KD is also still underexplored in the music generation area.

Customized Quantization

In addition to our proposed KD, we adopt a post-training mixed-precision method to quantize the MusicGen-small model. The MusicGen model can be partitioned into three distinct components: the T5 Text-Encoder, the MusicGen-Decoder, and the Encodec-Decoder. Each of these components is quantized into different formats: specifically, the Text-Encoder is quantized to Int8 to balance efficiency and representation preservation; the MusicGen-Decoder is quantized to Float16 to maintain autoregressive generation stability; and the Encodec-Decoder is kept in Float32 to ensure high-fidelity audio reconstruction.

The Text Encoder takes text as input embeddings, produced by a tokenizer or embedding layer, and outputs the last hidden states. In MusicGen-Decoder, the transformer performs autoregressive token generation by processing a sequence of discrete tokens, step-by-step. At each step, it uses causal self-attention to focus only on previously generated tokens, ensuring no future information is accessed. It also incorporates conditional signals (the text embeddings) via cross-attention to guide the generation. Based on these inputs, the transformer predicts the next token (using Classifier Free Guidance (CFG) strategy and the top-k sampling strategy to guide the model’s output) in the sequence, which is then added to the existing sequence. This iterative process continues until a complete token sequence is generated, and each new token builds on the context of all prior ones.

Dataset

We conduct our experiments on the MusicCap Dataset, which is a large-scale dataset for music-text alignment tasks. It consists of 5,500 high-quality music-text pairs. Each sample is annotated with two types of descriptions: (i) a list of English-language musical aspects, which captures elements such as genre, tempo, and instrumentation; and (ii) a free-form text caption authored by professional musicians, offering qualitative insights into the musical content.

Experimental Setup

All experiments to train the model are performed on a hardware environment equipped with an RTX 4090 GPU (24GB), a 16 vCPU Intel(R) Xeon(R) Gold 6430 CPU, Pytorch version 2.5.1, and the operating system is Ubuntu 18.04.

Comparison with State-of-the-Arts

In particular, we incorporate resource utilization metrics and accuracy-related established benchmarks. The resource utilization includes inference time (in seconds), GPU FLOPS, CPU utilization (in percentage), Memory Usage (in GB), GPU Memory Usage (in GB), and model size (in gigabytes), which collectively characterize the models’ computational efficiency and resource requirements.

To measure accuracy-related benchmarks, we employ two important benchmarks, i.e., CLAP (Contrastive Language Audio Pretraining) and FADscore (Frechet Audio Distance Score). CLAP is a framework that can capture the semantic relationship between audio and text. FADscore, on the other hand, measures the similarity between the distribution of generated audio and the real-world audio distribution.

Results and Discussion

We first examine the training dynamics of different loss functions to highlight the advantages of our proposed Stage-mixed Bidirectional KL divergence. Next, we report the findings of the ablation study, which quantifies the individual and combined impacts of knowledge distillation and quantization on model performance and efficiency. Finally, we conduct a detailed comparison with state-of-the-art music generation systems, demonstrating the superior trade-off between efficiency and generation quality achieved by TinyMusician.

Training Dynamics of Loss Functions

(ii) The use of blended distributions (combining teacher and student outputs) prevents the student from overfitting to the teacher’s specific non-generalizable patterns, while creating a stable reference frame for capturing long-range musical dependencies like harmonic progressions or thematic repetitions.

Comparison with State-of-the-Art Models

Large-scale models (e.g., YuE-7B, DiffRhythm) prioritize fidelity but suffer from prohibitive size and latency, while pure Int-8 quantization (0.58GB) sacrifices musical coherence (e.g., abrupt rhythm shifts). In contrast, the TinyMusician-MixedPrecision approach strikes a critical balance: its 1.04GB footprint retains near-baseline fidelity with FADscore of 7.05, approaching full-precision’s 6.44, and outperforms all competitors with CLAPscore of 0.373, underscoring stronger text-music alignment. Though its 26.54s latency marginally exceeds INT8, it remains orders of magnitude faster than bulky models (e.g., YuE-7B’s 1007s). The MusicGen-Tiny variant further validates scalability: with 40% fewer parameters, it nears baseline fidelity, demonstrating the framework’s potential for efficiency-driven refinement.

Conclusion

In this study, we address the critical challenge of deploying large music generation models on resource-constrained edge devices, such as mobile phones, by introducing TinyMusician, a lightweight framework that integrates knowledge distillation and adaptive mixed-precision quantization. By using MusicGen as a baseline, we propose a stage-mixed bidirectional KL Divergence loss with a dynamic temperature annealing strategy to enhance the performance of knowledge transfer between the teacher and student models. To further optimize inference efficiency on devices, we apply mixed-precision quantization to different components of the MusicGen model, achieving a 55% reduction in model size while preserving the performance. For future work, we plan to investigate how to speed up on-device inference by using the different model formats. Also, could apply this framework to the state-of-the-art generative models and conduct more experiments to optimize further compression strategies while saving the output quality.