Repository navigation
What's new
- Zero-inclusive ranges. Each multi-element slice is normalized using a range that includes zero. In exact arithmetic, this bounds each element of the gradient step by the effective learning rate. Weight decay and write-back rounding are separate.
- Upward-only stabilization. With
stabilize=True, divisors below the cross-slice mean are lifted toward it. Divisors at or above the mean are unchanged, so stabilization never amplifies a gradient update. - signSGD for single-element slices. The scalar fallback now also covers one-element vectors and shapes such as
(m, 1). These slices use the gradient's sign instead of range normalization. - Automatic step-size compensation. For tensors of rank 2 or higher, when the leading slice count
mexceeds the last-dimension widthw, Rose scales the gradient step size bysqrt(m / w). Weight decay still uses the unscaled group learning rate. - Decoupled exponential weight decay. Rose applies
exp(-lr * weight_decay)before the gradient step. With a positive reference learning rate, optionalwd_schedulemakes the decay exponent scale withlr. - One-draw BF16 stochastic rounding.
bf16_sruses a cached offset table and one random draw per updated BF16 tensor. Each element retains its exact carry probability, giving updates smaller than the local BF16 spacing a chance to reach the stored weight.
Upgrading from v1.x
compute_dtypenow defaults to"fp32"instead of"fp64".weight_decaynow defaults to1e-3instead of1e-4.- If you explicitly select
"fp16"or"bf16"compute, disable stochastic rounding withbf16_sr=False. - If you use
wd_scheduleand start warmup at a learning rate of zero, supply a positive reference rate explicitly. - Please re-tune
lrandweight_decayrather than assuming your v1 settings will produce the same updates.
Install or upgrade
python -m pip install --upgrade rose-opt==2.0.0Requires Python 3.10+ and PyTorch 2.0+. The import is unchanged: from rose_opt import Rose