Skip to main content

evie-optim

Evie: a risk-sensitive modulation of Adam-style optimizers for stochastic optimization, based on a risk-sensitive (Jacobson–Whittle) control formulation of neural network training. Evie multiplies the usual adaptive step by a noise-dependent, shrink-only gate: coordinates with higher gradient-noise variance get shrunk more.

For a variant that also allows bounded amplification on low-variance coordinates, see the companion package evie-amplify-optim.

Install

pip install evie-optim

Usage

import torch
from evie_optim import EvieOptimizer

model = torch.nn.Linear(10, 1)
optimizer = EvieOptimizer(model.parameters(), lr=1e-3, target_wp=0.85)

for step, (x, y) in enumerate(dataloader):
    optimizer.zero_grad()
    loss = torch.nn.functional.mse_loss(model(x), y)
    loss.backward()
    optimizer.step()

    # Calibrate gamma0 once, early in training (paper uses step 100-150).
    # Before this call, Evie behaves like plain AdamW.
    if step == 125:
        optimizer.calibrate_gamma0()

How it works

Evie treats mini-batch gradient noise as a stochastic disturbance in a control formulation of training, and derives a closed-form gain from the corresponding risk-sensitive Riccati equation. The practical update is:

sigma_t^2 = max(m2_hat - m1_hat^2, 0)              # gradient-variance estimate
gamma_t   = gamma0 / (1 + gamma0 * sigma_t^2)       # adaptive risk-aversion
well_pos  = 1 - gamma_t * sigma_t^2                 # in (0, 1]
update    = -lr * m1_hat * sqrt(well_pos) / sqrt(m2_hat)

gamma0 is calibrated once, from a separate fast-EMA variance estimate, so that well_pos starts near target_wp at the calibration step.

Because well_pos <= 1 always, Evie can only shrink the corresponding AdamW step — it never amplifies. See evie-amplify-optim for a variant that removes this restriction.

API

EvieOptimizer(params, lr=1e-3, gamma0=1.0, target_wp=0.85, beta1=0.9, beta2=0.999, eps=1e-8, weight_decay=0.0, fast_beta=0.9)

  • lr: learning rate.
  • gamma0: initial risk-aversion ceiling; overwritten by calibrate_gamma0().
  • target_wp: target well-posedness factor used during calibration.
  • beta1, beta2: Adam moment decay rates.
  • weight_decay: decoupled weight decay (AdamW-style).
  • fast_beta: decay rate for the separate fast-EMA variance estimate used only for calibration.

optimizer.calibrate_gamma0()

Call once, partway through training, to set gamma0 from the observed gradient variance. Safe to call only after at least one step().

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evie_optim-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evie_optim-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file evie_optim-0.1.0.tar.gz.

File metadata

  • Download URL: evie_optim-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for evie_optim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3bcafae29ce90cf6e28e4aeba6899e338896cdc31794c3d840928c17d70aabd2
MD5 45af05818602cd97f8a8c0b38ae0aa74
BLAKE2b-256 b920f7f70522a318aa32b598da3f1abd0e71c17c395e54382aa40149036ece1a

See more details on using hashes here.

File details

Details for the file evie_optim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: evie_optim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for evie_optim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac5e791490827a7362890a98cd87b44e969f008a8ff8c35509ce56b9e648301
MD5 ec3102302a4ed36d60a73572fd76c288
BLAKE2b-256 7843a911619a85fef098f2fc8eebda48d6858f4fd115ab9600bdbe7fba2de012

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page