Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

RBIG warm start for coupling flows

What fit_rbig_coupling hands to a coupling flow, and what it is worth on held-out data once both starts get the same budget

05 · RBIG warm start for coupling flows

Open In Colab

Part 4 started a diagonal flow from a greedy RBIG fit and found that the start buys time but, with a fair learning rate, not a better model on held-out data. fit_rbig_coupling does the same for a coupling flow. Its warm start is often credited to the conditioners’ zero readout, which makes each coupling a diagonal marginal map at the start. Since notebook 00 we know that every coupling in gauss_flows starts with a zero readout, so the readout is not what the warm start adds. The warm-start example shows the coupling warm start’s likelihood, pushforward and samples before training; here we ask what it adds, and what that is worth on held-out data.

Python implementation: CPython
Python version       : 3.13.12
IPython version      : 9.12.0

jax               : 0.12.1
numpy             : 2.4.3
optax             : 0.2.8
flowjax           : 19.1.0
pipekit_train     : 0.3.4
gauss_flows_models: 0.3.1

Compiler    : Clang 21.1.4 
OS          : Linux
Release     : 6.8.0-1044-azure
Machine     : x86_64
Processor   : x86_64
CPU cores   : 16
Architecture: 64bit

The data are those of Part 4: two moons with noise of standard deviation 0.08, standardised, split into Nt=3000N_t = 3000 training rows and Nv=1000N_v = 1000 held-out rows. The notebook runs in float32, the precision fit_rbig_coupling works in.

1. What the warm start hands over

