LoGRA: Low-Rank Gradient Sketches
Full gradient buffers and policy synchronization are costly; LoGRA accumulates projected gradient sketches and reuses their low-rank factors for weight updates and rollout synchronization.
Read the paper ↗What it is
- Gradient sketch A small set of projected gradient values that can be accumulated during backpropagation without storing the full weight gradient.
- Factorized update The compact sketch and its projection combine into a low-rank approximation that updates the full-sized weights.
- Policy synchronization The trainer sends the compact update factors and a seed so the rollout system can recreate the projection and apply the same change.
Why it matters
Large gradient buffers and full update transfers can be costly in reinforcement-learning training. LoGRA replaces them with compact factors, trading exact full-gradient updates for smaller gradient state and synchronization payloads.
Before getting into the mechanics, here is the short version: LoGRA keeps a compact sketch of a weight gradient instead of holding the whole gradient matrix. It then turns that sketch into a low-rank update, and the same compact factors can be sent to the rollout system so its policy catches up. The weights themselves stay full-sized; the compactness is in the gradient state and transfer.
-
Memory: A gradient for a large matrix can itself be large. The canonical example is one selected attention or MLP projection matrix: its ordinary gradient has the same shape as its weights, so a separate full gradient buffer adds substantial state. LoGRA keeps only projected contributions while accumulating gradients. The tradeoff is that model weights, activations, and other buffers do not disappear.
-
Synchronization: The rollout engine needs to apply the trainer’s update. Sending a full matrix update is the straightforward option, but it moves all its entries. LoGRA sends compact factors and a seed so the rollout side can rebuild the projection and apply the matching update. This is a compact representation of the update, not a compressed model.
So how do you get a useful update from a sketch without building the full gradient first? Think of the projection as a fixed narrow lens during one accumulation: each microbatch’s gradient contribution is viewed through the same lens, and the small results are added together. The concrete case is a weight-gradient calculation for one matrix; the implementation projects the inputs used in that calculation before combining them with backward derivatives. In the paper’s notation, the resulting sketch is . In words, multiply the full gradient conceptually by the projection transpose to describe what the sketch represents; the implementation accumulates the projected contributions directly rather than constructing that full matrix. This is the central practical point.
What can the compact sketch actually do to the weights? It is expanded back to the weight shape by multiplying by the same projection, giving . In words, the sketch’s columns are mixed by the projection to form a full-shaped gradient approximation. Because all columns come from just the sketch’s small set of columns, the update is low-rank; it approximates the full gradient rather than recovering it exactly. That is a real tradeoff: less gradient state and a compact update, but not an unrestricted full-gradient step.
What happens when the next training step comes along? The projection is held fixed while microbatches are accumulated, then refreshed for the next step. You can think of that as changing the narrow lens between steps, so the sequence of updates can cover different subspaces; the analogy is limited because the weight update itself is still applied to the full matrix. The rollout engine regenerates the projection from its seed and applies the received factor. In the basic SGD variant, the sketch itself is used; an optimizer can instead adjust it first. How much the update should change the policy is a separate step-size-control question, rather than a property of the sketch representation.
Read the deep dive
Why People Wanted It
In RL post-training, a selected weight matrix can have a gradient as large as the matrix itself. Keeping that full gradient while training costs memory, and sending a full update to the rollout engine costs communication. So the real question was: can you accumulate and apply a useful gradient representation without ever building the full gradient buffer?
The Core Move
LoGRA projects each weight-gradient contribution into a small fixed random basis, accumulates that sketch during backpropagation, then uses the sketch factors for a low-rank update and policy synchronization.
For a weight matrix , choose a random projection , where . The paper defines the sketch as , with . This notation states the desired sketch; the implementation accumulates projected contributions directly rather than first forming .
Why the Sketch Can Be Accumulated Without a Full Gradient
Here is the first deeper layer: the paper’s key implementation detail is to move the projection into the weight-gradient calculation. For each microbatch contribution , the algorithm adds to . Since is held fixed during accumulation, this gives the projected sum of microbatch gradients without allocating the full gradient matrix.
The projection is sampled independently of the current batch and is not learned. Its entries are random signs scaled by by default. The sketch has values instead of ; this saves gradient-accumulator storage, not the memory for model weights, activations, cached projections, or other buffers. The ordinary forward computation is preserved.
Why the Update Is Low-Rank but Not an Exact Recovery
Now the version for readers who want more of the machinery: the factors reconstruct a full-shaped approximation, not the full gradient itself. The paper uses in place of ; each column of is a combination of the columns of , so the update has rank at most .
An optimizer may adjust the sketch before applying it. Calling the adjusted sketch , the update is . In the basic SGD variant, ; is the nominal step size and scales it. The equation is the update written as a product of compact factors, while itself remains a full-sized matrix. It is an approximation to the gradient, not an exact reconstruction.
Why Refreshing the Projection Enables New Update Directions
Here is the next technical layer: the projection is held fixed across one accumulation, then refreshed each training step. The rollout engine can regenerate the same from its seed and apply the received factor .
Because successive steps can use different projection subspaces, their summed updates need not have rank at most . Synchronization sends the compact factor plus a seed and metadata instead of a full update. The mechanism’s stated scope is selected attention and MLP projection matrices, with other parameters held fixed. What the sketch saves is clear; what it leaves to the optimizer is how faithfully the low-rank approximation serves a particular training objective.
Minimal Causal Code
This plain loop shows the update state: each microbatch contributes directly to the sketch, and the full gradient matrix is never created.
# W: [d, k]; A: [r, k]; S: [d, r]
A = sample_projection(seed, r, k)
S = torch.zeros(d, r, dtype=torch.float32, device=W.device)
for microbatch in microbatches:
# Conceptual projected weight-gradient contribution.
# A real implementation projects the inputs in the weight-gradient calculation.
S += projected_weight_gradient(microbatch, W, A)
U = S # basic SGD variant
W -= alpha * eta * (U @ A)
# Send alpha * eta * U and the seed; rollout regenerates A and applies the update.
What You Gain, and What You Lose
You gain a smaller gradient accumulator and a synchronization payload based on the sketch factors rather than a full matrix update. For the paper’s stated example with and , fp32 gradient-accumulator storage falls from 64 MiB to 1 MiB; other model and training buffers still consume memory. Basic SGD needs no optimizer moments, while stateful sketch optimizers add storage of their own.
You give up exact full-gradient updates: is a low-rank approximation. The weights remain full-sized, and the savings do not erase activation or other memory costs. Refreshing the projection changes the subspace from step to step, but each individual update still uses a rank-limited sketch. Policy-update magnitude control is a separate concern from this module’s compact representation.
LoGRA keeps the weights full-sized but makes the gradient state and transmitted update compact by carrying low-rank factors.