luminav-core: Mathematical Foundations & State Invariants¶
luminav-core is the foundational dependency of the LuminaV optimizer workspace. It contains pure mathematical specifications, fixed-size parameter state buffers, precision conversions, and unbiased bitwise stochastic rounding routines without platform-specific SIMD or GPU code.
1. Mathematical Formulations¶
1.1 Dual-Buffer Convex Lookahead Momentum (buffer=2 / CLM)¶
Dual-buffer mode tracks first-order momentum \(m_t\), convex lookahead numerator \(\tilde{m}_t\), and centered innovation variance \(v_t\):
Bias-corrected denominator scaling and rational Padé \([13/6]\) hyperbolic tangent bounding (tanh_pade_f32 clamped on \([-7.9988117, 7.9988117]\)):
1.2 Single-Buffer Triangle-Defect Convex Lookahead Momentum (buffer=1 / TD-CLM)¶
Single-buffer mode eliminates the second-order buffer \(v_t\) (slashing state VRAM by 50%) by bounding the convex lookahead numerator \(\tilde{m}_t = w_1 m_{t-1} + w_2 g_t\) with \(w_1 + w_2 = 1\) directly via the Triangle Inequality \(\lvert w_1 m_{t-1} + w_2 g_t \rvert \le w_1 \lvert m_{t-1} \rvert + w_2 \lvert g_t \rvert\) and the Triangle Defect residual \(d_t^{(\text{B1})}\):
The default triangle defect ratio \(\lambda = 0.30\) is calibrated to Proposition 1's analytical symmetric spike–reversal equilibrium \(\lambda^* = \frac{2(1 - \beta_1^2)^2}{4\beta_1^2 - 3} \approx 0.3008\) for \(\beta_1 = 0.9\).
1.3 Cautious Masking & Boundary Control¶
- Cautious Update Condition: Updates are applied only along dimensions where the candidate step aligns with the gradient:
- Coordinate-wise Bound:
- Radial Manifold Bound:
2. Unbiased Bitwise Stochastic Rounding¶
When operating in BF16 or FP16 without FP32 master weights, standard Round-to-Nearest-Even (RNE) causes gradient stagnation under small learning rates \(\lvert \Delta w \rvert < 2^{-13} \lvert w \rvert\). luminav-core implements bitwise stochastic rounding:
Generated using a stateless 32-bit MurmurHash3 bit-avalanche PRNG directly seeded from tensor parameter index and training step counter.
3. Data Structures (src/state.rs & src/config.rs)¶
pub struct ParamState {
pub step: u64,
pub buf_count: BufferMode,
pub scratch: ScratchBuffer, // 6-element [mask_sum, u_sq_sum, p_sq_sum, cautious_scale, bound_scale, diff_sum]
pub exp_avg: Vec<f32>,
pub exp_avg_sq: Option<Vec<f32>>, // None when buf_count == BufferMode::TdClm
pub master_param: Option<Vec<f32>>,
}
- When
buffer == BufferMode::TdClm,exp_avg_sqis never allocated, reducing memory allocation pressure to a single vector per parameter.