fit_rbig_coupling builds K=4K = 4 layers, each a PCA frame (3) followed by two MixtureGaussianCDFCoupling layers with a flip after each, so that each coordinate is active once per layer. Each conditioner is an MLP of width 64 and depth 2, and the greedy fit sets the bias of its last layer to the 8-component mixture that EM fits to the active coordinate, as fit_rbig fits its marginals. Like fit_rbig, it also builds a trainable base (gauss_flows#256), which we swap for a fixed N(0,I)\mathcal{N}(\vect{0}, \mat{I}); the base starts there, so the swap changes no density.

['FixedRotation', 'MixtureGaussianCDFCoupling', 'Flip', 'MixtureGaussianCDFCoupling', 'Flip'] ... 20 blocks

For comparison we keep the warm start’s frames and flips and put a fresh coupling of the same size in place of each fitted one. A fresh coupling is the identity (notebook 00), so this fresh start is the PCA frames alone. Part 4 found that frozen frames alone are worth almost nothing before training and neither help nor harm after it, so it differs from the warm start in what matters only by what the couplings hold.

The fresh start cannot be trained as it is. Its zero readout gives all eight mixture components of a coupling the same parameters, so every component gets the same gradient and they stay identical through training, and the coupling trains as an affine one (gauss_flows#265). We break the symmetry as notebook 00 does, moving every weight of each fresh coupling by a normal draw of standard deviation 0.1, and call the result the cold start. The nudge moves the readout weight off zero too, so the cold start is neither the identity nor a marginal map.

warm: NLL 2.023 on training rows, 2.094 held out
fresh: NLL 2.839 on training rows, 2.834 held out
cold: NLL 5.606 on training rows, 5.634 held out

Before training, the warm start has a negative log-likelihood of 2.023 nats on the training rows and 2.094 held out. On the training rows that is the value of the diagonal flow that fit_rbig builds with four layers; held out the diagonal flow has 2.100, and notebook 06 traces the difference to three held-out rows. The fresh start has 2.839 and 2.834: a rotation followed by identities leaves standardised data where they are, and their negative log-likelihood under N(0,I)\mathcal{N}(\vect{0}, \mat{I}) is log⁡2π+1≈2.838\log 2\pi + 1 \approx 2.838 nats in two dimensions. The nudge costs the cold start almost three nats: its eight couplings, each moved a little off the identity, compound to 5.606 on the training rows and 5.634 held out.

2. The warm start is a marginal map

The last layer of a conditioner is affine: with v(xA)\vect{v}(\vect{x}_A) the output of the MLP’s last hidden layer, it returns

θ=Woutv(xA)+bout\theta = \mat{W}_{\mathrm{out}} \vect{v}(\vect{x}_A) + \vect{b}_{\mathrm{out}}

where Wout\mat{W}_{\mathrm{out}} has one row per parameter of the transformer and bout\vect{b}_{\mathrm{out}} is its bias. The warm and fresh starts have Wout=0\mat{W}_{\mathrm{out}} = \mat{0}: the fresh couplings by the default of gauss_flows, the warm ones because fit_rbig_coupling writes only the bias. Then θ=bout\theta = \vect{b}_{\mathrm{out}} for every xA\vect{x}_A, and the block of the coupling’s Jacobian below the diagonal (3), ∂zB/∂xA\partial z_B / \partial x_A, is zero. We check that from outside: one function runs the blocks of a flow in the density direction and, at each coupling, takes the median of ∣∂zB/∂xA∣\vert \partial z_B / \partial x_A \vert over a set of points.

warm: [0. 0. 0. 0. 0. 0. 0. 0.]
fresh: [0. 0. 0. 0. 0. 0. 0. 0.]
cold: [0.0492 0.1007 0.1204 0.1398 0.1192 0.1014 0.2727 0.0739]

Every cross-derivative of the warm and fresh starts is zero, so both are diagonal flows: each coupling is a marginal map on its active coordinate. What the warm start adds is in bout\vect{b}_{\mathrm{out}}, the EM mixtures; the fresh start’s bias gives eight copies of N(0,1)\mathcal{N}(0, 1), the identity. The nudged cold start has median cross-slopes of 0.05 to 0.27, so it starts as a weak coupling flow rather than a diagonal one. Notebook 06 checks that the warm start is the diagonal flow of fit_rbig, layer by layer.

3. The same budget at three learning rates

The training loop is that of Part 4: pipekit-train on the mean negative log-likelihood (1), Adam with gradients clipped to a global norm of 1 on a one-cycle cosine learning rate, 3,000 steps of 512 rows in 30 epochs, with the held-out loss after each epoch. The frozen PCA frames stay out of the optimiser.

We train the warm and cold starts at peak rates of 10-3, 3×10−33 \times 10^{-3} and 10-2. The six runs take about six minutes.

NLL after epoch 1 held out | after epoch 30 held out (training)
peak 1e-03: warm 1.861 | 1.887 (1.449)   cold 3.123 | 1.651 (1.540)
peak 3e-03: warm 1.718 | 2.173 (1.386)   cold 2.125 | 1.669 (1.534)
peak 1e-02: warm 1.693 | 1.981 (1.389)   cold 1.893 | 1.676 (1.530)
<Figure size 1300x440 with 2 Axes>

Figure 1:Left: the held-out negative log-likelihood per epoch of the warm start (orange) and the cold start (blue), at peak learning rates of 10⁻³ (dotted), 3 × 10⁻³ (dashed) and 10⁻² (solid). Right: the final training (dashed) and held-out (solid) negative log-likelihood against the peak learning rate.

The warm start leads early: after one epoch its held-out loss is 1.69 to 1.86 nats against the cold start’s 1.89 to 3.12, and the left panel shows it near its best within the first few epochs, a level the cold start reaches only around epoch 14. It does not stay there. From about epoch 14 the warm runs’ held-out loss climbs while their training loss keeps falling, and after 30 epochs they end at 1.887, 2.173 and 1.981 nats held out (at 10-3, 3×10−33 \times 10^{-3} and 10-2) with 1.39 to 1.45 on the training rows. The cold runs end at 1.651, 1.669 and 1.676 held out with 1.53 to 1.54 on the training rows. On the training rows the warm start is better at every rate; on held-out data it is worse by 0.24 to 0.50 nats at every rate. The warm start spends its head start on fitting the 3,000 training rows ever more closely, and the budget that is fair to the cold start is too long for it; Part 4’s diagonal warm start bought time but not a better held-out model, and the coupling warm start, with 46,804 parameters to the diagonal flow’s 212, pays for the same time with overfitting.

4. Training switches the conditioners on

We measure the cross-derivatives of the warm and cold starts again after training, at a peak rate of 10-3.

warm, trained: [0.055 0.052 0.056 0.055 0.068 0.107 0.157 0.166]
cold, trained: [0.118 0.299 0.489 0.14  0.396 0.366 0.738 0.286]

Training moves Wout\mat{W}_{\mathrm{out}} off zero in the warm start and further from it in the cold one, so neither is a marginal map. The warm start’s median cross-slopes stay small, from 0.052 to 0.166 and largest in the last two couplings, while the cold start’s grow from 0.05 to 0.27 before training to 0.12 to 0.74 after it. The warm conditioners barely leave the diagonal flow they started as; the cold ones, with nothing fitted to keep, use their copied coordinate far more.

Recap

PieceEquationIn code
the warm start(3), (2)fit_rbig_coupling, base swapped for StandardNormal((2,))
the conditioner’s readout(1)zero weight in every fresh coupling; fit_rbig_coupling writes the bias
a zero readout gives a marginal map(3)cross_slopes, from jax.jacfwd(block.transform)
breaking the mixture components’ symmetryperturb_weights, a normal draw of standard deviation 0.1 on every weight (gauss_flows#265)
training at a fair learning rate(1)pipekit-train’s TrainingLoop, three peak rates, held-out rows

Next. The warm start is a diagonal flow until training. Notebook 06 checks that the warm start is exactly the diagonal flow of fit_rbig, layer by layer, and finds where that fails today.