Sam Babichenko

Reading notes / Dataset distillation

Kernel dataset distillation

Nguyen et al., 2021; Zhou et al., 2022

Sets and labels
T,\mathcal T, S\mathcal Sreal training set (a batch of it per step), distilled set
∣S∣|\mathcal S|number of distilled images
yT,y_{\mathcal T}, ySy_{\mathcal S}label matrices, one row per image, one column per class
y^T\hat y_{\mathcal T}predictions on the real images of the model trained on S\mathcal S
yS⋆y_{\mathcal S}^\starlabels solved in closed form (Label Solve)
Kernel regression
K,K, ϕ\phikernel and its feature map, K(x,x′)=ϕ(x)⊤ϕ(x′)K(x,x')=\phi(x)^\top\phi(x')
ΦT,\Phi_{\mathcal T}, ΦS\Phi_{\mathcal S}features of the real and the distilled images, one row per image
KTS,K_{\mathcal T\mathcal S}, KSSK_{\mathcal S\mathcal S}kernel matrices between real and distilled, and among distilled images
λ\lambdaridge penalty, 10−6tr⁡KSS10^{-6}\operatorname{tr}K_{\mathcal S\mathcal S}
w⋆w^\starridge weights fitted on S\mathcal S
Networks
fθ,f_\theta, θ0\theta_0network output with weights θ\theta; random initial weights
Θ\Thetaneural tangent kernel of the architecture
ΘxS,\Theta_{x\mathcal S}, ΘSS\Theta_{\mathcal S\mathcal S}NTK values between xx and the distilled images, and among them
f0,f_0, f∞f_\inftyoutput at initialization and after training to convergence
ddpixel positions per image
ϕθ,\phi_\theta, KθK^\thetalast-hidden-layer features of a finite network, and their kernel (FRePo)
Paper symbols
T,\mathcal T, S\mathcal SKIP writes (Xt,yt)(X_t,y_t) and (Xs,ys)(X_s,y_s), the target and support sets
KTSK_{\mathcal T\mathcal S}KIP writes KXtXsK_{X_tX_s}, FRePo KXtXsθK^\theta_{X_tX_s}
ϕθ\phi_\thetaFRePo writes f(X,θ)f(X,\theta)

Context. learning a few synthetic training images per class, often 1 to 50, that train a network from scratch nearly as well as the full real training set. Reading note: Dataset distillation seeks a small synthetic set that trains a network to score well on real data. Because that real-data score depends on the distilled images only through the inner training run, direct optimization has to differentiate through training. Matching methods keep ordinary training and replace the objective; (Cazenavette et al., 2022) start a network at a saved checkpoint of a real-data run, train it a few steps on the synthetic images, and minimize its distance to a later checkpoint. Reading note: Matching training trajectories, for instance, scores how closely a short synthetic run tracks a real-data run. Kernel methods keep the real-data objective and replace the inner learner. ridge regression in the feature space of a kernel K(x,x′)=ϕ(x)⊤ϕ(x′)K(x,x')=\phi(x)^\top\phi(x'); its fit and its predictions are explicit matrix formulas in the training points trains in closed form. An infinitely wide network trained by gradient descent behaves as kernel regression with its NTK: Θ(x,x′)=∇θfθ0(x)⊤∇θfθ0(x′)\Theta(x,x')=\nabla_\theta f_{\theta_0}(x)^\top\nabla_\theta f_{\theta_0}(x'), the inner product of the output's parameter gradients at the random initial weights θ0\theta_0, with fθ(x)f_\theta(x) the output of the network with weights θ\theta; at infinite width it is the same for every initialization and stays fixed during training. Reading note: The neural tangent kernel. Nguyen et al. (2021) turned this correspondence into KIP (kernel inducing points), first with fully connected kernels and then with convolutional kernels in a second paper that year. Zhou et al. (2022) replaced the infinite-width kernel with finite-network features in FRePo (neural feature regression with pooling).

