Formula
Given two parameter vectors A and B in R^d, and interpolation parameter t in [0, 1]:Symbol Table
Shape Expectations
SLERP operates on flattened 1-D vectors. For a weight tensor of shape (H, I), both A and B are reshaped to length H * I before interpolation. The result is reshaped back to (H, I).Boundary Cases
Theta Near Zero
When A and B are nearly parallel, theta approaches 0 and sin(theta) approaches 0. Division by sin(theta) becomes numerically unstable.
Fallback formula:
Theta Near Pi
When A and B are nearly opposite, theta approaches pi. The shortest path is ambiguous: both arcs have equal length.
Engineering assumption: in practice, parameter vectors from fine-tuned variants of the same base model rarely diverge to theta near pi. This case is logged but not specially handled.
Numerical Stability
All dot products and norms are computed in fp64. The result is cast to fp32 before the final weighted sum. This prevents loss of precision when A and B are nearly orthogonal.Example
For two 3-D vectors:Cross-Links
- Merge Math for shared notation and weight shapes.
- Merge Strategies for when SLERP is selected.
- Tensor Operations for the TensorEngine implementation.