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

Offen
#16,124 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@AryanSharma48 arbeitet bereits daran.

Seit 25.10.2026.

  • #16313 von @AryanSharma48 — offen
  • #16317 von @AryanSharma48 — offen
  • #16358 von @Harsh28-raj — offen
  • #16594 von @devxsubh — offen

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
12/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c, javascript

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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:.
Vorherrschende Sprache
JavaScript
Sterne
6k
Forks
1.3k
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
224

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus stdlib-js/stdlib

Alle Issues in stdlib-js/stdlib

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.