Skip to content

[RFC]: add native float32 support for ML loss functions and activation primitives #16124

Open

Description

@AryanSharma48

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 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 for geluf)
  • math/base/special/expitf (Required for siluf and gelu-tanhf)
  • math/base/special/log1pexpf (Required for log loss 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:.

Activity

  1. added
    RFCRequest for comments. Feature requests and proposed changes.
    FeatureIssue or pull request for adding a new feature.
    MathIssue or pull request specific to math functionality.
    Machine LearningIssue or pull request specific to machine learning functionality.
    AcceptedRFC feature request which has been accepted.
    JavaScriptIssue involves or relates to JavaScript.
    CIssue involves or relates to C.
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedRFC feature request which has been accepted.CIssue involves or relates to C.FeatureIssue or pull request for adding a new feature.JavaScriptIssue involves or relates to JavaScript.Machine LearningIssue or pull request specific to machine learning functionality.MathIssue or pull request specific to math functionality.RFCRequest for comments. Feature requests and proposed changes.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions