Fix MLX rholrate to ratchet at maxdecs (#195) - #197
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #195.
Mirrors the torch/numpy fix from #194 for the MLX backend:
rholrateis now a maxdecs-ratcheted ceiling, not a per-LL-decrease monotone decay. The oldself.rholrate *= self.rholratefacton every decrease collapsed the rho rate toward ~1e-5 and froze the shape.Design decision (the open question in #195)
Fortran gates the
rholrate0ceiling ratchet oniter > newt_startindependent ofdo_newton(amica15.f90:1049 -- unlike thenewtrateratchet one line below, which also requires Newton). So MLX keepsnewt_start(default 50) purely as that schedule threshold, even though it does no Newton.rholrateis reset torholrate0at fit start and, since MLX has no rho ramp, nothing re-inflates it -- so it ratchets only at maxdecs.Tests (real sample EEG, Apple GPU)
Two new tests, both passing on the GPU:
test_rholrate_ratchets_at_maxdecs_not_per_decrease: an aggressive-lrate run triggers several LL decreases; the survivingrholrateratcheted at the maxdecs cadence (rholrate0 * factor^k), orders of magnitude above the old per-decrease decay.test_rholrate_ceiling_ratchet_gated_on_newt_start: withnewt_startpast the budget, decreases never move the ceiling (gate holds).Full MLX suite: 10 passed. ruff + ty clean.