Skip to content

chore: Validate eps in Adam at construction - #1

Merged
vraj00222 merged 1 commit into
mainfrom
vraj/validate-adam-eps
Aug 20, 2026
Merged

vraj00222 merged 1 commit into
mainfrom
vraj/validate-adam-eps

Conversation

@vraj00222

@vraj00222 vraj00222 commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

Adam and AdamW accept any eps, including negative values , while RMSprop, Adagrad, AdaDelta all reject eps <= 0 at construction. eps sits directly in the update denominator, so a bad value doesn't error, it just changes which direction the parameter moves

This adds one check to Adam.init, right after the existing betas validation. Since AdamW and Adamax both call this init through super(), the check covers all three optimizers at once, and Adamax's own copy of the check becomes dead code so i removed in this diff. The only visible side effect is that Adamax(eps=-1)'s error message now reads "Adam epsilon..." instead of "Epsilon value...".

The bound stays >=0 rather than >0, because Adamax already allows eps=0. Tightening that is a separate decision I'm leaving to maintainers, not something i should do in these fix. eps=0.0 and small positive values still construct for Adam, AdamW, and Adamax, unaffected by this change.

The new test cases fail on main with AssertionError: ValueError not raised, and pass on this branch under both DEVICE=cpu and DEVICE=gpu (26/26), with the full suite at 858 OK, 5 skipped, and pre-commit clean.

I used Claude Code to help me but every number and error string above is from a run on my machine, and I reviewed and understand every line in this diff.

@vraj00222
vraj00222 merged commit 27418ef into main Aug 20, 2026
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