seismic-descent

Seismic Optimizer for PyTorch

This document explains the implementation of the Seismic Descent algorithm as a standard PyTorch optimizer.

Overview

Traditional optimizers like SGD or Adam use stochasticity on a per-step basis (mini-batch sampling or weight noise). SeismicOptimizer introduces a dynamic, spatially correlated noise field over the entire parameter space of the model.

At every step, the optimizer adds the analytic gradient of this noise field to the loss gradient. The noise field vibrates with a specific frequency and amplitude schedule (“tremors”), which helps the model parameters “slide” out of sharp local minima into broader, more stable valleys.

Mathematical Foundation

The noise field $\eta(w, t)$ is approximated using Random Fourier Features (RFF):

\[\eta(w, t) = \sqrt{\frac{2}{R}} \cdot A(t) \cdot \sum_{r=1}^R \cos(\omega_r \cdot w + t \cdot \text{drift}_r + \phi_r)\]

Where:

The update rule is: \(w_{t+1} = w_t - \gamma \cdot (\nabla_w L + \nabla_w \eta)\)

The gradient $\nabla_w \eta$ is calculated analytically: \(\nabla_w \eta = -\sqrt{\frac{2}{R}} \cdot A(t) \cdot \sum_{r=1}^R \sin(\omega_r \cdot w + \text{offset}) \cdot \omega_r\)

Configuration Parameters

Best Practice Configurations (MNIST)

Our benchmarks suggest that unlike standard SGD, Seismic Descent benefits from a higher Learning Rate combined with a lower Noise Amplitude:

Parameter Recommended Value
lr 0.1
noise_amplitude 0.1
noise_decay 0.999
n_cycles 10+

Observation: High noise_amplitude (>1.0) with high lr (>0.01) can cause gradient explosion in neural networks. Keep amplitude subtle for deep learning models.

Scalability and Memory

The current implementation uses a Global Feature Field. It concatenates all model parameters into a single vector and applies a single RFF projection.

Implementation

The optimizer is defined in seismic_optimizer.py.

Example usage:

from seismic_optimizer import SeismicOptimizer

optimizer = SeismicOptimizer(
    model.parameters(), 
    lr=0.01, 
    noise_amplitude=0.5, 
    n_cycles=10
)