Repository navigation
[RFC]: add native float32 support for ML loss functions and activation primitives #16124
Copy link
Copy link
Open
Labels
AcceptedRFC feature request which has been accepted.RFC feature request which has been accepted.CIssue involves or relates to C.Issue involves or relates to C.FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.Machine LearningIssue or pull request specific to machine learning functionality.Issue or pull request specific to machine learning functionality.MathIssue or pull request specific to math functionality.Issue or pull request specific to math functionality.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.
Description
Description
This RFC proposes adding native single-precision (float32) support for the core machine learning loss functions and activation primitives.
Currently, the lack of float32 packages forces the engine to cast Float32Array buffers up to float64 to compute mathematical operations before casting back down. This doubles memory bandwidth usage and hinders SIMD vectorization. These proposed packages rely on standard algebraic arithmetic and can be efficiently implemented via single-precision C kernels without requiring new polynomial derivations.
Core ML Loss Functions (Forward & Gradients)
-
ml/base/loss/float32/epsilon-insensitive -
ml/base/loss/float32/epsilon-insensitive-gradient -
ml/base/loss/float32/hinge -
ml/base/loss/float32/hinge-gradientfeat: addml/base/loss/float32/hinge-gradient#16275 -
ml/base/loss/float32/huber -
ml/base/loss/float32/huber-gradientfeat: addml/base/loss/float32/huber-gradient#16289 -
ml/base/loss/float32/log -
ml/base/loss/float32/log-gradient -
ml/base/loss/float32/modified-huber -
ml/base/loss/float32/modified-huber-gradient -
ml/base/loss/float32/squared-epsilon-insensitive -
ml/base/loss/float32/squared-epsilon-insensitive-gradient -
ml/base/loss/float32/squared-error -
ml/base/loss/float32/squared-error-gradientfeat: addml/base/loss/float32/squared-error-gradient#16287 -
ml/base/loss/float32/squared-hinge -
ml/base/loss/float32/squared-hinge-gradientfeat: addml/base/loss/float32/squared-hinge-gradient#16276
ML Activations
-
math/base/special/siluf -
math/base/special/geluf -
math/base/special/fast/gelu-tanhf -
math/base/special/fast/gelu-quickf
Prerequisites
The above ML pipeline relies on the following core single-precision math primitives, which are already being tracked in the #649:
-
math/base/special/erfcf(Required forgeluf) -
math/base/special/expitf(Required forsilufandgelu-tanhf) -
math/base/special/log1pexpf(Required forlogloss functions)
Related Issues
None.
Questions
None.
Other
No.
Checklist
- I have read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
- The issue name begins with
RFC:.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
AcceptedRFC feature request which has been accepted.RFC feature request which has been accepted.CIssue involves or relates to C.Issue involves or relates to C.FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.Machine LearningIssue or pull request specific to machine learning functionality.Issue or pull request specific to machine learning functionality.MathIssue or pull request specific to math functionality.Issue or pull request specific to math functionality.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.
Activity