Skip to content

Synchronize Lookahead slow weights after each k fast steps - #571

Open
Afloat16 wants to merge 1 commit into
jettify:masterfrom
Afloat16:fix/lookahead-slow-update-cadence-20261112
Open

Afloat16 wants to merge 1 commit into
jettify:masterfrom
Afloat16:fix/lookahead-slow-update-cadence-20261112

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

Lookahead captures its first slow weights after the first inner update and synchronizes at fast steps 1, k+1, 2k+1, and so on. The first synchronization is a no-op, and later interpolation uses the wrong initial weights and cadence.

Change

Capture slow weights before the first fast step, then synchronize after every completed block of k fast steps. Initialization remains lazy, so model weights loaded after optimizer construction are captured correctly. Closure results and the inner optimizer's momentum state are preserved.

Validation

Python 3.12.14, PyTorch 2.15.0+cpu:

  • New native tests: 13 failed / 6 passed before; 19 passed after. A closed-form geometric-series oracle checks constant-gradient SGD with and without momentum across k=1/2/5 and alpha=0/0.5/1, including partial blocks and weights loaded after construction. A quadratic closure checks both returned losses and the synchronized parameter value.
  • All 4 existing Lookahead convergence tests pass before and after.
  • Changed files pass Black 23.3.0, isort 5.9.3, pycodestyle, pyflakes, and git diff --check.

The scope is slow-weight initialization and update cadence. The existing modern-PyTorch state_dict-hook compatibility problem is unchanged and is not presented as passing checkpoint coverage. CUDA and the full historical CI matrix are outside this validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant