NVIDIA-NeMo / NVIDIA-NeMo/Emerging-Optimizers

Locoprop-S and Newton-Muon support via TE, Megatron-LM changes.

Open
#215 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
274
Forks
51
Avg merge
1d 3h
Merged PRs (30d)
6

Description

Is your feature request related to a problem? Please describe.

Newton-Muon and Locoprop are part of an evolving line of optimizers that study right-preconditioning on the gradient. However, a strong limitation has been that they require activation info. in the optimization step.
However,

  • Newton-Muon can be expressed as $msign(G f(C))$, where C is the feature gram matrix. (NM chooses $f(C)$ to be $C^{-1}$ but it could be something else, from what I understand).
  • Locoprop can also be expressed purely as a function of $(G,C)$ through the following construction:
Image

Hence, by adding optional support to route the _feature_gram_ ($X^T X$) beside the main_grad ($dY^TX$), via a series of not-very-invasive changes into TransformerEngine, Megatron-LM, and Emerging-Optimizers, with the possibility for a beautiful abstraction:
Image

Describe the solution you'd like

I have a functioning version of the solution with TE, Megatron-LM, EO forks pinned at Megaprop.

On a TP=2 sweep on a Megatron GPT over a FineWeb Edu set, 2000 steps, two sweeps, with the feature gram matrix refreshed every 8 steps, we have:

Image

It's wasteful to materialize the full gram matrix, so with Locoprop I tried a diagonal approximation and a block diagonal approximation.
The diagonal approximation seems to do well! NM appears to be slower at the moment due to the polar iteration maybe, I need to check.

Image

The initial speed was off for Locoprop too initially, but Codex was able to write some basic kernels very quickly.

I think there should be a few more AdamW LRs checked, but the initial results look promising, and not streaming the activations seem to work. I double-checked to make sure that the calculations come out to be equivalent.

I've also attached a design doc here for reference.
The diff excl. test files is not that huge:

repo                 | non-test diff
---------------------|-----------------------
Megatron-LM          | 13 files, +1336/-2
Emerging-Optimizers  | 6 files, +1140/-3
TransformerEngine    | 5 files, +281/-0
Total                | 24 files, +2757/-5

CC and thanks to: @mkhona-nvidia for his help!

feature_gram_matrix_optimizers_design.pdf

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the feature_gram_matrix_optimizers_design.pdf and the functioning implementation in the linked Megaprop forks. Compare the proposed changes across Megatron-LM, Emerging-Optimizers, and TransformerEngine, which together involve 24 non-test files. Done means implementing the optional feature_gram routing and supporting Locoprop-S and Newton-Muon across those projects.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.