← Back to the article

Companion notes

DiMuon: equations and experiment details

These are the equations and measurement details behind Reverse engineering DiMuon through a training API.

The gradient-meter equations#

With no clipping or weight decay, a coordinate moves by:

u=−ηg∣g∣+ϵ,g=−ϵuη−∣u∣.u=-\eta\frac{g}{|g|+\epsilon}, \qquad g=-\frac{\epsilon u}{\eta-|u|}.

Large epsilon avoids saturation. I repeated measurements with different epsilon values to check the recovered gradients, including their rounding.

The complete update equations#

After optional joint gradient clipping, form the current momentum:

Mt=βMt−1+(1−β)G~t.M_t=\beta M_{t-1}+(1-\beta)\widetilde G_t.

Compute energies from the previous momentum:

ei=∑jMt−1,ij2,fj=∑iMt−1,ij2.e_i=\sum_j M_{t-1,ij}^2, \qquad f_j=\sum_i M_{t-1,ij}^2.

Normalize each vector by its maximum, add a small ridge, and take the inverse fourth root:

Dr=diag⁡[(eimax⁡kek+10−4)−1/4],D_r=\operatorname{diag}\left[\left(\frac{e_i}{\max_k e_k}+10^{-4}\right)^{-1/4}\right],
Dc=diag⁡[(fjmax⁡kfk+10−4)−1/4].D_c=\operatorname{diag}\left[\left(\frac{f_j}{\max_k f_k}+10^{-4}\right)^{-1/4}\right].

Zero old momentum uses relative energies of one. The ridge keeps inactive coordinates from getting unbounded multipliers. Energy is a squared norm, so its inverse fourth root is an inverse square root of the norm.

Then:

Ut=Dr Φ(DrMtDc) Dc,Δθt=−ηC(r)Ut∥Ut∥F.U_t=D_r\,\Phi(D_rM_tD_c)\,D_c, \qquad \Delta\theta_t=-\eta C(r)\frac{U_t}{\|U_t\|_F}.

Φ includes the approximate polar computation and its input normalization. A zero direction gets a zero update. At alpha 32, tested ranks 1 through 64 followed:

C(r)=r(r32)0.175.C(r)=\sqrt r\left(\frac r{32}\right)^{0.175}.

This predicted a held-out rank-16 norm to about 5.6 × 10⁻⁸ relative error. The origin of 0.175 is still a mystery.

The polar computation I replayed#

Normalize the preconditioned momentum and store it in FP16:

X=round⁡FP16(DrMtDc1.01max⁡(∥DrMtDc∥F,10−7)).X=\operatorname{round}_{\mathrm{FP16}}\left( \frac{D_rM_tD_c}{1.01\max(\|D_rM_tD_c\|_F,10^{-7})} \right).

For a tall matrix, form the small Gram matrix R = XᵀX and apply a stage:

X←X[aI+R(bI+cR)].X\leftarrow X\left[aI+R(bI+cR)\right].

The coefficients change each stage. Wide matrices use the transposed construction. The intermediate stores matter, as does how the GPU reduces each matrix product.

Experiment and measurement details#

The ordinary steps use learning rate 0.001. Subtracting two nearly equal exported weights loses precision, so I also measure updates with the learning rate enlarged to 16. That changes the readout gain while keeping the optimizer state and gradient fixed.

With that readout, relative update errors were 7.6 × 10⁻⁸ to 1.21 × 10⁻⁷. At the ordinary learning rate, errors in the subtracted updates range from roughly 2 × 10⁻⁶ to 2.4 × 10⁻⁵; the accumulated local weights differ from the hosted weights by at most 9.3 × 10⁻¹⁰. The replay uses measured gradients at the hosted weights; it does not recompute them with a separate local language model. Other experiments include an unresolved 0.81% discrepancy in a rank-two B continuation and 1.14% RMS across historical A updates. The replay data covers the four-step rank-one experiment.