Skip to content

feat(autofit): MultiStartProdigy + optax.contrib + per-start vmapped state - #1398

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/multistart-contrib-vmapped-state
Jul 20, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/multistart-contrib-vmapped-state

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase 1 of the multi-start gradient v2 promotion (autolens_workspace_developer#101). Promotes learning-rate-free / optax.contrib rule support into af.AbstractMultiStartGradient:

  • optax.contrib rule resolution — the update rule is resolved from optax then optax.contrib, unlocking prodigy and the other lr-free / experimental rules.
  • Per-start vmapped optimizer state — init/update are now jax.vmaped per start. The learning-rate-free rules estimate a global scalar step scale from whole-tree norms (Prodigy's d, DoG's max_dist, Mechanic's scale, MoMo's Polyak step); the old stacked-(n_starts, ndim) state silently coupled every start into one shared estimate. Elementwise rules (Adam/ADABelief/Lion) are numerically unaffected.
  • optax.apply_if_finite in-step guard (new max_consecutive_nan knob, default 8) — a non-finite step zeroes that start's update rather than NaN-poisoning the population, with the value= branch for MoMo-family rules (optax >= 0.2.5 forwards it).
  • af.MultiStartProdigy — learning-rate-free; on the parametric MGE cell it reaches Adam's optimum with no learning rate (the headline Remove use of sym link from Emcee, Dynesty. #101 result).

The restart-on-death resurrection recovery layer is deferred to Phase 2 (it builds on this PR's per-start vmapped state).

API Changes

  • Added af.MultiStartProdigy — a learning-rate-free multi-start gradient MAP search (optax.contrib.prodigy).
  • Added a max_consecutive_nan: int = 8 constructor argument on af.AbstractMultiStartGradient (inherited by all MultiStart* searches) — the apply_if_finite per-start rejected-step budget.
  • Changed behaviour (backward-compatible): the existing MultiStartAdam / MultiStartADABelief / MultiStartLion now use per-start vmapped optimizer state and an apply_if_finite guard. For these elementwise rules this is numerically identical on finite trajectories — results are unchanged.
  • Dependency: optax pin raised to optax>=0.2.5 (for apply_if_finite's value= forwarding).

See full details below.

Test Plan

  • Library unit suite (numpy-only): pytest test_autofit/non_linear/search/mle/ — 7 passed (Prodigy defaults / lr-free / dict round-trip, max_consecutive_nan knob).
  • JAX end-to-end (validated locally against the 1D Gaussian dataset): MultiStartAdam, MultiStartProdigy, and MultiStartProdigy(batch_size=4) each recover the truth basin; Adam and Prodigy land on the identical optimum with no learning rate on Prodigy.
  • Resume/persistence: the new vmapped ApplyIfFiniteState opt_state dill round-trips exactly and a step continues on the reloaded state.
  • Follow-up (/ship_workspace): permanent autofit_workspace_test/scripts/searches/MultiStartProdigy.py JAX validation script.
Full API Changes (for automation & release notes)

Added

  • af.MultiStartProdigy(...) — learning-rate-free multi-start gradient MAP search using optax.contrib.prodigy; optax_method = "prodigy", _default_learning_rate = None.
  • af.AbstractMultiStartGradient(..., max_consecutive_nan: int = 8, ...) — new constructor argument (inherited by MultiStartAdam / MultiStartADABelief / MultiStartLion / MultiStartProdigy); the optax.apply_if_finite per-start rejected-step budget. Serialised in to_dict/from_dict and recorded in samples_info.

Changed Behaviour

  • AbstractMultiStartGradient._fit — optimizer state moved from a single stacked init to per-start jax.vmap(optimizer.init), and the update step is a per-start jax.vmap of optimizer.update (with a value=-forwarding branch for MoMo-family rules). The rule is wrapped in optax.apply_if_finite. Numerically inert for the elementwise Adam family; enables lr-free rules to keep independent per-start scalar estimates.
  • Optax rule resolution changed from getattr(optax, method) to optax → optax.contrib fallback.

Migration

  • None required. Existing MultiStartAdam / MultiStartADABelief / MultiStartLion code is unchanged in behaviour and API (the new argument is optional). New capability is opt-in via af.MultiStartProdigy.

Generated by the PyAutoLabs agent workflow.

…ltiStartProdigy

Promote the learning-rate-free rule support from autolens_workspace_developer#101
into af.AbstractMultiStartGradient (Phase 1 of the multi-start gradient v2
promotion; restart-on-death resurrection is Phase 2):

- resolve the optax rule from optax then optax.contrib (unlocks prodigy et al.)
- per-start jax.vmap optimizer init/update, so the lr-free rules' global scalar
  estimates no longer couple across starts (elementwise Adam family unchanged)
- optax.apply_if_finite in-step guard (new max_consecutive_nan knob) with the
  value= branch for momo-family rules
- add af.MultiStartProdigy (learning-rate-free; == tuned Adam on the MGE cell)
- bump optax pin to >=0.2.5

Numpy-only unit tests; JAX MGE validation follows in autofit_workspace_test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Linked workspace PR (JAX validation for af.MultiStartProdigy): PyAutoLabs/autofit_workspace_test#58 (pending-release). Library-first merge gate: this PR merges first, then #58.

@Jammy2211
Jammy2211 merged commit bc48c87 into main Jul 20, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/multistart-contrib-vmapped-state branch July 20, 2026 19:04
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 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