This paper, Perfect diffusion is TC0 – Bad diffusion is Turing-complete, has been stuck in my head. Here’s an exposition of 1/2 of the result.
(I claim no novelty in either exposition or content for what is below)
what is SMLD?
Given a distribution 𝜌𝑑𝑎𝑡𝑎 over ℝ𝑑, SMLD aims to learn a score-matching function 𝑓𝜃 which samples from ∇log𝜌𝑑𝑎𝑡𝑎 well. In particular, for 𝑥 ∼𝜌0, which we define as 𝜌0 =𝜌𝑑𝑎𝑡𝑎, we aim for 𝑓𝜃(𝑥,𝑡) to approximate ∇𝑥log𝜌𝑡. Why are we introducing time as a parameter? The point of diffusion models is to learn a function which can learn to denoise a process and thus learn to sample the underlying distribution well. SMLD does this by training a model to learn the score function in the reverse Langevin process for a given noise schedule. In more detail:
- Take some noise schedule 𝛽(𝑡) :[0,∞) →[0,∞) such that ∫∞0𝛽(𝑡) =∞ (this is to ensure the distribution gets fully noised).
- Evolve my data sample 𝑥𝑡 ∼𝜌𝑡 according to 𝑑𝑥𝑡 = −12𝛽(𝑡)𝑥𝑡𝑑𝑡 +√𝛽(𝑡)𝑑𝑊𝑡, which is just Langevin dynamics (and 𝑑𝑊𝑡 is the Brownian motion contributor). This has a corresponding evolution over the distributions given by 𝜕𝑡𝜌𝑡 =12𝛽(𝑡)(∇⋅(𝑥𝜌𝑡)+Δ𝜌𝑡) (straightforward from Fokker-Planck).
- Fix a time 𝑇 >0. The reverse time-evolution process can be exactly characterized by 𝑑ˆ𝑥𝑡=12𝛽(𝑇−𝑡)ˆ𝑥𝑡𝑑𝑡+𝛽(𝑇−𝑡)∇ˆ𝑥𝑡log𝜌𝑇−𝑡(ˆ𝑥𝑡)𝑑𝑡+√𝛽(𝑇−𝑡)𝑑𝑊𝑡, and ∇ˆ𝑥𝑡log𝜌𝑇−𝑡(ˆ𝑥𝑡) is exactly what we’re trying to approximate with 𝑓𝜃(ˆ𝑥,𝑇 −𝑡).
- So, if I sample ˆ𝑥𝑡 ∼N(0,𝐼𝑑) (pure noise!), by solving the reversed SDE above and substituting 𝑓𝜃 for the score function, I can approximate my underlying data distribution.
TC0 circuit families are (essentially) neural networks
Circuit complexity classes describe “families of boolean circuits.” A “family of boolean circuits” is just the set of all possible boolean circuits satisfying some properties; a boolean circuit is (abstractly) some DAG of “gates” (boolean functions) that takes a series of Boolean inputs to a Boolean output. TC0 in particular satisfies:
- polynomial width: the number of gates at each depth, is upper-bounded by a polynomial in the input-size 𝑛,
- constant depth: the maximum number of gates from input to output is upper-bounded by some constant,
- unbounded fan-in: each gate can receive inputs from arbitrarily many other gates,
- each gate is either AND< OR, NOT, or MAJ (for “majority”, returns True when half or more arguments are True and False otherwise).
You can use MAJ gates to simulate threshold gates.. As such, this last bullet point is equivalent to:
- each gate is a threshold gate: step(∑𝑖𝑤𝑖𝑥𝑖 +𝑡), where 𝑤𝑖,𝑡 are real numbers and step returns 1 if the value is greater than 1/2 and 0 otherwise.
This is a feed-forward neural network, where each gate is an activation function acting on Boolean inputs. TC0 is the class of neural networks with width <𝑝(𝑛) and depth ≤𝐷. Circuit complexity classes in general are somewhat pathological, and can solve sets of problems that one might not expect to be easily grouped together. But this is quite interestingly natural for ML purposes.
proof of the result
Theorem. Take a TC0 family of score-networks 𝑓𝜃,0,𝑓𝜃,1,… such that for each 𝑛 and each 𝑥1,…,𝑥𝑛 the function 𝑓𝜃,𝑛(𝑥,𝑡|𝑥1,…,𝑥𝑛) exactly computes the score function of some initial distribution 𝜌0,𝑛 with bounded first moment. If this family solves a prefix language modeling problem in the SMLD infinite time limit with a constant probability bound, then the problem is in TC0.
What is a “prefix language modeling problem”? Next-token prediction: given 𝑛 previous tokens in an alphabet, predict token 𝑛 +1. This is solved by a circuit complexity class if a family of circuits 𝐶𝑖 for every input size satisfying the complexity class solves the problem.
The proof relies on a result from the literature given in O(d/T) Convergence Theory for Diffusion Probabilistic Models under Minimal Assumptions which states that there exists some universal constant 𝑐 >0 such that 𝑇𝑉(𝑝𝑋,𝑝𝑌)≤𝑐𝑑log3𝑇𝑇+𝑐𝜖𝑠𝑐𝑜𝑟𝑒√log𝑇. Here 𝑇𝑉 is the total variation distance, 𝑋 is the data distribution, and 𝑌 is a distribution generated by DDPM denoising (essentially just a discretization of SMLD). One can use this to upper bound the total variation distance between the DDPM sampler and our denoising process by some constant 𝜖′, and setting our constant probability bound of finding a solution to 𝜖 we find that 𝜖′ =𝜖/2 is enough for our denoising process to solve the problem. This is then derandomized by a construction given in Threshold circuits of bounded depth, which reconstructs a TC0 class.
One may wonder where we require “perfect” score matching! Well, the 𝑐𝜖𝑠𝑐𝑜𝑟𝑒√log𝑇 term increases with 𝑇, so for this proof to work completely cleanly one requires 𝜖𝑠𝑐𝑜𝑟𝑒 to be set to 0. Practical diffusion networks are not like this — there will always be some error.