Kernel ridge regression turns the trained model's real-data predictions into an explicit formula in the distilled images. Gradient descent then optimizes the pixels and labels directly, with no inner run to unroll. Under a small ConvNet NTK, kernel regression on one KIP image per class of CIFAR-10 matches 128 random real images per class. The sets also transfer to finite networks. On a 128-channel ConvNet, the width most distillation papers evaluate with, 10 KIP images per class of CIFAR-10 reach 57.6% test accuracy (Cazenavette et al., 2022). At that budget in their benchmark, random real images reach 26.0%, gradient matching with augmentation reaches 52.1%, and trajectory matching reaches 65.3%. Convolutional NTKs are expensive to compute. KIP's released sets took thousands of GPU-hours and never went past 32 × 32 images. FRePo keeps the closed-form loss but substitutes the last-layer features of a pool of small networks trained alongside the images. On CIFAR-100 at one image per class, it came within a point of trajectory matching in a hundredth of the time. That speedup opened up 128 × 128 images and 64 × 64 ImageNet-1k. Its headline numbers rely on a wider network than the field's standard. On many-class benchmarks they also rely on learned labels, which carry most of its ImageNet-1k accuracy.

Setting and kernel ridge regression. Let the real training set; in practice each step uses a random batch of it, 5,000 images in the convolutional KIP runs and 1,024 in FRePo be the real training set and the distilled set, a few images per class whose pixels are optimized, with ∣S∣|\mathcal S| the number of images the distilled set. Stack their labels as rows in the labels of the real and the distilled images; each row is a mean-centered one-hot vector, or for S\mathcal S a learned row, posing classification as regression on one-hot vectors with 1/C1/C subtracted from every entry, CC the number of classes. Write the kernel as K(x,x′)=ϕ(x)⊤ϕ(x′)K(x,x')=\phi(x)^\top\phi(x') for a a map from an image to a vector, possibly infinite-dimensional, whose inner products give the kernel; for the NTK it is the gradient ∇θfθ0(x)\nabla_\theta f_{\theta_0}(x). Stack the features of S\mathcal S and T\mathcal T as rows of the matrix whose rows are ϕ(x)⊤\phi(x)^\top for the distilled images x∈Sx\in\mathcal S; ΦT\Phi_{\mathcal T} does the same for the real images and ΦT\Phi_{\mathcal T}, so the kernel matrices are KSSK_{\mathcal S\mathcal S}=ΦSΦS⊤{}=\Phi_{\mathcal S}\Phi_{\mathcal S}^\top and KTSK_{\mathcal T\mathcal S}=ΦTΦS⊤{}=\Phi_{\mathcal T}\Phi_{\mathcal S}^\top. A linear model fitted on S\mathcal S with the ridge penalty; the convolutional KIP paper and FRePo scale it to the kernel, λ=10−6tr⁡KSS\lambda=10^{-6}\operatorname{tr}K_{\mathcal S\mathcal S} solves min⁡w∥yS−ΦSw∥2+λ∥w∥2\min_w\|y_{\mathcal S}-\Phi_{\mathcal S}w\|^2+\lambda\|w\|^2. Because ϕ\phi can be infinite-dimensional, the (A⊤A+λI)−1A⊤=A⊤(AA⊤+λI)−1(A^\top A+\lambda I)^{-1}A^\top=A^\top(AA^\top+\lambda I)^{-1} for any matrix AA and λ>0\lambda\gt 0; multiply both sides by A⊤A+λIA^\top A+\lambda I on the left and AA⊤+λIAA^\top+\lambda I on the right to check moves the inverse to the ∣S∣×∣S∣|\mathcal S|\times|\mathcal S| sample matrix. Multiplying the fitted weights w⋆w^\star by ΦT\Phi_{\mathcal T} gives the real-set predictions y^T\hat y_{\mathcal T}:w⋆=(ΦS⊤ΦS+λI)−1ΦS⊤yS=ΦS⊤(KSS+λI)−1yS,y^T=ΦTw⋆=KTS(KSS+λI)−1yS.\begin{aligned}w^\star&=(\Phi_{\mathcal S}^\top\Phi_{\mathcal S}+\lambda I)^{-1}\Phi_{\mathcal S}^\top y_{\mathcal S}\\&=\Phi_{\mathcal S}^\top(K_{\mathcal S\mathcal S}+\lambda I)^{-1}y_{\mathcal S},\\\hat y_{\mathcal T}&=\Phi_{\mathcal T}w^\star\\&=K_{\mathcal T\mathcal S}(K_{\mathcal S\mathcal S}+\lambda I)^{-1}y_{\mathcal S}.\end{aligned}

