Skip to content

Key RAdam cached step sizes by their hyperparameters - #564

Open
Afloat16 wants to merge 1 commit into
jettify:masterfrom
Afloat16:fix/radam-cache-hyperparameters-20261112
Open

Afloat16 wants to merge 1 commit into
jettify:masterfrom
Afloat16:fix/radam-cache-hyperparameters-20261112

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

RAdam caches a learning-rate-dependent step size using only the parameter's step counter. Groups with the same betas can share that cache, so a later group can use the first group's learning rate. A parameter receiving its first gradient after a learning-rate change can also reuse a stale entry. Iterable groups with different betas have the same problem when they bypass the list-only constructor setup.

With learning rates 0.01 and 0.1, the second parameter's first coordinate becomes approximately 0.997 instead of 0.970 for a gradient of 0.3.

Change

Key each cache entry by every scalar that determines its value: step, beta1, beta2, and learning rate. The update equations and cache size are unchanged. Old checkpoints with integer-only keys naturally miss and recompute their entries.

Validation

Native CPU tests with Python 3.12.14 and PyTorch 2.15.0+cpu:

  • New suite: 8 failed / 6 passed before; 14 passed after. Grouped training is compared step by step with independent optimizers, across list/generator inputs, different betas, both learning-rate orders, delayed gradients, rectified and early steps, and old cache entries.
  • Existing RAdam selection retains 7 failed / 4 passed before and after. The seven existing TestOptim::test_optimizer[RAdam_0..6] failures are the saved-state snapshot comparison in _test_state_dict at line 205: loaded moment tensors share storage with the input checkpoint and subsequent steps mutate them. The preceding resumed-parameter comparisons and the three benchmark cases plus neural-network case pass.
  • Changed files pass Black 23.3.0, isort 5.9.3, pycodestyle, pyflakes, and git diff --check.

CPU validation does not cover CUDA or the historical CI matrix. The repository's RAdam deprecation warnings remain unchanged.

The earlier #103 separated buffers for constructor lists with different betas; it did not include learning rates in the cache key or cover generator groups and delayed gradients.

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