Skip to main content

evie-amplify-optim

Evie-Amplify: a risk-sensitive modulation of Adam-style optimizers that allows bounded amplification on low-variance gradient coordinates, on top of the noise-dependent suppression inherited from evie-optim.

The base Evie update is structurally a shrink-only reweighting of AdamW — it can only ever damp the step. Evie-Amplify re-centers the same noise-dependent gate around a target well-posedness level so that sufficiently low-noise coordinates can receive an update larger than the corresponding AdamW step, while noisy coordinates are still strongly damped.

Install

pip install evie-amplify-optim

Usage

import torch
from evie_amplify_optim import EvieAmplifyOptimizer

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

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).
    if step == 125:
        optimizer.calibrate_gamma0()

How it works

sigma_t^2 = max(m2_hat - m1_hat^2, 0)                  # gradient-variance estimate
gamma_t   = gamma0 / (1 + gamma0 * sigma_t^2)           # adaptive risk-aversion
raw_wp    = 1 / (1 + gamma_t * sigma_t^2)               # in (0, 1], Evie's shrink-only gate
well_pos  = clamp(raw_wp / target_wp, eps, well_pos_max)
update    = -lr * m1_hat * sqrt(well_pos) / sqrt(m2_hat)

Dividing by target_wp re-centers the gate: when the raw gate exceeds target_wp (i.e. the coordinate is low-noise), well_pos > 1 and the update is amplified; otherwise it is damped, same as in base Evie. Amplification is bounded above by well_pos_max / target_wp; suppression is unbounded below as gradient variance grows.

gamma0 is calibrated once, from a separate fast-EMA variance estimate, the same way as in evie-optim.

API

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

  • lr: learning rate.
  • gamma0: initial risk-aversion ceiling; overwritten by calibrate_gamma0().
  • target_wp: re-centering target for the well-posedness gate.
  • beta1, beta2: Adam moment decay rates.
  • weight_decay: decoupled weight decay (AdamW-style).
  • well_pos_max: upper clamp on the well-posedness factor, bounding maximum amplification.
  • 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_amplify_optim-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

evie_amplify_optim-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for evie_amplify_optim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e279880d0e27cc50dfc8bfe35a03a603f77c25484615c75a5f7d07c8875cf19
MD5 43b11c40a60fc349091a62a40bafc172
BLAKE2b-256 62cbfea3833b9b49b4311815aaa32b22f015ce798cd2821b8323f7dd646ce197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for evie_amplify_optim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0dcdacbaaa1f7b779c2918ffd6ad2c647de44156f01eb8ecccff9f36cf919bc
MD5 68b287a7aad65dcc24844f2ad2ffcfde
BLAKE2b-256 ebefd0e9f8c58138304c649ebd15ae1c992821074dcdf65fbdba257e410c772f

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