pytorch / pytorch/pytorch

Optimize Metal Kernels with sincos

Open
#184,769 6 comments 2 reactions 0 assignees View on GitHub
bot-triaged enhancement module: complex module: mps module: performance triaged
Dominant language
Python
Stars
103k
Forks
29.5k
PR merge metrics
PR metrics pending

Description

### 🚀 The feature, motivation and pitch

A lot of complex dtypes on Metal manually implement exp_ and trigonometric functions. Main have to apply both sin and cos to the same input args to do so via trig identities. These separate calls to sin and cos can be optimized to metal::precise::sincos primitive to share the range reduction between both calls and compute the exact same answer with fewer cycle. We should update these calls to use them.

### Alternatives

_No response_

### Additional context

_No response_

cc @jerryzh168 @ezyang @anjali411 @dylanbespalko @mruberry @nikitaved @amjames @kulinseth @malfet @DenisVieriu97 @jhavukainen @aditvenk

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.