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

Aberta
#16,124 4 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@AryanSharma48 já está trabalhando nisso.

Desde 25/10/2026.

  • #16313 de @AryanSharma48 — aberto
  • #16317 de @AryanSharma48 — aberto
  • #16358 de @Harsh28-raj — aberto
  • #16594 de @devxsubh — aberto

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
12/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
c, javascript

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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:.
Linguagem predominante
JavaScript
Estrelas
6k
Forks
1.3k
Merge médio
1d 21h
PRs com merge (30d)
224

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de stdlib-js/stdlib

Todas as issues de stdlib-js/stdlib

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.