KIP's single-level objective and Label Solve. KIP minimizes the squared prediction error of y^T\hat y_{\mathcal T} on the real data over the distilled images and, optionally, their labels:min⁡S, yS 12∥yT−y^T∥2.\min_{\mathcal S,\,y_{\mathcal S}}\ \tfrac12\|y_{\mathcal T}-\hat y_{\mathcal T}\|^2.The bilevel problem collapses to a single level, since the loss depends on the pixels only through KTSK_{\mathcal T\mathcal S} and KSSK_{\mathcal S\mathcal S}. Gradients with respect to those two matrices need only linear solves against the ∣S∣×∣S∣|\mathcal S|\times|\mathcal S| matrix KSS+λIK_{\mathcal S\mathcal S}+\lambda I. Backpropagation then pushes those gradients through the kernel function into the pixels, with no training run to unroll. For fixed images, y^T\hat y_{\mathcal T} is linear in ySy_{\mathcal S}, so the loss is quadratic in ySy_{\mathcal S}. Its minimum-norm minimizer has a closed form, called Label Solve:yS⋆=(KTS(KSS+λI)−1)+yT,y_{\mathcal S}^\star=\big(K_{\mathcal T\mathcal S}(K_{\mathcal S\mathcal S}+\lambda I)^{-1}\big)^+y_{\mathcal T},where +^+ denotes the pseudoinverse.

