Symbolic Music Generation with Non-Differentiable Rule Guided Diffusion

Yujia Huang, Adishree Ghatare, Yuanzhe Liu, Ziniu Hu, Qinsheng Zhang, Chandramouli Shama Sastry, Siddharth Gururani, Sageev Oore, Yisong Yue

Introduction

Diffusion models have emerged as a powerful paradigm for generative AI, yet precisely controlling their output remains a significant challenge. In domains like symbolic music generation, users often need the model to adhere to specific, complex constraints—such as a particular chord progression or a target note density. Traditionally, guiding these models requires a differentiable loss function, allowing the system to calculate gradients and iteratively nudge the generation toward the desired outcome.

However, many fundamental musical rules are inherently non-differentiable. For instance, counting notes to determine density or performing symbolic lookups for chord identification are discrete, "black-box" operations. Previous solutions often involved training specialized surrogate models to approximate these rules, a process that is both computationally expensive and prone to inaccuracy. This paper introduces Stochastic Control Guidance (SCG), a "plug-and-play" framework that enables diffusion models to follow arbitrary, non-differentiable rules without retraining.

Methodology

Stochastic Control Guidance (SCG)

SCG reframes the diffusion process as a stochastic optimal control problem. Rather than relying on gradients, the algorithm leverages the inherent randomness of the sampling process. At each denoising step, the system generates multiple potential "next steps" (realizations). It then evaluates these candidates using the target rule—even if that rule is a complex, non-differentiable program—and selects the path that best aligns with the constraints. This "sample-and-select" mechanism is mathematically grounded in path integral control theory, allowing it to work with any programmable rule.

Overview of the SCG framework, showing how rule programs guide the pretrained diffusion model through a sample-and-select process.

High-Resolution Latent Diffusion

To capture the nuance of human performance, the authors utilize a high-resolution latent diffusion architecture. Standard symbolic music models often use coarse, beat-based grids that strip away expressive timing. This system employs a Variational Autoencoder (VAE) to compress piano rolls into a latent space, which is then modeled by a Transformer-based diffusion backbone (DiT). By achieving a 10ms time resolution, the model preserves subtle expressive elements like rubato (timing variations) and velocity (dynamics).

The latent diffusion architecture: piano roll data is chunked, encoded into a latent space for diffusion, and then decoded back into high-resolution music.

Experimental Setup and Results

The model was trained on a massive corpus of MIDI data, including the MAESTRO dataset (virtuosic classical performances) and Muscore (~700 hours of diverse musical styles). Evaluation focused on three key areas:

  • Unconditional Quality: The model achieved state-of-the-art results in Average Overlapping Area (OA), a metric that compares the statistical distribution of generated musical attributes against real human data. It outperformed established baselines such as MusicTransformer and PolyDiff.
  • Controllability: When tested against specific constraints like chord progressions and note density, SCG demonstrated significantly lower error rates than gradient-based methods like Diffusion Posterior Sampling (DPS), which struggle with non-differentiable logic.
  • Human Evaluation: In blind listening tests, professional musicians rated SCG-generated samples higher than baselines across musical creativity, coherence, rule alignment, and overall quality.

Discussion and Future Work

A key insight of this research is that backpropagation is not strictly necessary for effective guidance; the stochasticity of the diffusion process itself provides enough "search space" to satisfy complex constraints. While SCG is computationally more intensive than unguided sampling—requiring multiple realizations per step—it offers unparalleled flexibility for composers to swap rules (e.g., changing from Jazz to Classical harmonies) instantly.

Beyond music, the authors suggest that SCG could be applied to other scientific fields where constraints are defined by complex physical simulations, such as protein design or astronomy imaging, where differentiable gradients are often unavailable.

Summary updated

BibTeX
@inproceedings{huang2024symbolic,
  author = {Yujia Huang and Adishree Ghatare and Yuanzhe Liu and Ziniu Hu and Qinsheng Zhang and Chandramouli Shama Sastry and Siddharth Gururani and Sageev Oore and Yisong Yue},
  title = {{Symbolic Music Generation with Non-Differentiable Rule Guided Diffusion}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=g8AigOTNXL},
}
Figure