Apple's NFM Beats Its Own Teacher, Generating Images 145x Faster
Apple researchers show that distilling a normalizing flow teacher into a flow matching student beats both models — with up to 145x faster inference
ProTakeaways
- NFM (Normalized Flow Matching) uses a pretrained TarFlow normalizing flow as a teacher to generate better noise-image pairings for training flow matching student models.
- The student model achieves FID 1.78 vs 2.57 (FM baseline) on ImageNet64 at 31 steps, and dramatically outperforms at low step counts (FID 3.23 vs 13.01 at 7 steps).
- The NFM student is up to 145x faster than the TarFlow teacher at inference while also beating the teacher's FID — a student surpassing its teacher.
- The key mechanism: the NF teacher provides near-deterministic, data-specific noise pairings that reduce trajectory curvature by ~2x, making the FM regression task much easier.
- The method requires training a TarFlow teacher first, which is expensive; it is most useful when NF training is already planned for density estimation tasks.
- Code is open-sourced at github.com/apple/ml-nfm; paper accepted to ICML.
Flow matching has become the dominant training recipe for large-scale image generators , the backbone of systems like Stable Diffusion 3 and many others. But there is a quiet design choice buried inside every flow matching run that turns out to matter enormously: how you pair noise vectors with training images. A new paper from Apple, "The Coupling Within: Flow Matching via Distilled Normalizing Flows", proposes a surprisingly elegant answer , steal the pairing from a completely different type of model.
The pairing problem at the heart of flow matching
To understand the contribution, you need to understand what a "coupling" is in this context. Flow matching (FM) trains a neural network to learn a velocity field that gradually transports random Gaussian noise into real images. At training time, the model is shown pairs of (noise, image) and learns to interpolate between them. The question is: which noise vector should be paired with which image?
The default answer is the simplest one: pick them independently at random. But when training uses the default independent coupling, the implied trajectories can exhibit substantial crossings and curvature, which increases integration difficulty. More curvature means you need more denoising steps at inference to get a good image , which means slower generation.
The research community has been attacking this problem with optimal transport (OT) , a mathematical framework for finding the most efficient way to move mass from one distribution to another. In flow matching, OT offers principled pairings between source and target points, constructing minimal-cost transport maps that lead to shorter, straighter paths with improved sampling efficiency. Straighter paths mean fewer integration steps, which means faster inference. But computing the OT coupling in high dimensions is intractable, and existing methods attempt to solve the OT problem at the cost of persistent bias or significant overhead.
A teacher that already knows the answer
The Apple team's insight is that there is a class of models that already solves the noise-to-image pairing problem by construction: normalizing flows (NFs). Unlike flow matching models, normalizing flows do not suffer from any ambiguity when it comes to coupling noise to data: they learn, by construction, a bijection between the data and a Gaussian noise source, and rely on the maximum likelihood principle to fit that bijection. Feed an image in, get a unique noise vector out. The mapping is exact and invertible.
The catch is that normalizing flows have historically been slow to sample from. The specific architecture used here, TarFlow (Transformer AutoRegressive Flow), is Apple's own recent work that revived the NF paradigm. TarFlow is a simple and scalable architecture that enables highly performant NF models. It can be thought of as a Transformer-based variant of Masked Autoregressive Flows: it consists of a stack of autoregressive Transformer blocks on image patches, alternating the autoregression direction between layers. The autoregressive nature means it generates patches sequentially , accurate, but slow.

