Skip to content

Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN004 · Training method

Adafactor

Reduces optimizer-state storage by approximating matrix second moments using row and column factors.

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Reduces optimizer-state storage by approximating matrix second moments using row and column factors.

Question / hypotheses

Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.

Architecture / computational structure

Matrix parameters maintain row/column statistics rather than a full second-moment tensor; vector parameters need separate treatment.

Assumptions

Factoring is an approximation to adaptive statistics, not a claim that model weights are low rank. Update clipping and relative-step options affect behavior.

Formula / computational definition

V^ij=ricj/rˉ,U=G/(V^+ϵ).\widehat V_{ij}=r_i c_j/\bar r,\qquad U=G/(\sqrt{\widehat V}+\epsilon).

Parameters and notation

Learned: model weights. State: factored second moments and optional first moments. Hyperparameters: decay schedule, relative versus absolute step, update clipping, parameter scaling, epsilon.

Fitting, fine-tuning, and adaptation

Use the schedule convention documented by the implementation; do not combine a relative-step optimizer with an incompatible external schedule. Validate adaptation with representative gradients.

How to use and calibrate

Measure peak memory, update norms, validation loss, and wall time. Example: fine-tune a text encoder under optimizer-memory constraints.

Example application

fine-tune a text encoder under optimizer-memory constraints.

Interpretation / pitfalls

Watch out

The displayed operation is only the factored preconditioner; the complete method includes time-varying decay, clipping, and scale rules. A memory saving does not automatically imply equal downstream quality.

Python and R code examples

Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — numerical mechanism demonstration. · needs numpy

import numpy as np
G=np.array([[1.,2.,3.],[2.,1.,2.]]); V=G*G
r=V.mean(1); c=V.mean(0); approx=np.outer(r,c)/r.mean(); print(G/(np.sqrt(approx)+1e-8))
R

Component demo, not a trained model — numerical mechanism demonstration.

G <- rbind(c(1,2,3),c(2,1,2)); V <- G*G
r <- rowMeans(V); c <- colMeans(V); approx <- outer(r,c)/mean(r); print(G/(sqrt(approx)+1e-8))

Sources

From the CodeSplash reference, entry TRN004.