Skip to content

Validate GPAAdamW lr is strictly positive at construction - #283

Open
rootkiller6788 wants to merge 1 commit into
facebookresearch:mainfrom
rootkiller6788:fix-gpa-lr-zero-validation
Open

rootkiller6788 wants to merge 1 commit into
facebookresearch:mainfrom
rootkiller6788:fix-gpa-lr-zero-validation

Conversation

@rootkiller6788

Copy link
Copy Markdown

Problem

GPAAdamW.__init__ only rejected lr < 0, so GPAAdamW(params, lr=0.0) was accepted. However step() asserts lr_max > 0 (and the SCHEDULE_FREE averaging weight divides by lr_max), so the first step() call always crashed with an opaque AssertionError:

AssertionError: lr_max must be positive, got lr_max=0.0. Check that lr=0.0 is positive.

The constructor and the step loop disagree on whether lr=0.0 is valid, turning a configuration error into a deferred crash with a confusing message.

Fix

Validate lr > 0.0 at construction, so an invalid learning rate fails fast with a clear ValueError consistent with the invariant asserted in step(). No valid configuration changes behavior — lr=0.0 never actually worked.

Also documents that lr must be positive in the docstring.

Test

Adds a regression case to gpa/tests/gpa_adamw_test.py asserting GPAAdamW(..., lr=0.0) raises ValueError("Invalid learning rate: 0.0").

All 19 GPA unit/equivalence tests pass locally.

step() asserts lr_max > 0 (and the SCHEDULE_FREE averaging weight divides
by lr_max), but __init__ only rejected negative lr, so lr=0.0 was accepted
at construction and then crashed on the first step() with an opaque
AssertionError. Reject lr <= 0 up front with a clear ValueError and cover
it in the invalid-hyperparameter tests.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 18, 2026
@rootkiller6788
rootkiller6788 marked this pull request as ready for review November 26, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant