trunk/be439766659656c6b0cc12f98a6fbc80ecff9f41: [MPS] Improve expm1 accuracy near zero (#198771)
- PyTorch: 1583 events in the last 90 days
- PyTorch: 1564th Release in the last 90 days
- Previous: earlier the same day · trunk/4dd1a8f7ea355060ec3ccd8602cae34c761302b6
What happened
Use expm1f for $|x| < 0.1$ instead of 1e-5 (introduced in #155611 without much explanation why this limits) to avoid cancellations in $exp(x) - 1$ . A sweep of 4,000 log-spaced float32 inputs per sign against CPU float64 found the helper more accurate on over 99% of samples in [1e-5, 0.1), with maximum relative error below 6e-8. Retain exp(x) - 1 for larger inputs, where the helper can be less accurate. Add a ded…
Summary assembled by rule from the sources below