When kernel regression matches a trained network. Kernel regression equals a trained neural network only in an idealized limit, and only on average over initializations. Put a network fθf_\theta in the each layer's weights drawn with unit variance and multiplied by 1/fan-in1/\sqrt{\text{fan-in}} in the forward pass, so that the kernel has a finite limit as the width grows (Jacot et al., 2018) and send its width to infinity. Train all weights on S\mathcal S under the why: the infinitely wide network trains as its linearization, a linear model in the features ∇θfθ0(x)\nabla_\theta f_{\theta_0}(x), and least squares on a linear model has a closed-form solution; with cross-entropy the trained linear model has no closed form by gradient flow, or by gradient descent with a small enough step. In that limit the network stays equal to its linearization around the random initial weights θ0\theta_0. At convergence, its prediction at xx is (Lee et al., 2019)f∞(x)=f0(x)+ΘxSΘSS−1×(yS−f0(S)),Eθ0f∞(x)=ΘxSΘSS−1yS.\begin{aligned}f_\infty(x)&=f_0(x)+\Theta_{x\mathcal S}\Theta_{\mathcal S\mathcal S}^{-1}\\&\quad\times\big(y_{\mathcal S}-f_0(\mathcal S)\big),\\\mathbb E_{\theta_0}f_\infty(x)&=\Theta_{x\mathcal S}\Theta_{\mathcal S\mathcal S}^{-1}y_{\mathcal S}.\end{aligned}Here the output of the network at its random initial weights θ0\theta_0; f0(S)f_0(\mathcal S) stacks it over the distilled images, and it has mean zero over the initialization is the zero-mean output at initialization, while the row of NTK values Θ(x,x′)\Theta(x,x') between the image xx and each distilled image x′x'; ΘSS\Theta_{\mathcal S\mathcal S} is the NTK matrix among the distilled images and ΘSS\Theta_{\mathcal S\mathcal S} hold the NTK values from xx to S\mathcal S and within S\mathcal S. Because Θ\Theta is deterministic in this limit, the same for every initialization, only the f0f_0 terms are random. Averaging over θ0\theta_0 cancels them, though any single trained network still differs from the mean by a random term. Setting K=ΘK=\Theta in KIP recovers this mean predictor at λ=0\lambda=0, and KIP keeps λ\lambda tiny in practice. Using the neural network Gaussian process kernel: K(x,x′)=Eθ0fθ0(x)fθ0(x′)K(x,x')=\mathbb E_{\theta_0}f_{\theta_0}(x)f_{\theta_0}(x'), the covariance of an infinitely wide network's outputs at random initialization instead gives the Bayesian posterior mean of the infinitely wide network, with λ\lambda as the observation noise variance. A finite network does not stay linear. Its kernel moves during training, so sets distilled in the limit must be tested on finite networks.

How KIP runs in practice. KIP initializes S\mathcal S as a class-balanced random subset of real images and updates the pixels, and optionally ySy_{\mathcal S}, with Adam. At each step it draws a real batch, forms KTSK_{\mathcal T\mathcal S} and KSSK_{\mathcal S\mathcal S}, and backpropagates the squared error into the distilled pixels. The first KIP paper used cheap kernels, those of shallow fully connected networks and an RBF kernel. Each entry depends on two images only through the dot products x⊤x′x^\top x', x⊤xx^\top x, and x′⊤x′x'^\top x'. A one-hidden-layer network trained on 100 KIP images of CIFAR-10 reached 45.7%, against 44.9% for gradient matching on a ConvNet. The second paper switched to the NTK of a 4-layer ConvNet with average pooling. That architecture has an extra input convolutional layer relative to the 3-layer ConvNet of earlier matching papers, and drops instance normalization, which the infinite-width limit excludes.

Why convolutional kernels are expensive. Convolutional NTKs are slow because each kernel entry tracks correlations across all pairs of spatial positions. With the number of pixel positions of an image, height times width; 1,024 for 32 × 32 images pixel positions per image, each convolutional layer costs O(d)O(d) per kernel entry and global pooling costs O(d2)O(d^2). On a V100 GPU, an 18 × 18 block of ConvNet kernel entries takes 80 ms. One step with 100 distilled images against 5,000 real images therefore takes about 120 GPU-seconds for the kernel matrices alone and 460 GPU-seconds with gradients. The authors distributed blocks across hundreds of GPUs and report thousands of GPU-hours for the released sets. Doubling resolution from 32 × 32 to 64 × 64 multiplies the pooling cost alone by 16 (computed here from the d2d^2 scaling). Every KIP result stays at 32 × 32 or smaller.

Kernel accuracy versus finite-network transfer. Under the kernel itself with the linear map x↦(C+εI)−1/2xx\mapsto(C+\varepsilon I)^{-1/2}x, with CC the covariance of the training images' pixels and ε\varepsilon a regularizer, which flattens the pixel spectrum; the convolutional KIP paper calls it a crucial ingredient for its color-image results, KIP sets punch far above their size. On CIFAR-10, one fixed-label KIP image per class reaches 58.5%, against 58.1% for 128 random real images per class. Learning the labels raises that kernel accuracy to 64.7%. Finite networks lose part of that advantage, and on CIFAR-10 the learned-label gain does not carry over. At 10 images per class, learned labels lift kernel accuracy from 67.6% to 75.6% but drop a 1,024-channel ConvNet from 62.7% to 58.9%. The best CIFAR-10 transfers therefore keep labels fixed. On CIFAR-100, the best finite-network transfers sit 17 to 18 points below the kernel. As the linearization predicts, wider networks narrow the gap, and KIP's strongest transfers use 1,024 channels per layer with no normalization. Cazenavette et al.'s 128-channel re-run above lands 5 points below KIP's 1,024-channel number, even after searching over checkpoints, weight decay, augmentation, whitening, label learning, and instance normalization. Without ZCA whitening, 10-image-per-class transfer drops to 49.2%.

FRePo: replacing the NTK with finite-network features. FRePo keeps KIP's closed-form loss while replacing the expensive infinite-width kernel with features from a finite ConvNet. Split the network into a body with weights θ\theta and a linear readout, and write the last hidden layer's activations for image xx in a finite network with weights θ\theta, a vector of fixed length for the last hidden layer's features. Fitting only the readout on S\mathcal S by ridge regression repeats the derivation above with ϕ=ϕθ\phi=\phi_\theta. The readout predicts KTSθ(KSSθ+λI)−1ySK^\theta_{\mathcal T\mathcal S}(K^\theta_{\mathcal S\mathcal S}+\lambda I)^{-1}y_{\mathcal S} on the real batch, using the finite-network Kθ(x,x′)=ϕθ(x)⊤ϕθ(x′)K^\theta(x,x')=\phi_\theta(x)^\top\phi_\theta(x'), the kernel of a network's last hidden layer, here of a finite network in the middle of training KθK^\theta. FRePo scores those predictions with the same squared loss. The gradient into the distilled pixels takes one backward pass through the body with θ\theta held fixed.

The network pool and what FRePo's gradient omits. To avoid overfitting a single random initialization, FRePo draws θ\theta from a pool of ten networks. Each step samples one network, evaluates the closed-form loss on a real batch, updates the distilled images and labels, and trains that network for one step on the current distilled set. Each network resets after 100 of its own updates. The pool supplies features across initializations and training stages, beating a single periodically reset network. Because θ\theta is frozen during differentiation, FRePo's gradient omits how the distilled images shape the body's features during training. Zhou et al. liken the scheme to one-step truncated backpropagation through training, with the last layer solved in closed form in place of a gradient step. No derivation guarantees that images good for fitting the readout on given features also train the whole network well. The paper rests that premise on experiment.

Speed, larger images, and cross-architecture transfer. On the 128-channel ConvNet, one FRePo step takes 10.9 ms and 0.39 GB of GPU memory. On the same GPU and architecture, one trajectory-matching step unrolled over 15 inner steps takes 486 ms and 4.9 GB. On CIFAR-100 at one image per class, FRePo reached 23.4% in 38 seconds, while trajectory matching needed 3,805 seconds to reach 24.0%. That speed made higher-resolution datasets practical. On ten dog breeds from ImageNet, here at 128 × 128, built to be hard to tell apart; its companion ImageNette has ten easily separated classes at 128 × 128 and 10 images per class, FRePo reaches 42.2%, against 35.8% for trajectory matching and 27.0% for random real images. FRePo sets also transfer across architectures better than matching methods and KIP. At 10 CIFAR-10 images per class, a VGG network with batch normalization reaches 59.4% on FRePo's set, against 46.6% on trajectory matching's and 30.1% on KIP's. KIP's set fares much better on networks without normalization than on VGG with batch normalization. Zhou et al. suggest that matching methods transfer worse because of the normalizing each channel of each image's activations to zero mean and unit variance over the spatial positions they train with.

The wide-network requirement and scaling cost. Zhou et al. note that kernel regression on ϕθ\phi_\theta needs a feature dimension much larger than ∣S∣|\mathcal S|, so FRePo doubles the channel count at each downsampling layer. They also train the network pool with batch normalization and evaluate without normalization. With that wider architecture, FRePo matches trajectory matching on CIFAR-10 at 10 images per class (65.5% against 65.3%). On CIFAR-100 it leads at one image per class (28.7% against 24.3%) and trails at 50 (44.3% against 47.7%). When distilled with the 128-channel instance-norm ConvNet used by trajectory matching, FRePo trails at 10 images per class on both CIFAR-10 (59.6% against 65.3%) and CIFAR-100 (31.2% against 40.1%). Step time also grows with the distilled set size, because each step passes all of S\mathcal S through the body and solves an ∣S∣×∣S∣|\mathcal S|\times|\mathcal S| linear system. One step takes 11 ms at 100 images and 123 ms at 6,400, making tens of thousands of distilled images difficult.

Learned labels carry most of FRePo's gain on many classes. FRePo jointly learns the distilled labels and trains the evaluation network with squared loss on them. On CIFAR-10 at 10 images per class, learned labels barely move accuracy (65.5% against 65.4% fixed). On CIFAR-100 at one image per class, they add 3.3 points (28.7% against 25.4%). On ImageNet-1k at one image per class, learned labels supply most of the score, lifting accuracy from 1.6% fixed to 7.5%. Under the same squared-loss training, random real images reach 1.1% and the full dataset reaches 19.8%. Learned labels are targets that give every class a probability; how much of distillation's progress they account for (Qin et al., 2024; Dey et al., 2026). Reading note: Soft labels in dataset distillation.

Consequences and limits. Kernel ridge regression collapses distillation into a single-level problem with an exact inner solve for the kernel model. For finite networks, every performance claim rests on transfer experiments. Transfer accuracy drops on mismatched architectures, and on CIFAR-10 it also drops as width shrinks or when labels are learned. Later comparisons of distilled sets with selected and random real images under the same labels and training. Reading note: Dataset distillation stressed comparisons against selected real subsets and against random real images given labels of the same kind. Neither paper includes a selected subset in its distillation benchmarks. KIP does run Label Solve on random real images, and its learned images beat that baseline. At 10 CIFAR-10 images per class, Label Solve on random real images reaches 53.6% under kernel regression, against 75.6% for KIP's learned images and labels. On a 1,024-channel ConvNet, the same comparison is 49.3% against 58.9%. FRePo omits this baseline, and both papers rely on ZCA whitening for color-image results.

Terms

Kernel distillation
Replace training on the distilled set by kernel ridge regression, whose trained predictions are a formula in the distilled images.
KIP loss
12∥yT−KTS(KSS+λI)−1yS∥2\tfrac12\|y_{\mathcal T}-K_{\mathcal T\mathcal S}(K_{\mathcal S\mathcal S}+\lambda I)^{-1}y_{\mathcal S}\|^2, minimized over the distilled images and optionally their labels.
Push-through
(Φ⊤Φ+λI)−1Φ⊤=Φ⊤(ΦΦ⊤+λI)−1(\Phi^\top\Phi+\lambda I)^{-1}\Phi^\top=\Phi^\top(\Phi\Phi^\top+\lambda I)^{-1}: ridge weights through an ∣S∣×∣S∣|\mathcal S|\times|\mathcal S| solve.
Label Solve
For fixed images the loss is quadratic in ySy_{\mathcal S}; the minimum-norm minimizer is (KTS(KSS+λI)−1)+yT(K_{\mathcal T\mathcal S}(K_{\mathcal S\mathcal S}+\lambda I)^{-1})^+y_{\mathcal T}.
Exactness
With the NTK and λ=0\lambda=0, the predictor is the mean over initializations of an infinitely wide network in the NTK parametrization, trained to convergence by gradient flow on the squared loss.
KIP cost
Convolutional kernel entries and their gradients; about 460 GPU-seconds per step for 100 images, thousands of GPU-hours, 32 × 32 only.
Transfer
57.6% on the 128-channel ConvNet at 10 images per class of CIFAR-10, against 26.0% random real and 65.3% trajectory matching; on CIFAR-10 learned labels transfer worse than fixed.
FRePo
Same loss with the last-hidden-layer kernel of finite networks from a pool of ten, each trained on the distilled set and reset after 100 steps.
FRePo's costs
Needs features much wider than the set; trails trajectory matching on the standard ConvNet; on ImageNet-1k most of its gain is learned labels.

Sources

Connected notes

  • Any model becomes lazy, its tangent kernel effectively frozen, when its output scale grows and its initial output is cancelled; for a width-nn network a 1/n1/\sqrt n output normalization is lazy in the limit and the mean-field 1/n1/n is not.

  • Random features with no linear part have a covariance within (log⁡n)C(\log n)^C of the identity in Frobenius norm, so their limiting risk is that of an isotropic linear model.

  • One first-layer gradient step of order one leaves the features equivalent to a linear model plus Gaussian noise, so the error cannot fall below the target's nonlinear part, while a step of order N\sqrt N moves each neuron along the target and, when 10τ∗<μ2∗210\tau^*\lt\mu_2^{*2} (Theorem 11), beats every kernel with n≍dn\asymp d samples.

  • A parametrization is feature-learning when the hidden features change by order one during training, and the initialization, the output multiplier and the learning rate must scale with width to get that change. For Adam with updates fully aligned to their inputs, the hidden-matrix learning rate falls like 1/width and so does the readout's multiplier.

Threads