NFM: distill the coupling, not the model
The method, called Normalized Flow Matching (NFM), is conceptually clean. Instead of training a flow matching model with randomly paired noise, you first run your training images through a frozen TarFlow teacher to get their corresponding noise representations. Then you use those teacher-assigned noise vectors as the coupling for flow matching training. The student model can be any architecture , it does not need to be invertible.
Here is the core substitution in practice:
# Standard FM: random noise paired with image
epsilon = torch.randn_like(x) # random Gaussian
# NFM: teacher-assigned noise paired with image
with torch.no_grad():
z = tarflow_teacher(x + eta * torch.randn_like(x), class_label)
z = z / sigma_f # normalize to unit variance
# Then train FM student on (x, z) pairs instead of (x, epsilon)
x_t = (1 - t) * x + t * z
loss = (student(x_t, class_label, t) - (z - x)).pow(2).mean()
This substitution does not change the flow matching objective: for a fixed noise schedule, FM remains the same weighted regression of a vector field along the linear interpolant. The only change is replacing the endpoint coupling (x, epsilon) with (x, z) where z is normalized to be approximately Gaussian marginally.
Why does this help? Two reasons. First, the teacher-induced coupling dramatically reduces what the paper calls conditional velocity variance , the spread of possible directions the model needs to predict at any given point along the trajectory. Lower variance means more stable training and straighter paths. Second, for ImageNet64, TarFlow uses eta=0.05 resulting in a maximum flow matching noise level of 0.0476 in NFM, while the original flow matching maximum noise is 1.0000, potentially making the inference path straighter.
Numbers that are hard to ignore
The experiments run on ImageNet at 64x64 and 256x256 resolution, using FID (Fréchet Inception Distance , lower is better) as the quality metric. The results show consistent, large gains across all inference budgets:
| Method | NFE (steps) | FID (ImageNet64, 256M samples) |
|---|---|---|
| FM (baseline) | 31 | 2.57 |
| SD-FM (OT coupling) | 31 | 2.68 |
| NFM (ours) | 31 | 1.78 |
| FM (baseline) | 7 | 13.01 |
| SD-FM (OT coupling) | 7 | 6.41 |
| NFM (ours) | 7 | 3.23 |
The gains are most dramatic at low step counts, which is exactly where it matters most for deployment. The student outperforms the teacher's FID while also achieving a 32x faster latency. At 7 NFE (function evaluations), the speedup over the TarFlow teacher reaches 145x , going from 10.8 seconds per batch to 0.074 seconds , while still producing better images.
The paper also measures trajectory curvature directly. For each solver and schedule, NFM produces significantly straighter paths than FM and SD-FM. With a Heun solver at 31 NFE, NFM's curvature score is 0.0435 versus 0.0864 for vanilla FM , a 2x reduction.
The surprising geometry of the teacher's noise space
One of the more interesting findings is about the structure of the noise vectors the NF teacher produces. You might assume that nearby images map to nearby noise vectors , that the teacher preserves neighborhood structure. Surprisingly the answer is no, at least in the case of TarFlow. In fact, the paper shows that different noise realizations of the same image end up farther apart in noise space than representations of different images under the same noise. The many copies of one image are not its nearest neighbors in z-space.
This is counterintuitive, and the authors admit they do not fully understand it. But despite this scrambled geometry, the coupling still works , and works well. This suggests the gains come not from preserving local structure, but from the deterministic, data-dependent assignment itself reducing the ambiguity the student model has to resolve.
What it is and is not good for
NFM is most compelling when:
- You already have or plan to train a normalizing flow model for density estimation or likelihood tasks , the teacher training cost is then "free" from a workflow perspective
- You need fast few-step inference (the gains are largest at 3-7 NFE)
- You are working in a class-conditional image generation setting
- You want a student model that is architecture-agnostic , any FM model can be the student
The main limitation is upfront cost. Training TarFlow is considerably more costly than solving a semi-discrete optimal transport problem as in SD-FM, and furthermore vanilla FM does not even need to learn a coupling in the first place before training. The teacher needs to be trained to convergence before distillation can begin. The paper also notes that the student quality correlates with the teacher's negative log-likelihood score , a weaker teacher produces a weaker student.
The real unlock: NFs as reusable noise encoders
The deeper implication the authors flag is architectural. They draw an analogy to autoencoders (AEs): just as pretrained VAEs are routinely reused as image encoders for latent diffusion models, pretrained normalizing flow models could become reusable "noise encoders" , foundation models that map data to Gaussian representations and can be plugged into any flow matching training pipeline. Such pretrained NF models could be reused, just like pretrained AEs are currently reused for various tasks. This is an exciting avenue for future work.
The code for NFM is available at github.com/apple/ml-nfm, and the TarFlow teacher code is at github.com/apple/ml-tarflow. The paper is accepted to ICML.
The broader takeaway is that the coupling choice in flow matching is not a minor implementation detail , it is one of the highest-leverage decisions in the entire training pipeline. NFM shows that a learned, data-informed bijection from a normalizing flow can outperform both random and OT-based couplings, and that the student trained on these better pairs can surpass its own teacher. That last result , a distilled model beating the model it was distilled from , is the kind of outcome that tends to open new research directions.