← Back to events
ActiveAIRelease0.7783+0.0038j

viable/strict/1791919581: [MPS] Fix precision loss in complex sqrt (#200736)

What happened

The Metal complex sqrt computed the imaginary part as sqrt((|z| - re) / 2) , which suffers catastrophic cancellation when |im| (and the real part likewise via |z| + re when re ). E.g. on MPS sqrt(1+1e-4j) returned 1+0j instead of 1+5e-5j for complex64, and chalf sqrt(0.7783+0.0038j) had a 3.4x error in the imaginary part, which made test_sqrt fail once its explicit seed was removed. Fix by adding a c10::metal::sqrt…

Summary assembled by rule from the sources below

Why it's spreading

Sources