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

未关闭
#16,124 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@AryanSharma48 已经在做这个了。

开始于 2026年10月25日。

  • #16313 来自 @AryanSharma48 —— 未关闭
  • #16317 来自 @AryanSharma48 —— 未关闭
  • #16358 来自 @Harsh28-raj —— 未关闭
  • #16594 来自 @devxsubh —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, javascript

调研方向

This is a tracking RFC, not a single task, so start by reading the existing float64 loss implementations under ml/base/loss/ and the float32 backlog in #649 to see how a float32 variant is laid out. The blocked activations (math/base/special/siluf, geluf, fast/gelu-tanhf, fast/gelu-quickf) depend on primitives such as erfcf and expitf that do not exist yet. Done means the team has agreed on the scope and each checklist package has its implementation, tests and benchmarks.

由索引模型根据 Issue 内容生成。

描述

Accepted C Feature JavaScript Machine Learning Math RFC
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 #16317
  • ml/base/loss/float32/hinge
  • ml/base/loss/float32/hinge-gradient #16275
  • ml/base/loss/float32/huber
  • ml/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 #16313
  • ml/base/loss/float32/squared-epsilon-insensitive
  • ml/base/loss/float32/squared-epsilon-insensitive-gradient #16358
  • ml/base/loss/float32/squared-error
  • ml/base/loss/float32/squared-error-gradient #16287
  • ml/base/loss/float32/squared-hinge
  • ml/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 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:.
主要语言
JavaScript
星标
6k
派生
1.3k
平均合并
1 天 21 小时
30 天内合并 PR
224

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stdlib-js/stdlib 的其他 Issue

查看 stdlib-js/stdlib 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。